Skip to content

Commit 7d36500

Browse files
committed
remove SwiftEither to remove dependency.( use own implemention Result.swift )
1 parent 8accfeb commit 7d36500

File tree

9 files changed

+51
-171
lines changed

9 files changed

+51
-171
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Norihiro Sakamoto
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# SwiftPathClass
2-
[![CI Status](http://img.shields.io/travis/nori0620/SwiftFilePath.svg?style=flat)](https://travis-ci.org/nori0620/SwiftFilePath)
32

4-
# Dependency
5-
* [SwiftEither](https://github.com/gfx/Swift-SwiftEither)
3+
[![CI Status](http://img.shields.io/travis/nori0620/SwiftFilePath.svg?style=flat)](https://travis-ci.org/nori0620/SwiftFilePath)
64

75
# LICENSE
86

9-
The Apache 2.0 License
7+
SwiftPathClass is released under the MIT license. See LICENSE for details.

SwiftFilePath.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Pod::Spec.new do |s|
55
s.version = "0.0.1"
66
s.summary = "Simple and powerful wrapper for NSFileManager."
77
s.homepage = "https://github.com/nori0620/SwiftFilePath"
8-
s.license = "Apache License, Version 2.0"
8+
s.license = "MIT"
99
s.author = { "Norihiro Sakamoto" => "[email protected]" }
1010
s.source = { :git => "https://github.com/nori0620/SwiftFilePath.git", :tag => "0.0.1" }
1111
s.platform = :ios, '8.0'
12-
s.source_files = ["SwiftFilePath/**/*.swift", "Vendor/**/*.swift"]
12+
s.source_files = "SwiftFilePath/**/*.swift"
1313
s.requires_arc = true
1414

1515
end

SwiftFilePath.xcodeproj/project.pbxproj

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
CC7833121A610299005E77C3 /* Dir.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC78330F1A610299005E77C3 /* Dir.swift */; };
1414
CC7833131A610299005E77C3 /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC7833101A610299005E77C3 /* Entity.swift */; };
1515
CC7833141A610299005E77C3 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC7833111A610299005E77C3 /* File.swift */; };
16-
CC78331C1A618186005E77C3 /* Either.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC78331A1A61816B005E77C3 /* Either.swift */; };
1716
CC78331E1A6186B7005E77C3 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC78331D1A6186B7005E77C3 /* Result.swift */; };
1817
/* End PBXBuildFile section */
1918

@@ -37,7 +36,6 @@
3736
CC78330F1A610299005E77C3 /* Dir.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dir.swift; sourceTree = "<group>"; };
3837
CC7833101A610299005E77C3 /* Entity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Entity.swift; sourceTree = "<group>"; };
3938
CC7833111A610299005E77C3 /* File.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
40-
CC78331A1A61816B005E77C3 /* Either.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Either.swift; sourceTree = "<group>"; };
4139
CC78331D1A6186B7005E77C3 /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
4240
/* End PBXFileReference section */
4341

@@ -63,7 +61,6 @@
6361
CC7832E21A610124005E77C3 = {
6462
isa = PBXGroup;
6563
children = (
66-
CC7833081A610222005E77C3 /* Vendor */,
6764
CC7832EE1A610124005E77C3 /* SwiftFilePath */,
6865
CC7832FB1A610125005E77C3 /* SwiftFilePathTests */,
6966
CC7832ED1A610124005E77C3 /* Products */,
@@ -117,22 +114,6 @@
117114
name = "Supporting Files";
118115
sourceTree = "<group>";
119116
};
120-
CC7833081A610222005E77C3 /* Vendor */ = {
121-
isa = PBXGroup;
122-
children = (
123-
CC7833171A618046005E77C3 /* SwiftEither-0.0.1 */,
124-
);
125-
path = Vendor;
126-
sourceTree = "<group>";
127-
};
128-
CC7833171A618046005E77C3 /* SwiftEither-0.0.1 */ = {
129-
isa = PBXGroup;
130-
children = (
131-
CC78331A1A61816B005E77C3 /* Either.swift */,
132-
);
133-
path = "SwiftEither-0.0.1";
134-
sourceTree = "<group>";
135-
};
136117
/* End PBXGroup section */
137118

138119
/* Begin PBXHeadersBuildPhase section */
@@ -240,7 +221,6 @@
240221
isa = PBXSourcesBuildPhase;
241222
buildActionMask = 2147483647;
242223
files = (
243-
CC78331C1A618186005E77C3 /* Either.swift in Sources */,
244224
CC78331E1A6186B7005E77C3 /* Result.swift in Sources */,
245225
CC7833141A610299005E77C3 /* File.swift in Sources */,
246226
CC7833121A610299005E77C3 /* Dir.swift in Sources */,

SwiftFilePath/Dir.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public class Dir: Entity,SequenceType {
7373
return Dir( self.path.stringByAppendingPathComponent(path) )
7474
}
7575

76-
public func mkdir() -> Either<Dir,String> {
76+
public func mkdir() -> Result<Dir,String> {
7777
if( self.exists ){
78-
return Either(failure: "Already exists.<path:\(path)>")
78+
return Result(failure: "Already exists.<path:\(path)>")
7979
}
8080
var error: NSError?
8181
let result = fileManager.createDirectoryAtPath(path,
@@ -84,8 +84,8 @@ public class Dir: Entity,SequenceType {
8484
error: &error
8585
)
8686
return result
87-
? Either(success: self)
88-
: Either(failure: "Failed to mkdir.< error:\(error?.localizedDescription) path:\(path) >");
87+
? Result(success: self)
88+
: Result(failure: "Failed to mkdir.< error:\(error?.localizedDescription) path:\(path) >");
8989

9090
}
9191

SwiftFilePath/Entity.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,35 @@ public class Entity {
4747
return path.lastPathComponent
4848
}
4949

50-
public func remove() -> Either<Entity,String> {
50+
public func remove() -> Result<Entity,String> {
5151
assert(self.exists,"To remove file, file MUST be exists")
5252
var error: NSError?
5353
let result = fileManager.removeItemAtPath(path, error:&error)
5454
return result
55-
? Either(success: self)
56-
: Either(failure: "Failed to remove file.<error:\(error?.localizedDescription) path:\(path)>");
55+
? Result(success: self)
56+
: Result(failure: "Failed to remove file.<error:\(error?.localizedDescription) path:\(path)>");
5757
}
5858

59-
public func copyTo(toPath:Entity) -> Either<Entity,String> {
59+
public func copyTo(toPath:Entity) -> Result<Entity,String> {
6060
assert(self.exists,"To copy file, file MUST be exists")
6161
var error: NSError?
6262
let result = fileManager.copyItemAtPath(path,
6363
toPath: toPath.toString,
6464
error: &error)
6565
return result
66-
? Either(success: self)
67-
: Either(failure: "Failed to copy file.<error:\(error?.localizedDescription) from-path:\(path) to-path:\(toPath)>");
66+
? Result(success: self)
67+
: Result(failure: "Failed to copy file.<error:\(error?.localizedDescription) from-path:\(path) to-path:\(toPath)>");
6868
}
6969

70-
public func moveTo(toPath:Entity) -> Either<Entity,String> {
70+
public func moveTo(toPath:Entity) -> Result<Entity,String> {
7171
assert(self.exists,"To move file, file MUST be exists")
7272
var error: NSError?
7373
let result = fileManager.moveItemAtPath(path,
7474
toPath: toPath.toString,
7575
error: &error)
7676
return result
77-
? Either(success: self)
78-
: Either(failure: "Failed to move file.<error:\(error?.localizedDescription) from-path:\(path) to-path:\(toPath)>");
77+
? Result(success: self)
78+
: Result(failure: "Failed to move file.<error:\(error?.localizedDescription) from-path:\(path) to-path:\(toPath)>");
7979
}
8080

8181
private func loadAttributes() -> NSDictionary {

SwiftFilePath/File.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@ public class File: Entity {
1616
return Dir( path.stringByDeletingLastPathComponent )
1717
}
1818

19-
public func touch() -> Either<File,String> {
19+
public func touch() -> Result<File,String> {
2020
return self.exists
2121
? self.updateModificationDate()
2222
: self.createEmptyFile()
2323
}
2424

25-
public func updateModificationDate(date: NSDate = NSDate() ) -> Either<File,String>{
25+
public func updateModificationDate(date: NSDate = NSDate() ) -> Result<File,String>{
2626
var error: NSError?
2727
let result = fileManager.setAttributes(
2828
[NSFileModificationDate :date],
2929
ofItemAtPath:path,
3030
error:&error
3131
)
3232
return result
33-
? Either(success: self)
34-
: Either(failure: "Failed to modify file.< error:\(error?.localizedDescription) path:\(path) >");
33+
? Result(success: self)
34+
: Result(failure: "Failed to modify file.< error:\(error?.localizedDescription) path:\(path) >");
3535
}
3636

37-
private func createEmptyFile() -> Either<File,String>{
37+
private func createEmptyFile() -> Result<File,String>{
3838
let result = fileManager.createFileAtPath(path,
3939
contents:NSData(),
4040
attributes:nil
4141
)
4242
return result
43-
? Either(success: self)
44-
: Either(failure: "Failed to create file:\(path)");
43+
? Result(success: self)
44+
: Result(failure: "Failed to create file:\(path)");
4545
}
4646

4747
// MARK: - read/write String
@@ -59,15 +59,15 @@ public class File: Entity {
5959
return read
6060
}
6161

62-
public func writeString(string:String) -> Either<File,String> {
62+
public func writeString(string:String) -> Result<File,String> {
6363
var error: NSError?
6464
let result = string.writeToFile(path,
6565
atomically:true,
6666
encoding: NSUTF8StringEncoding,
6767
error: &error)
6868
return result
69-
? Either(success: self)
70-
: Either(failure: "Failed to write file.< error:\(error?.localizedDescription) path:\(path) >");
69+
? Result(success: self)
70+
: Result(failure: "Failed to write file.< error:\(error?.localizedDescription) path:\(path) >");
7171
}
7272

7373
// MARK: - read/write NSData
@@ -76,11 +76,11 @@ public class File: Entity {
7676
return NSData(contentsOfFile: path)
7777
}
7878

79-
public func writeData(data:NSData) -> Either<File,String> {
79+
public func writeData(data:NSData) -> Result<File,String> {
8080
let result = data.writeToFile(path, atomically:true)
8181
return result
82-
? Either(success: self)
83-
: Either(failure: "Failed to write file.< path:\(path) >");
82+
? Result(success: self)
83+
: Result(failure: "Failed to write file.< path:\(path) >");
8484
}
8585

8686
}

SwiftFilePathTests/SwiftFilePathTests.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,6 @@ extension String {
2121

2222
}
2323

24-
extension Either {
25-
26-
var isSuccess : Bool {
27-
switch self {
28-
case .Success(let success):
29-
return true
30-
case .Failure(let failure):
31-
return false
32-
}
33-
}
34-
35-
var isFailure: Bool {
36-
switch self {
37-
case .Success(let success):
38-
return false
39-
case .Failure(let failure):
40-
return true
41-
}
42-
}
43-
44-
}
45-
46-
4724
// MARK: Test cases
4825

4926
class SwiftFilePathTests: XCTestCase {

Vendor/SwiftEither-0.0.1/Either.swift

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)