• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

macOSのスクリーンショットの保存場所を変更するメニュバーエクストラ


Commit MetaInfo

Revisionf71edbdb8a1c018c5ffbd2186023cbaef4458110 (tree)
Time2017-04-23 23:52:13
Authormasakih <masakih@user...>
Commitermasakih

Log Message

実験的クラスを削除

Change Summary

Incremental Difference

--- a/GoInto.xcodeproj/project.pbxproj
+++ b/GoInto.xcodeproj/project.pbxproj
@@ -14,13 +14,9 @@
1414 F40EB6D01EA26BEC00FEE444 /* ActionListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40EB6CF1EA26BEC00FEE444 /* ActionListener.swift */; };
1515 F40EB6D21EA2F28100FEE444 /* Screenshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = F40EB6D11EA2F28100FEE444 /* Screenshot.swift */; };
1616 F414DD031EABAB7300111DA7 /* UserDefaultsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F414DD021EABAB7300111DA7 /* UserDefaultsExtension.swift */; };
17- F414DD051EAC12D500111DA7 /* FolderItemSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F414DD041EAC12D500111DA7 /* FolderItemSerializer.swift */; };
18- F414DD071EAC43E500111DA7 /* UserDefaultsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F414DD061EAC43E500111DA7 /* UserDefaultsTest.swift */; };
19- F463F6D91EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F463F6D81EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift */; };
20- F463F6DB1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F463F6DA1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift */; };
17+ F42539E01EACCEDE0083EB9D /* UserDefaultsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42539DF1EACCEDE0083EB9D /* UserDefaultsTest.swift */; };
2118 F47B06EB1E9A5DF9006711D9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47B06EA1E9A5DF9006711D9 /* AppDelegate.swift */; };
2219 F47B06EF1E9A5DF9006711D9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F47B06EE1E9A5DF9006711D9 /* Assets.xcassets */; };
23- F47B06FD1E9A5DF9006711D9 /* GoIntoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47B06FC1E9A5DF9006711D9 /* GoIntoTests.swift */; };
2420 F47B07081E9A6071006711D9 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F47B07071E9A6071006711D9 /* MainMenu.xib */; };
2521 F47B070C1E9A65FA006711D9 /* StatusItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47B070B1E9A65FA006711D9 /* StatusItem.swift */; };
2622 F47B070E1E9A6E55006711D9 /* StatusBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47B070D1E9A6E55006711D9 /* StatusBar.swift */; };
@@ -51,16 +47,12 @@
5147 F40EB6CF1EA26BEC00FEE444 /* ActionListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionListener.swift; sourceTree = "<group>"; };
5248 F40EB6D11EA2F28100FEE444 /* Screenshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Screenshot.swift; sourceTree = "<group>"; };
5349 F414DD021EABAB7300111DA7 /* UserDefaultsExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaultsExtension.swift; sourceTree = "<group>"; };
54- F414DD041EAC12D500111DA7 /* FolderItemSerializer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FolderItemSerializer.swift; sourceTree = "<group>"; };
55- F414DD061EAC43E500111DA7 /* UserDefaultsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaultsTest.swift; sourceTree = "<group>"; };
56- F463F6D81EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LimitedArraySerializerTest.swift; sourceTree = "<group>"; };
57- F463F6DA1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LimitedArraySerializer.swift; sourceTree = "<group>"; };
50+ F42539DF1EACCEDE0083EB9D /* UserDefaultsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaultsTest.swift; sourceTree = "<group>"; };
5851 F47B06E71E9A5DF9006711D9 /* GoInto.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GoInto.app; sourceTree = BUILT_PRODUCTS_DIR; };
5952 F47B06EA1E9A5DF9006711D9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
6053 F47B06EE1E9A5DF9006711D9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
6154 F47B06F31E9A5DF9006711D9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6255 F47B06F81E9A5DF9006711D9 /* GoIntoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GoIntoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
63- F47B06FC1E9A5DF9006711D9 /* GoIntoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoIntoTests.swift; sourceTree = "<group>"; };
6456 F47B06FE1E9A5DF9006711D9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6557 F47B07071E9A6071006711D9 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = "<group>"; };
6658 F47B070B1E9A65FA006711D9 /* StatusItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusItem.swift; sourceTree = "<group>"; };
@@ -123,8 +115,6 @@
123115 F47B07171EA10A88006711D9 /* QuitItem.swift */,
124116 F40EB6CF1EA26BEC00FEE444 /* ActionListener.swift */,
125117 F4D346931EA644170031AFB3 /* LimitedArray.swift */,
126- F463F6DA1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift */,
127- F414DD041EAC12D500111DA7 /* FolderItemSerializer.swift */,
128118 F47B06EE1E9A5DF9006711D9 /* Assets.xcassets */,
129119 F47B06F31E9A5DF9006711D9 /* Info.plist */,
130120 F40EB6C91EA1D7B500FEE444 /* ImageType.plist */,
@@ -139,9 +129,7 @@
139129 isa = PBXGroup;
140130 children = (
141131 F4DBE9271EA7864B00CEB984 /* LimitedArrayTest.swift */,
142- F463F6D81EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift */,
143- F414DD061EAC43E500111DA7 /* UserDefaultsTest.swift */,
144- F47B06FC1E9A5DF9006711D9 /* GoIntoTests.swift */,
132+ F42539DF1EACCEDE0083EB9D /* UserDefaultsTest.swift */,
145133 F47B06FE1E9A5DF9006711D9 /* Info.plist */,
146134 );
147135 path = GoIntoTests;
@@ -261,11 +249,9 @@
261249 F47B07181EA10A88006711D9 /* QuitItem.swift in Sources */,
262250 F40EB6C81EA1CD7A00FEE444 /* ImageTypeItem.swift in Sources */,
263251 F47B070E1E9A6E55006711D9 /* StatusBar.swift in Sources */,
264- F463F6DB1EAA3C9700FAB2E3 /* LimitedArraySerializer.swift in Sources */,
265252 F4D346941EA644170031AFB3 /* LimitedArray.swift in Sources */,
266253 F414DD031EABAB7300111DA7 /* UserDefaultsExtension.swift in Sources */,
267254 F47B07121EA10A3E006711D9 /* ChooseFolderItem.swift in Sources */,
268- F414DD051EAC12D500111DA7 /* FolderItemSerializer.swift in Sources */,
269255 );
270256 runOnlyForDeploymentPostprocessing = 0;
271257 };
@@ -273,10 +259,8 @@
273259 isa = PBXSourcesBuildPhase;
274260 buildActionMask = 2147483647;
275261 files = (
276- F414DD071EAC43E500111DA7 /* UserDefaultsTest.swift in Sources */,
262+ F42539E01EACCEDE0083EB9D /* UserDefaultsTest.swift in Sources */,
277263 F4DBE9281EA7864B00CEB984 /* LimitedArrayTest.swift in Sources */,
278- F463F6D91EAA3B8F00FAB2E3 /* LimitedArraySerializerTest.swift in Sources */,
279- F47B06FD1E9A5DF9006711D9 /* GoIntoTests.swift in Sources */,
280264 );
281265 runOnlyForDeploymentPostprocessing = 0;
282266 };
--- a/GoInto.xcodeproj/xcuserdata/masaki.xcuserdatad/xcschemes/GoInto.xcscheme
+++ b/GoInto.xcodeproj/xcuserdata/masaki.xcuserdatad/xcschemes/GoInto.xcscheme
@@ -24,8 +24,8 @@
2424 </BuildAction>
2525 <TestAction
2626 buildConfiguration = "Debug"
27- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
27+ selectedDebuggerIdentifier = ""
28+ selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
2929 shouldUseLaunchSchemeArgsEnv = "YES"
3030 codeCoverageEnabled = "YES">
3131 <Testables>
--- a/GoInto/FolderItemSerializer.swift
+++ /dev/null
@@ -1,37 +0,0 @@
1-//
2-// FolderItemSerializer.swift
3-// GoInto
4-//
5-// Created by Hori,Masaki on 2017/04/23.
6-// Copyright © 2017年 Hori,Masaki. All rights reserved.
7-//
8-
9-import Foundation
10-
11-final class FolderItemSerializer: NSObject, NSCoding {
12- fileprivate let url: URL
13-
14- init(_ url: URL) {
15- self.url = url
16- }
17-
18- private struct CodingKey {
19- static let url = "FolderItemWrapper.url"
20- }
21-
22- init?(coder aDecoder: NSCoder) {
23- guard let url = aDecoder.decodeObject(forKey: CodingKey.url) as? URL
24- else { return nil }
25- self.url = url
26- }
27- func encode(with aCoder: NSCoder) {
28- aCoder.encode(url, forKey: CodingKey.url)
29- }
30-}
31-extension FolderItemSerializer: Serializer {
32- var original: SerializerProvider? { return FolderItem(url) }
33-}
34-
35-extension FolderItem: SerializerProvider {
36- var serializer: Serializer { return FolderItemSerializer(url) }
37-}
--- a/GoInto/LimitedArraySerializer.swift
+++ /dev/null
@@ -1,68 +0,0 @@
1-//
2-// LimitedArraySerializer.swift
3-// GoInto
4-//
5-// Created by Hori,Masaki on 2017/04/21.
6-// Copyright © 2017年 Hori,Masaki. All rights reserved.
7-//
8-
9-import Foundation
10-
11-protocol SerializerProvider {
12- var serializer: Serializer { get }
13-}
14-protocol Serializer {
15- var original: SerializerProvider? { get }
16-}
17-
18-private struct LimitedArrayWrapperCodingKey {
19- static let array = "LimitedArrayWrapperCodingKey.Array"
20- static let size = "LimitedArrayWrapperCodingKey.Size"
21-}
22-
23-private class LimitedArrayWrapper<Element: Equatable>: NSObject, NSCoding {
24- let array: [Element]
25- let size: Int
26-
27- init(_ limited: LimitedArray<Element>) {
28- array = limited.array
29- size = limited.size
30- }
31- required init?(coder aDecoder: NSCoder) {
32- let array = aDecoder.decodeObject(forKey: LimitedArrayWrapperCodingKey.array)
33- switch array {
34- case let elements as [Element]:
35- self.array = elements
36- case let serialized as [Serializer]:
37- self.array = serialized.flatMap { $0.original as? Element }
38- default:
39- return nil
40- }
41- size = aDecoder.decodeInteger(forKey: LimitedArrayWrapperCodingKey.size)
42- }
43- func encode(with aCoder: NSCoder) {
44- if let serializable = array as? [SerializerProvider] {
45- let storeArray = serializable.map { $0.serializer }
46- aCoder.encode(storeArray, forKey: LimitedArrayWrapperCodingKey.array)
47- } else {
48- aCoder.encode(array, forKey: LimitedArrayWrapperCodingKey.array)
49- }
50- aCoder.encode(size, forKey: LimitedArrayWrapperCodingKey.size)
51- }
52-}
53-
54-class LimitedArraySerializer {
55-
56- class func seirialize<Element>(_ object: LimitedArray<Element>) -> Data {
57- let wrapper = LimitedArrayWrapper(object)
58- return NSKeyedArchiver.archivedData(withRootObject: wrapper)
59- }
60-
61- class func deserialize<Element>(_ data: Data) -> LimitedArray<Element>? {
62- guard let wrapper = NSKeyedUnarchiver.unarchiveObject(with: data) as? LimitedArrayWrapper<Element>
63- else { return nil }
64- var limited = LimitedArray<Element>(wrapper.size)
65- wrapper.array.reversed().forEach { limited.append($0) }
66- return limited
67- }
68-}
--- a/GoInto/StatusBar.swift
+++ b/GoInto/StatusBar.swift
@@ -12,7 +12,7 @@ final class StatusBar: NSObject {
1212 let myStatusBar = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)
1313 let menu = NSMenu()
1414 private(set) var items: [StatusItem] = []
15- private(set) var recentItems = LimitedArray<FolderItem>(3)
15+ private(set) var recentItems = LimitedArray<FolderItem>(5)
1616
1717 override init() {
1818 super.init()
@@ -36,6 +36,8 @@ final class StatusBar: NSObject {
3636
3737 items.reversed().forEach { $0.enter(menu) }
3838
39+ UserDefaults.standard.recentURLs?.forEach(appendFolder)
40+
3941 let currentLocation = Screenshot.shared.location
4042 if items
4143 .flatMap({ $0 as? FolderItem })
@@ -50,6 +52,8 @@ final class StatusBar: NSObject {
5052 newItem.enter(menu)
5153 newItem.set()
5254 recentItems.append(newItem)
55+
56+ UserDefaults.standard.recentURLs = recentItems.map { $0.url }
5357 }
5458 }
5559
--- a/GoInto/UserDefaultsExtension.swift
+++ b/GoInto/UserDefaultsExtension.swift
@@ -9,16 +9,23 @@
99 import Foundation
1010
1111 extension UserDefaults {
12- var recentFolders: LimitedArray<FolderItem>? {
13- get {
14- guard let data = object(forKey: "recentFolders") as? Data,
15- let serialized: LimitedArray<FolderItem> = LimitedArraySerializer.deserialize(data)
16- else { return nil }
17- return serialized
12+ func set(archived: Any?, forKey: String) {
13+ if let object = archived {
14+ let data = NSKeyedArchiver.archivedData(withRootObject: object)
15+ set(data, forKey: forKey)
16+ } else {
17+ set(nil, forKey: forKey)
1818 }
19- set {
20- let data = newValue.map { LimitedArraySerializer.seirialize($0) }
21- set(data, forKey: "recentFolders")
19+ }
20+ func unarchiveObject(forKey: String) -> Any? {
21+ if let data = object(forKey: forKey) as? Data {
22+ return NSKeyedUnarchiver.unarchiveObject(with: data)
2223 }
24+ return nil
25+ }
26+
27+ var recentURLs: [URL]? {
28+ get { return unarchiveObject(forKey: "recentURLs") as? [URL] }
29+ set { set(archived: newValue, forKey: "recentURLs") }
2330 }
2431 }
--- a/GoIntoTests/GoIntoTests.swift
+++ /dev/null
@@ -1,36 +0,0 @@
1-//
2-// GoIntoTests.swift
3-// GoIntoTests
4-//
5-// Created by Hori,Masaki on 2017/04/09.
6-// Copyright © 2017年 Hori,Masaki. All rights reserved.
7-//
8-
9-import XCTest
10-@testable import GoInto
11-
12-class GoIntoTests: XCTestCase {
13-
14- override func setUp() {
15- super.setUp()
16- // Put setup code here. This method is called before the invocation of each test method in the class.
17- }
18-
19- override func tearDown() {
20- // Put teardown code here. This method is called after the invocation of each test method in the class.
21- super.tearDown()
22- }
23-
24- func testExample() {
25- // This is an example of a functional test case.
26- // Use XCTAssert and related functions to verify your tests produce the correct results.
27- }
28-
29- func testPerformanceExample() {
30- // This is an example of a performance test case.
31- self.measure {
32- // Put the code you want to measure the time of here.
33- }
34- }
35-
36-}
--- a/GoIntoTests/LimitedArraySerializerTest.swift
+++ /dev/null
@@ -1,70 +0,0 @@
1-//
2-// LimitedArraySerializerTest.swift
3-// GoInto
4-//
5-// Created by Hori,Masaki on 2017/04/21.
6-// Copyright © 2017年 Hori,Masaki. All rights reserved.
7-//
8-
9-import XCTest
10-
11-@testable import GoInto
12-
13-
14-class LimitedArraySerializerTest: XCTestCase {
15-
16- func testInt() {
17- var limited = LimitedArray<Int>(3)
18- limited.append(1)
19- limited.append(2)
20- limited.append(3)
21-
22- let data = LimitedArraySerializer.seirialize(limited)
23- XCTAssertNotNil(data)
24- let object: LimitedArray<Int> = LimitedArraySerializer.deserialize(data) ?? LimitedArray<Int>(3)
25-
26- XCTAssertEqual(object.array, limited.array)
27- XCTAssertEqual(object.size, limited.size)
28- }
29-
30- func testURL() {
31- var limited = LimitedArray<URL>(3)
32- limited.append(URL(fileURLWithPath: "/System/"))
33- limited.append(URL(fileURLWithPath: "/Users/"))
34- limited.append(URL(fileURLWithPath: "/var/"))
35-
36- let data = LimitedArraySerializer.seirialize(limited)
37- XCTAssertNotNil(data)
38- let object: LimitedArray<URL> = LimitedArraySerializer.deserialize(data) ?? LimitedArray<URL>(3)
39-
40- XCTAssertEqual(object.array, limited.array)
41- XCTAssertEqual(object.size, limited.size)
42- }
43- func testFolderItem() {
44- var limited = LimitedArray<FolderItem>(3)
45- limited.append(FolderItem(URL(fileURLWithPath: "/System/")))
46- limited.append(FolderItem(URL(fileURLWithPath: "/Users/")))
47- limited.append(FolderItem(URL(fileURLWithPath: "/var/")))
48-
49- let data = LimitedArraySerializer.seirialize(limited)
50- XCTAssertNotNil(data)
51- let object: LimitedArray<FolderItem> = LimitedArraySerializer.deserialize(data) ?? LimitedArray<FolderItem>(3)
52-
53- XCTAssertEqual(object.array, limited.array)
54- XCTAssertEqual(object.size, limited.size)
55- }
56-
57- func testSize() {
58- var limited = LimitedArray<URL>(5)
59- limited.append(URL(fileURLWithPath: "/System/"))
60- limited.append(URL(fileURLWithPath: "/Users/"))
61- limited.append(URL(fileURLWithPath: "/var/"))
62-
63- let data = LimitedArraySerializer.seirialize(limited)
64- XCTAssertNotNil(data)
65- let object: LimitedArray<URL> = LimitedArraySerializer.deserialize(data) ?? LimitedArray<URL>(5)
66-
67- XCTAssertEqual(object.array, limited.array)
68- XCTAssertEqual(object.size, limited.size)
69- }
70-}
--- a/GoIntoTests/UserDefaultsTest.swift
+++ b/GoIntoTests/UserDefaultsTest.swift
@@ -11,20 +11,29 @@ import XCTest
1111 @testable import GoInto
1212
1313 class UserDefaultsTest: XCTestCase {
14+ var originalURLs: [URL]? = []
15+
16+ override func setUp() {
17+ super.setUp()
18+ originalURLs = UserDefaults.standard.recentURLs
19+ }
20+
21+ override func tearDown() {
22+ UserDefaults.standard.recentURLs = originalURLs
23+ super.tearDown()
24+ }
1425
1526 func testRecentFolders() {
16- var limited = LimitedArray<FolderItem>(3)
17- limited.append(FolderItem(URL(fileURLWithPath: "/System/")))
18- limited.append(FolderItem(URL(fileURLWithPath: "/Users/")))
19- limited.append(FolderItem(URL(fileURLWithPath: "/var/")))
27+ let urls = [URL(fileURLWithPath: "/System/"),
28+ URL(fileURLWithPath: "/Users/"),
29+ URL(fileURLWithPath: "/var/")]
2030
21- UserDefaults.standard.recentFolders = limited
31+ UserDefaults.standard.recentURLs = urls
2232
23- let storedData = UserDefaults.standard.recentFolders
33+ let storedData = UserDefaults.standard.recentURLs
2434 XCTAssertNotNil(storedData)
2535 guard let stored = storedData else { return }
2636
27- XCTAssertEqual(limited.array, stored.array)
28- XCTAssertEqual(limited.size, stored.size)
37+ XCTAssertEqual(urls, stored)
2938 }
3039 }