From a22b2cbbd9005cbbb525dfa5f14d4709b0f98fa5 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 10:53:30 +0000 Subject: [PATCH 01/11] [MNY-30]: Updates podspec for Result --- Money.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Money.podspec b/Money.podspec index 0178095..e63c28d 100644 --- a/Money.podspec +++ b/Money.podspec @@ -34,7 +34,7 @@ Pod::Spec.new do |s| s.tvos.exclude_files = [ 'Money/iOS' ] s.dependency 'ValueCoding' - s.dependency 'Result', '0.6.0-beta.6' + s.dependency 'Result' s.dependency 'SwiftyJSON' end From a16124f0c6f2a0bdcafb812e0561c7330ba38952 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 10:53:56 +0000 Subject: [PATCH 02/11] [MNY-30]: Updates example project --- Examples/Custom Money/Podfile.lock | 18 +- .../Pods/Local Podspecs/Money.podspec.json | 7 +- Examples/Custom Money/Pods/Manifest.lock | 18 +- .../xcshareddata/xcschemes/Money.xcscheme | 60 +++ Examples/Custom Money/Pods/Result/README.md | 1 + .../Pods/Result/Result/Result.swift | 24 +- .../Pods/Result/Result/ResultType.swift | 23 ++ .../Custom Money/Pods/SwiftyJSON/README.md | 45 +-- .../Pods/SwiftyJSON/Source/SwiftyJSON.swift | 368 ++++++++++-------- .../Target Support Files/Money/Info.plist | 2 +- .../Target Support Files/Result/Info.plist | 2 +- .../SwiftyJSON/Info.plist | 2 +- .../ValueCoding/Info.plist | 2 +- .../Custom Money/Pods/ValueCoding/README.md | 22 +- .../ValueCoding/ValueCoding/ValueCoding.swift | 26 +- 15 files changed, 384 insertions(+), 236 deletions(-) create mode 100644 Examples/Custom Money/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme diff --git a/Examples/Custom Money/Podfile.lock b/Examples/Custom Money/Podfile.lock index 539de3d..653763a 100644 --- a/Examples/Custom Money/Podfile.lock +++ b/Examples/Custom Money/Podfile.lock @@ -1,11 +1,11 @@ PODS: - - Money (1.3.0): - - Result (= 0.6.0-beta.6) + - Money (1.4.1): + - Result - SwiftyJSON - ValueCoding - - Result (0.6.0-beta.6) - - SwiftyJSON (2.3.1) - - ValueCoding (1.1.0) + - Result (1.0.1) + - SwiftyJSON (2.3.2) + - ValueCoding (1.1.1) DEPENDENCIES: - Money (from `../../`) @@ -15,9 +15,9 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - Money: 80739aa547740640fd960128baa40a28a22cc91b - Result: dc390d0b58f9ec43fcd536f1ebdd130803cc6cbc - SwiftyJSON: 592b53bee5ef3dd9b3bebc6b9cb7ee35426ae8c3 - ValueCoding: 54486fde2d7b1c2f1eb46de260b95340abed5bde + Money: 5f822a7b435ab6f07af599f0d0e40786732364ad + Result: caef80340451e1f07492fa1e89117f83613bce24 + SwiftyJSON: 04ccea08915aa0109039157c7974cf0298da292a + ValueCoding: c693457b32175c1e468b3fd838cb021100a63e71 COCOAPODS: 0.39.0 diff --git a/Examples/Custom Money/Pods/Local Podspecs/Money.podspec.json b/Examples/Custom Money/Pods/Local Podspecs/Money.podspec.json index 068f864..04f34d4 100644 --- a/Examples/Custom Money/Pods/Local Podspecs/Money.podspec.json +++ b/Examples/Custom Money/Pods/Local Podspecs/Money.podspec.json @@ -1,6 +1,6 @@ { "name": "Money", - "version": "1.3.0", + "version": "1.4.1", "summary": "Swift types for working with Money.", "description": "Money is a Swift cross platform framework for iOS, watchOS, tvOS and OS X. \n\nIt provides types and functionality to help represent and manipulate money \nand currency related information.", "homepage": "https://github.com/danthorpe/Money", @@ -10,9 +10,10 @@ }, "source": { "git": "https://github.com/danthorpe/Money.git", - "tag": "1.3.0" + "tag": "1.4.1" }, "module_name": "Money", + "documentation_url": "http://docs.danthorpe.me/money/1.4.1/index.html", "social_media_url": "https://twitter.com/danthorpe", "requires_arc": true, "platforms": { @@ -46,7 +47,7 @@ ], "Result": [ - "0.6.0-beta.6" + ], "SwiftyJSON": [ diff --git a/Examples/Custom Money/Pods/Manifest.lock b/Examples/Custom Money/Pods/Manifest.lock index 539de3d..653763a 100644 --- a/Examples/Custom Money/Pods/Manifest.lock +++ b/Examples/Custom Money/Pods/Manifest.lock @@ -1,11 +1,11 @@ PODS: - - Money (1.3.0): - - Result (= 0.6.0-beta.6) + - Money (1.4.1): + - Result - SwiftyJSON - ValueCoding - - Result (0.6.0-beta.6) - - SwiftyJSON (2.3.1) - - ValueCoding (1.1.0) + - Result (1.0.1) + - SwiftyJSON (2.3.2) + - ValueCoding (1.1.1) DEPENDENCIES: - Money (from `../../`) @@ -15,9 +15,9 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - Money: 80739aa547740640fd960128baa40a28a22cc91b - Result: dc390d0b58f9ec43fcd536f1ebdd130803cc6cbc - SwiftyJSON: 592b53bee5ef3dd9b3bebc6b9cb7ee35426ae8c3 - ValueCoding: 54486fde2d7b1c2f1eb46de260b95340abed5bde + Money: 5f822a7b435ab6f07af599f0d0e40786732364ad + Result: caef80340451e1f07492fa1e89117f83613bce24 + SwiftyJSON: 04ccea08915aa0109039157c7974cf0298da292a + ValueCoding: c693457b32175c1e468b3fd838cb021100a63e71 COCOAPODS: 0.39.0 diff --git a/Examples/Custom Money/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme b/Examples/Custom Money/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme new file mode 100644 index 0000000..2add980 --- /dev/null +++ b/Examples/Custom Money/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/Custom Money/Pods/Result/README.md b/Examples/Custom Money/Pods/Result/README.md index cec661d..2df4ab4 100644 --- a/Examples/Custom Money/Pods/Result/README.md +++ b/Examples/Custom Money/Pods/Result/README.md @@ -3,6 +3,7 @@ [![Build Status](https://travis-ci.org/antitypical/Result.svg?branch=master)](https://travis-ci.org/antitypical/Result) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/Result.svg)](https://cocoapods.org/) +[![Reference Status](https://www.versioneye.com/objective-c/result/reference_badge.svg?style=flat)](https://www.versioneye.com/objective-c/result/references) This is a Swift µframework providing `Result`. diff --git a/Examples/Custom Money/Pods/Result/Result/Result.swift b/Examples/Custom Money/Pods/Result/Result/Result.swift index d035fc3..877e48b 100644 --- a/Examples/Custom Money/Pods/Result/Result/Result.swift +++ b/Examples/Custom Money/Pods/Result/Result/Result.swift @@ -17,24 +17,28 @@ public enum Result: ResultType, CustomStringConvertible, Cu self = .Failure(error) } - /// Constructs a result from an Optional, failing with `Error` if `nil` + /// Constructs a result from an Optional, failing with `Error` if `nil`. public init(_ value: T?, @autoclosure failWith: () -> Error) { self = value.map(Result.Success) ?? .Failure(failWith()) } - /// Constructs a result from a function that uses `throw`, failing with `Error` if throws + /// Constructs a result from a function that uses `throw`, failing with `Error` if throws. public init(@autoclosure _ f: () throws -> T) { + self.init(attempt: f) + } + + /// Constructs a result from a function that uses `throw`, failing with `Error` if throws. + public init(@noescape attempt f: () throws -> T) { do { self = .Success(try f()) } catch { self = .Failure(error as! Error) } } - // MARK: Deconstruction - /// Returns the value from `Success` Results or `throw`s the error + /// Returns the value from `Success` Results or `throw`s the error. public func dematerialize() throws -> T { switch self { case let .Success(value): @@ -146,7 +150,7 @@ public func ?? (left: Result, @autoclosure right: () -> Res // MARK: - Derive result from failable closure -public func materialize(f: () throws -> T) -> Result { +public func materialize(@noescape f: () throws -> T) -> Result { return materialize(try f()) } @@ -201,4 +205,14 @@ public func >>- (result: Result, @noescape transform: T } +// MARK: - ErrorTypeConvertible conformance + +/// Make NSError conform to ErrorTypeConvertible +extension NSError: ErrorTypeConvertible { + public static func errorFromErrorType(error: ErrorType) -> NSError { + return error as NSError + } +} + + import Foundation diff --git a/Examples/Custom Money/Pods/Result/Result/ResultType.swift b/Examples/Custom Money/Pods/Result/Result/ResultType.swift index f445a32..c7ae4f9 100644 --- a/Examples/Custom Money/Pods/Result/Result/ResultType.swift +++ b/Examples/Custom Money/Pods/Result/Result/ResultType.swift @@ -64,6 +64,29 @@ public extension ResultType { } } +/// Protocol used to constrain `tryMap` to `Result`s with compatible `Error`s. +public protocol ErrorTypeConvertible: ErrorType { + typealias ConvertibleType = Self + static func errorFromErrorType(error: ErrorType) -> ConvertibleType +} + +public extension ResultType where Error: ErrorTypeConvertible { + + /// Returns the result of applying `transform` to `Success`es’ values, or wrapping thrown errors. + public func tryMap(@noescape transform: Value throws -> U) -> Result { + return flatMap { value in + do { + return .Success(try transform(value)) + } + catch { + let convertedError = Error.errorFromErrorType(error) as! Error + // Revisit this in a future version of Swift. https://twitter.com/jckarter/status/672931114944696321 + return .Failure(convertedError) + } + } + } +} + // MARK: - Operators infix operator &&& { diff --git a/Examples/Custom Money/Pods/SwiftyJSON/README.md b/Examples/Custom Money/Pods/SwiftyJSON/README.md index 20058d1..c0846f9 100644 --- a/Examples/Custom Money/Pods/SwiftyJSON/README.md +++ b/Examples/Custom Money/Pods/SwiftyJSON/README.md @@ -1,5 +1,7 @@ #SwiftyJSON [中文介绍](http://tangplin.github.io/swiftyjson/) +[![Travis CI](https://travis-ci.org/SwiftyJSON/SwiftyJSON.svg?branch=master)](https://travis-ci.org/SwiftyJSON/SwiftyJSON) + SwiftyJSON makes it easy to deal with JSON data in Swift. 1. [Why is the typical JSON handling in Swift NOT good](#why-is-the-typical-json-handling-in-swift-not-good) @@ -26,12 +28,9 @@ The code would look like this: ```swift -let JSONObject: AnyObject? = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) - -if let statusesArray = JSONObject as? [AnyObject], - let status = statusesArray[0] as? [String: AnyObject], - let user = status["user"] as? [String: AnyObject], - let username = user["name"] as? String { +if let statusesArray = try? NSJSONSerialization.JSONObjectWithData(data, options: .AllowFragments) as? [[String: AnyObject]], + let user = statusesArray[0]["user"] as? [String: AnyObject], + let username = user["name"] as? String { // Finally we got the username } @@ -43,10 +42,9 @@ Even if we use optional chaining, it would be messy: ```swift -let JSONObject: AnyObject? = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) - -if let username = (((JSONObject as? [AnyObject])?[0] as? [String: AnyObject])?["user"] as? [String: AnyObject])?["name"] as? String { - // What a disaster +if let JSONObject = try NSJSONSerialization.JSONObjectWithData(data, options: .AllowFragments) as? [[String: AnyObject]], + let username = (JSONObject[0]["user"] as? [String: AnyObject])?["name"] as? String { + // There's our username } ``` @@ -165,7 +163,7 @@ for (key,subJson):(String, JSON) in json { ```swift //If json is .Array //The `index` is 0.. JSON { + return string.dataUsingEncoding(NSUTF8StringEncoding) + .flatMap({JSON(data: $0)}) ?? JSON(NSNull()) + } + /** Creates a JSON using the object. - + - parameter object: The object must have the following properties: All objects are NSString/String, NSNumber/Int/Float/Double/Bool, NSArray/Array, NSDictionary/Dictionary, or NSNull; All dictionary keys are NSStrings/String; NSNumbers are not NaN or infinity. - + - returns: The created JSON */ public init(_ object: AnyObject) { self.object = object } - + /** Creates a JSON from a [JSON] - + - parameter jsonArray: A Swift array of JSON objects - + - returns: The created JSON */ public init(_ jsonArray:[JSON]) { self.init(jsonArray.map { $0.object }) } - + /** Creates a JSON from a [String: JSON] - + - parameter jsonDictionary: A Swift dictionary of JSON objects - + - returns: The created JSON */ public init(_ jsonDictionary:[String: JSON]) { @@ -113,7 +124,7 @@ public struct JSON { } self.init(dictionary) } - + /// Private object private var rawArray: [AnyObject] = [] private var rawDictionary: [String : AnyObject] = [:] @@ -124,7 +135,7 @@ public struct JSON { private var _type: Type = .Null /// prviate error private var _error: NSError? = nil - + /// Object in JSON public var object: AnyObject { get { @@ -170,13 +181,13 @@ public struct JSON { } } } - + /// json type public var type: Type { get { return _type } } - + /// Error in JSON public var error: NSError? { get { return self._error } } - + /// The static null json @available(*, unavailable, renamed="null") public static var nullJSON: JSON { get { return null } } @@ -185,11 +196,11 @@ public struct JSON { // MARK: - CollectionType, SequenceType, Indexable extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { - + public typealias Generator = JSONGenerator - + public typealias Index = JSONIndex - + public var startIndex: JSON.Index { switch self.type { case .Array: @@ -200,7 +211,7 @@ extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { return JSONIndex() } } - + public var endIndex: JSON.Index { switch self.type { case .Array: @@ -211,7 +222,7 @@ extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { return JSONIndex() } } - + public subscript (position: JSON.Index) -> JSON.Generator.Element { switch self.type { case .Array: @@ -223,8 +234,8 @@ extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { return ("", JSON.null) } } - - /// If `type` is `.Array` or `.Dictionary`, return `array.empty` or `dictonary.empty` otherwise return `false`. + + /// If `type` is `.Array` or `.Dictionary`, return `array.empty` or `dictonary.empty` otherwise return `true`. public var isEmpty: Bool { get { switch self.type { @@ -237,7 +248,7 @@ extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { } } } - + /// If `type` is `.Array` or `.Dictionary`, return `array.count` or `dictonary.count` otherwise return `0`. public var count: Int { switch self.type { @@ -249,7 +260,7 @@ extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { return 0 } } - + public func underestimateCount() -> Int { switch self.type { case .Array: @@ -260,10 +271,10 @@ extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { return 0 } } - + /** If `type` is `.Array` or `.Dictionary`, return a generator over the elements like `Array` or `Dictionary`, otherwise return a generator over empty. - + - returns: Return a *generator* over the elements of JSON. */ public func generate() -> JSON.Generator { @@ -272,30 +283,30 @@ extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { } public struct JSONIndex: ForwardIndexType, _Incrementable, Equatable, Comparable { - + let arrayIndex: Int? let dictionaryIndex: DictionaryIndex? - + let type: Type - + init(){ self.arrayIndex = nil self.dictionaryIndex = nil self.type = .Unknown } - + init(arrayIndex: Int) { self.arrayIndex = arrayIndex self.dictionaryIndex = nil self.type = .Array } - + init(dictionaryIndex: DictionaryIndex) { self.arrayIndex = nil self.dictionaryIndex = dictionaryIndex self.type = .Dictionary } - + public func successor() -> JSONIndex { switch self.type { case .Array: @@ -364,14 +375,14 @@ public func >(lhs: JSONIndex, rhs: JSONIndex) -> Bool { } public struct JSONGenerator : GeneratorType { - + public typealias Element = (String, JSON) - + private let type: Type private var dictionayGenerate: DictionaryGenerator? private var arrayGenerate: IndexingGenerator<[AnyObject]>? private var arrayIndex: Int = 0 - + init(_ json: JSON) { self.type = json.type if type == .Array { @@ -380,17 +391,17 @@ public struct JSONGenerator : GeneratorType { self.dictionayGenerate = json.rawDictionary.generate() } } - + public mutating func next() -> JSONGenerator.Element? { switch self.type { case .Array: - if let o = self.arrayGenerate!.next() { + if let o = self.arrayGenerate?.next() { return (String(self.arrayIndex++), JSON(o)) } else { return nil } case .Dictionary: - if let (k, v): (String, AnyObject) = self.dictionayGenerate!.next() { + if let (k, v): (String, AnyObject) = self.dictionayGenerate?.next() { return (k, JSON(v)) } else { return nil @@ -406,14 +417,29 @@ public struct JSONGenerator : GeneratorType { /** * To mark both String and Int can be used in subscript. */ -public protocol JSONSubscriptType {} +public enum JSONKey { + case Index(Int) + case Key(String) +} -extension Int: JSONSubscriptType {} +public protocol JSONSubscriptType { + var jsonKey:JSONKey { get } +} + +extension Int: JSONSubscriptType { + public var jsonKey:JSONKey { + return JSONKey.Index(self) + } +} -extension String: JSONSubscriptType {} +extension String: JSONSubscriptType { + public var jsonKey:JSONKey { + return JSONKey.Key(self) + } +} extension JSON { - + /// If `type` is `.Array`, return json which's object is `array[index]`, otherwise return null json with error. private subscript(index index: Int) -> JSON { get { @@ -437,7 +463,7 @@ extension JSON { } } } - + /// If `type` is `.Dictionary`, return json which's object is `dictionary[key]` , otherwise return null json with error. private subscript(key key: String) -> JSON { get { @@ -459,36 +485,34 @@ extension JSON { } } } - + /// If `sub` is `Int`, return `subscript(index:)`; If `sub` is `String`, return `subscript(key:)`. private subscript(sub sub: JSONSubscriptType) -> JSON { get { - if sub is String { - return self[key:sub as! String] - } else { - return self[index:sub as! Int] + switch sub.jsonKey { + case .Index(let index): return self[index: index] + case .Key(let key): return self[key: key] } } set { - if sub is String { - self[key:sub as! String] = newValue - } else { - self[index:sub as! Int] = newValue + switch sub.jsonKey { + case .Index(let index): self[index: index] = newValue + case .Key(let key): self[key: key] = newValue } } } - + /** Find a json in the complex data structuresby using the Int/String's array. - + - parameter path: The target json's path. Example: - + let json = JSON[data] let path = [9,"list","person","name"] let name = json[path] - + The same as: let name = json[9]["list"]["person"]["name"] - + - returns: Return a json found by the path or a null json with error */ public subscript(path: [JSONSubscriptType]) -> JSON { @@ -509,16 +533,16 @@ extension JSON { } } } - + /** Find a json in the complex data structuresby using the Int/String's array. - + - parameter path: The target json's path. Example: - + let name = json[9,"list","person","name"] - + The same as: let name = json[9]["list"]["person"]["name"] - + - returns: Return a json found by the path or a null json with error */ public subscript(path: JSONSubscriptType...) -> JSON { @@ -534,43 +558,43 @@ extension JSON { // MARK: - LiteralConvertible extension JSON: Swift.StringLiteralConvertible { - + public init(stringLiteral value: StringLiteralType) { self.init(value) } - + public init(extendedGraphemeClusterLiteral value: StringLiteralType) { self.init(value) } - + public init(unicodeScalarLiteral value: StringLiteralType) { self.init(value) } } extension JSON: Swift.IntegerLiteralConvertible { - + public init(integerLiteral value: IntegerLiteralType) { self.init(value) } } extension JSON: Swift.BooleanLiteralConvertible { - + public init(booleanLiteral value: BooleanLiteralType) { self.init(value) } } extension JSON: Swift.FloatLiteralConvertible { - + public init(floatLiteral value: FloatLiteralType) { self.init(value) } } extension JSON: Swift.DictionaryLiteralConvertible { - + public init(dictionaryLiteral elements: (String, AnyObject)...) { self.init(elements.reduce([String : AnyObject]()){(dictionary: [String : AnyObject], element:(String, AnyObject)) -> [String : AnyObject] in var d = dictionary @@ -581,14 +605,14 @@ extension JSON: Swift.DictionaryLiteralConvertible { } extension JSON: Swift.ArrayLiteralConvertible { - + public init(arrayLiteral elements: AnyObject...) { self.init(elements) } } extension JSON: Swift.NilLiteralConvertible { - + public init(nilLiteral: ()) { self.init(NSNull()) } @@ -597,7 +621,7 @@ extension JSON: Swift.NilLiteralConvertible { // MARK: - Raw extension JSON: Swift.RawRepresentable { - + public init?(rawValue: AnyObject) { if JSON(rawValue).type == .Unknown { return nil @@ -605,19 +629,19 @@ extension JSON: Swift.RawRepresentable { self.init(rawValue) } } - + public var rawValue: AnyObject { return self.object } - + public func rawData(options opt: NSJSONWritingOptions = NSJSONWritingOptions(rawValue: 0)) throws -> NSData { guard NSJSONSerialization.isValidJSONObject(self.object) else { throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "JSON is invalid"]) } - + return try NSJSONSerialization.dataWithJSONObject(self.object, options: opt) } - + public func rawString(encoding: UInt = NSUTF8StringEncoding, options opt: NSJSONWritingOptions = .PrettyPrinted) -> String? { switch self.type { case .Array, .Dictionary: @@ -644,7 +668,7 @@ extension JSON: Swift.RawRepresentable { // MARK: - Printable, DebugPrintable extension JSON: Swift.Printable, Swift.DebugPrintable { - + public var description: String { if let string = self.rawString(options:.PrettyPrinted) { return string @@ -652,7 +676,7 @@ extension JSON: Swift.Printable, Swift.DebugPrintable { return "unknown" } } - + public var debugDescription: String { return description } @@ -661,7 +685,7 @@ extension JSON: Swift.Printable, Swift.DebugPrintable { // MARK: - Array extension JSON { - + //Optional [JSON] public var array: [JSON]? { get { @@ -672,14 +696,14 @@ extension JSON { } } } - + //Non-optional [JSON] public var arrayValue: [JSON] { get { return self.array ?? [] } } - + //Optional [AnyObject] public var arrayObject: [AnyObject]? { get { @@ -703,7 +727,7 @@ extension JSON { // MARK: - Dictionary extension JSON { - + //Optional [String : JSON] public var dictionary: [String : JSON]? { if self.type == .Dictionary { @@ -716,12 +740,12 @@ extension JSON { return nil } } - + //Non-optional [String : JSON] public var dictionaryValue: [String : JSON] { return self.dictionary ?? [:] } - + //Optional [String : AnyObject] public var dictionaryObject: [String : AnyObject]? { get { @@ -745,7 +769,7 @@ extension JSON { // MARK: - Bool extension JSON: Swift.BooleanType { - + //Optional bool public var bool: Bool? { get { @@ -757,14 +781,14 @@ extension JSON: Swift.BooleanType { } } set { - if newValue != nil { - self.object = NSNumber(bool: newValue!) + if let newValue = newValue { + self.object = NSNumber(bool: newValue) } else { self.object = NSNull() } } } - + //Non-optional bool public var boolValue: Bool { get { @@ -784,7 +808,7 @@ extension JSON: Swift.BooleanType { // MARK: - String extension JSON { - + //Optional string public var string: String? { get { @@ -796,24 +820,24 @@ extension JSON { } } set { - if newValue != nil { - self.object = NSString(string:newValue!) + if let newValue = newValue { + self.object = NSString(string:newValue) } else { self.object = NSNull() } } } - + //Non-optional string public var stringValue: String { get { switch self.type { case .String: - return self.object as! String + return self.object as? String ?? "" case .Number: return self.object.stringValue case .Bool: - return (self.object as! Bool).description + return (self.object as? Bool).map { String($0) } ?? "" default: return "" } @@ -826,7 +850,7 @@ extension JSON { // MARK: - Number extension JSON { - + //Optional number public var number: NSNumber? { get { @@ -841,7 +865,7 @@ extension JSON { self.object = newValue ?? NSNull() } } - + //Non-optional number public var numberValue: NSNumber { get { @@ -853,7 +877,7 @@ extension JSON { } return decimal case .Number, .Bool: - return self.object as! NSNumber + return self.object as? NSNumber ?? NSNumber(int: 0) default: return NSNumber(double: 0.0) } @@ -866,7 +890,7 @@ extension JSON { //MARK: - Null extension JSON { - + public var null: NSNull? { get { switch self.type { @@ -890,7 +914,7 @@ extension JSON { //MARK: - URL extension JSON { - + //Optional URL public var URL: NSURL? { get { @@ -914,20 +938,20 @@ extension JSON { // MARK: - Int, Double, Float, Int8, Int16, Int32, Int64 extension JSON { - + public var double: Double? { get { return self.number?.doubleValue } set { - if newValue != nil { - self.object = NSNumber(double: newValue!) + if let newValue = newValue { + self.object = NSNumber(double: newValue) } else { self.object = NSNull() } } } - + public var doubleValue: Double { get { return self.numberValue.doubleValue @@ -936,20 +960,20 @@ extension JSON { self.object = NSNumber(double: newValue) } } - + public var float: Float? { get { return self.number?.floatValue } set { - if newValue != nil { - self.object = NSNumber(float: newValue!) + if let newValue = newValue { + self.object = NSNumber(float: newValue) } else { self.object = NSNull() } } } - + public var floatValue: Float { get { return self.numberValue.floatValue @@ -958,20 +982,20 @@ extension JSON { self.object = NSNumber(float: newValue) } } - + public var int: Int? { get { return self.number?.longValue } set { - if newValue != nil { - self.object = NSNumber(integer: newValue!) + if let newValue = newValue { + self.object = NSNumber(integer: newValue) } else { self.object = NSNull() } } } - + public var intValue: Int { get { return self.numberValue.integerValue @@ -980,20 +1004,20 @@ extension JSON { self.object = NSNumber(integer: newValue) } } - + public var uInt: UInt? { get { return self.number?.unsignedLongValue } set { - if newValue != nil { - self.object = NSNumber(unsignedLong: newValue!) + if let newValue = newValue { + self.object = NSNumber(unsignedLong: newValue) } else { self.object = NSNull() } } } - + public var uIntValue: UInt { get { return self.numberValue.unsignedLongValue @@ -1002,20 +1026,20 @@ extension JSON { self.object = NSNumber(unsignedLong: newValue) } } - + public var int8: Int8? { get { return self.number?.charValue } set { - if newValue != nil { - self.object = NSNumber(char: newValue!) + if let newValue = newValue { + self.object = NSNumber(char: newValue) } else { self.object = NSNull() } } } - + public var int8Value: Int8 { get { return self.numberValue.charValue @@ -1024,20 +1048,20 @@ extension JSON { self.object = NSNumber(char: newValue) } } - + public var uInt8: UInt8? { get { return self.number?.unsignedCharValue } set { - if newValue != nil { - self.object = NSNumber(unsignedChar: newValue!) + if let newValue = newValue { + self.object = NSNumber(unsignedChar: newValue) } else { self.object = NSNull() } } } - + public var uInt8Value: UInt8 { get { return self.numberValue.unsignedCharValue @@ -1046,20 +1070,20 @@ extension JSON { self.object = NSNumber(unsignedChar: newValue) } } - + public var int16: Int16? { get { return self.number?.shortValue } set { - if newValue != nil { - self.object = NSNumber(short: newValue!) + if let newValue = newValue { + self.object = NSNumber(short: newValue) } else { self.object = NSNull() } } } - + public var int16Value: Int16 { get { return self.numberValue.shortValue @@ -1068,20 +1092,20 @@ extension JSON { self.object = NSNumber(short: newValue) } } - + public var uInt16: UInt16? { get { return self.number?.unsignedShortValue } set { - if newValue != nil { - self.object = NSNumber(unsignedShort: newValue!) + if let newValue = newValue { + self.object = NSNumber(unsignedShort: newValue) } else { self.object = NSNull() } } } - + public var uInt16Value: UInt16 { get { return self.numberValue.unsignedShortValue @@ -1090,20 +1114,20 @@ extension JSON { self.object = NSNumber(unsignedShort: newValue) } } - + public var int32: Int32? { get { return self.number?.intValue } set { - if newValue != nil { - self.object = NSNumber(int: newValue!) + if let newValue = newValue { + self.object = NSNumber(int: newValue) } else { self.object = NSNull() } } } - + public var int32Value: Int32 { get { return self.numberValue.intValue @@ -1112,20 +1136,20 @@ extension JSON { self.object = NSNumber(int: newValue) } } - + public var uInt32: UInt32? { get { return self.number?.unsignedIntValue } set { - if newValue != nil { - self.object = NSNumber(unsignedInt: newValue!) + if let newValue = newValue { + self.object = NSNumber(unsignedInt: newValue) } else { self.object = NSNull() } } } - + public var uInt32Value: UInt32 { get { return self.numberValue.unsignedIntValue @@ -1134,20 +1158,20 @@ extension JSON { self.object = NSNumber(unsignedInt: newValue) } } - + public var int64: Int64? { get { return self.number?.longLongValue } set { - if newValue != nil { - self.object = NSNumber(longLong: newValue!) + if let newValue = newValue { + self.object = NSNumber(longLong: newValue) } else { self.object = NSNull() } } } - + public var int64Value: Int64 { get { return self.numberValue.longLongValue @@ -1156,20 +1180,20 @@ extension JSON { self.object = NSNumber(longLong: newValue) } } - + public var uInt64: UInt64? { get { return self.number?.unsignedLongLongValue } set { - if newValue != nil { - self.object = NSNumber(unsignedLongLong: newValue!) + if let newValue = newValue { + self.object = NSNumber(unsignedLongLong: newValue) } else { self.object = NSNull() } } } - + public var uInt64Value: UInt64 { get { return self.numberValue.unsignedLongLongValue @@ -1184,7 +1208,7 @@ extension JSON { extension JSON : Swift.Comparable {} public func ==(lhs: JSON, rhs: JSON) -> Bool { - + switch (lhs.type, rhs.type) { case (.Number, .Number): return lhs.rawNumber == rhs.rawNumber @@ -1204,7 +1228,7 @@ public func ==(lhs: JSON, rhs: JSON) -> Bool { } public func <=(lhs: JSON, rhs: JSON) -> Bool { - + switch (lhs.type, rhs.type) { case (.Number, .Number): return lhs.rawNumber <= rhs.rawNumber @@ -1224,7 +1248,7 @@ public func <=(lhs: JSON, rhs: JSON) -> Bool { } public func >=(lhs: JSON, rhs: JSON) -> Bool { - + switch (lhs.type, rhs.type) { case (.Number, .Number): return lhs.rawNumber >= rhs.rawNumber @@ -1244,7 +1268,7 @@ public func >=(lhs: JSON, rhs: JSON) -> Bool { } public func >(lhs: JSON, rhs: JSON) -> Bool { - + switch (lhs.type, rhs.type) { case (.Number, .Number): return lhs.rawNumber > rhs.rawNumber @@ -1256,7 +1280,7 @@ public func >(lhs: JSON, rhs: JSON) -> Bool { } public func <(lhs: JSON, rhs: JSON) -> Bool { - + switch (lhs.type, rhs.type) { case (.Number, .Number): return lhs.rawNumber < rhs.rawNumber @@ -1288,7 +1312,7 @@ extension NSNumber { } } -public func ==(lhs: NSNumber, rhs: NSNumber) -> Bool { +func ==(lhs: NSNumber, rhs: NSNumber) -> Bool { switch (lhs.isBool, rhs.isBool) { case (false, true): return false @@ -1299,12 +1323,12 @@ public func ==(lhs: NSNumber, rhs: NSNumber) -> Bool { } } -public func !=(lhs: NSNumber, rhs: NSNumber) -> Bool { +func !=(lhs: NSNumber, rhs: NSNumber) -> Bool { return !(lhs == rhs) } -public func <(lhs: NSNumber, rhs: NSNumber) -> Bool { - +func <(lhs: NSNumber, rhs: NSNumber) -> Bool { + switch (lhs.isBool, rhs.isBool) { case (false, true): return false @@ -1315,8 +1339,8 @@ public func <(lhs: NSNumber, rhs: NSNumber) -> Bool { } } -public func >(lhs: NSNumber, rhs: NSNumber) -> Bool { - +func >(lhs: NSNumber, rhs: NSNumber) -> Bool { + switch (lhs.isBool, rhs.isBool) { case (false, true): return false @@ -1327,8 +1351,8 @@ public func >(lhs: NSNumber, rhs: NSNumber) -> Bool { } } -public func <=(lhs: NSNumber, rhs: NSNumber) -> Bool { - +func <=(lhs: NSNumber, rhs: NSNumber) -> Bool { + switch (lhs.isBool, rhs.isBool) { case (false, true): return false @@ -1339,8 +1363,8 @@ public func <=(lhs: NSNumber, rhs: NSNumber) -> Bool { } } -public func >=(lhs: NSNumber, rhs: NSNumber) -> Bool { - +func >=(lhs: NSNumber, rhs: NSNumber) -> Bool { + switch (lhs.isBool, rhs.isBool) { case (false, true): return false diff --git a/Examples/Custom Money/Pods/Target Support Files/Money/Info.plist b/Examples/Custom Money/Pods/Target Support Files/Money/Info.plist index 8c485de..a543516 100644 --- a/Examples/Custom Money/Pods/Target Support Files/Money/Info.plist +++ b/Examples/Custom Money/Pods/Target Support Files/Money/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.3.0 + 1.4.1 CFBundleSignature ???? CFBundleVersion diff --git a/Examples/Custom Money/Pods/Target Support Files/Result/Info.plist b/Examples/Custom Money/Pods/Target Support Files/Result/Info.plist index 7b20907..513ed9d 100644 --- a/Examples/Custom Money/Pods/Target Support Files/Result/Info.plist +++ b/Examples/Custom Money/Pods/Target Support Files/Result/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.6.0-beta.6 + 1.0.1 CFBundleSignature ???? CFBundleVersion diff --git a/Examples/Custom Money/Pods/Target Support Files/SwiftyJSON/Info.plist b/Examples/Custom Money/Pods/Target Support Files/SwiftyJSON/Info.plist index a98a41a..23e7588 100644 --- a/Examples/Custom Money/Pods/Target Support Files/SwiftyJSON/Info.plist +++ b/Examples/Custom Money/Pods/Target Support Files/SwiftyJSON/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.3.1 + 2.3.2 CFBundleSignature ???? CFBundleVersion diff --git a/Examples/Custom Money/Pods/Target Support Files/ValueCoding/Info.plist b/Examples/Custom Money/Pods/Target Support Files/ValueCoding/Info.plist index 01903d7..9f5393b 100644 --- a/Examples/Custom Money/Pods/Target Support Files/ValueCoding/Info.plist +++ b/Examples/Custom Money/Pods/Target Support Files/ValueCoding/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.1.0 + 1.1.1 CFBundleSignature ???? CFBundleVersion diff --git a/Examples/Custom Money/Pods/ValueCoding/README.md b/Examples/Custom Money/Pods/ValueCoding/README.md index 18ac72c..888f177 100644 --- a/Examples/Custom Money/Pods/ValueCoding/README.md +++ b/Examples/Custom Money/Pods/ValueCoding/README.md @@ -1,7 +1,12 @@ -# ValueCoding +![](https://raw.githubusercontent.com/danthorpe/ValueCoding/development/header.png) [![Build status](https://badge.buildkite.com/482fd5558d9ccf05b669c55f40450166033522f32314a1bbb2.svg)](https://buildkite.com/blindingskies/valuecoding) [![codecov.io](http://codecov.io/github/danthorpe/ValueCoding/coverage.svg?branch=development)](http://codecov.io/github/danthorpe/ValueCoding?branch=development) +[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/ValueCoding.svg)](https://img.shields.io/cocoapods/v/ValueCoding.svg) +[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) +[![Platform](https://img.shields.io/cocoapods/p/ValueCoding.svg?style=flat)](http://cocoadocs.org/docsets/ValueCoding) + +# ValueCoding ValueCoding is a simple pair of protocols to support the coding of Swift value types. @@ -42,13 +47,13 @@ class FooCoder: NSObject, NSCoding, CodingType { If you are converting existing models from classes to values types, the `NSCoding` methods should look familiar, and hopefully you are able to reuse your existing code. -The framework provides static methods and properties for types which conform to `ValueCoding` with correct archivers. Therefore, given a value of `Foo`, you can encode it ready for serialization using `NSKeyedArchiver`. +The framework provides static methods and properties for types which conform to `ValueCoding` with valid coders. Therefore, given a value of `Foo`, you can encode it ready for archiving using `NSKeyedArchiver`. ```swift let data = NSKeyedArchiver.archivedDataWithRootObject(foo.encoded) ``` -and likewise, unarchiving (and decoding) can be done: +and likewise, decoding from unarchiving can be done: ```swift if let foo = Foo.decode(NSKeyedUnarchiver.unarchiveObjectWithData(data)) { @@ -65,16 +70,21 @@ let foos = Set(arrayLiteral: Foo(), Foo(), Foo()) let data = NSKeyedArchiver.archivedDataWithRootObject(foos.encoded) ``` -When decoding an `NSArray`, perform a conditional cast to `[AnyObject]` before passing it to `decode`. The result will be an `Array` which will be empty if the object was not cast successfully. In addition, any members of `[AnyObject]` which did not decode will filtered from the result. This means that the length of the result will be less than the original encoded array if there was an issue decoding. +When decoding an `NSArray`, perform a conditional cast to `[AnyObject]` before passing it to `decode`. The result will be an `Array` which will be empty if the object was not cast successfully. In addition, any members of `[AnyObject]` which did not decode will be filtered from the result. This means that the length of the result will be less than the original encoded array if there was an issue decoding. ```swift let foos = Foo.decode(NSKeyedUnarchiver.unarchiveObjectWithData(data) as? [AnyObject]) ``` +### CoderType Examples + +The [Money](https://github.com/danthorpe/Money) framework contains more examples of implementing `ValueCoding`. Including the generic type [`FXTransactionCoder`](https://github.com/danthorpe/Money/blob/development/Money/Shared/FX/FX.swift#L467). + +The [YapDatabaseExtensions](https://github.com/danthorpe/YapDatabaseExtension) framework relies heavily on `ValueCoding`. For more examples of generic where constraints see its [Functional API](https://github.com/danthorpe/YapDatabaseExtensions/tree/development/YapDatabaseExtensions/Shared/Functional). ### Installation -ValueCoding builds as a cross platform (iOS, OS X, watchOS) extension compatible framework. It is also available via CocoaPods +ValueCoding builds as a cross platform (iOS, OS X, watchOS, tvOS) extension compatible framework. It is also available via CocoaPods ```ruby -pod ‘ValueCoding’ +pod 'ValueCoding' ``` diff --git a/Examples/Custom Money/Pods/ValueCoding/ValueCoding/ValueCoding.swift b/Examples/Custom Money/Pods/ValueCoding/ValueCoding/ValueCoding.swift index 6ea6ab4..623f02c 100644 --- a/Examples/Custom Money/Pods/ValueCoding/ValueCoding/ValueCoding.swift +++ b/Examples/Custom Money/Pods/ValueCoding/ValueCoding/ValueCoding.swift @@ -16,6 +16,20 @@ encode/decode value types. */ public protocol CodingType { + /** + The type of the composed value, ValueType + + Bear in mind that there are no constraints on this + type. However, in reality when working with generic + types which require coding, it will be necessary to + constrain your generic clauses like this: + + ```swift + func foo() + ``` + + - see: ValueCoding + */ typealias ValueType /// The value type which is being encoded/decoded @@ -32,6 +46,12 @@ A generic protocol for value types which require coding. */ public protocol ValueCoding { + + /** + The Coder which implements CodingType + + - see: CodingType + */ typealias Coder: CodingType } @@ -48,8 +68,7 @@ extension CodingType where ValueType: ValueCoding, ValueType.Coder == Self { } } -extension SequenceType - where +extension SequenceType where Generator.Element: CodingType { /// Access the values from a sequence of coders. @@ -106,8 +125,7 @@ extension ValueCoding where Coder: NSCoding, Coder.ValueType == Self { } } -extension SequenceType - where +extension SequenceType where Generator.Element: ValueCoding, Generator.Element.Coder: NSCoding, Generator.Element.Coder.ValueType == Generator.Element { From db4a2eec9b1c807684ee68fe97a2bc5ccb39f915 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 12:29:44 +0000 Subject: [PATCH 03/11] [MNY-30]: Updates Cartfile too. --- Cartfile | 2 +- Cartfile.private | 2 +- Cartfile.resolved | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cartfile b/Cartfile index f4eeaff..2e4b6cd 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "danthorpe/ValueCoding" -github "antitypical/Result" >= 0.6 +github "antitypical/Result" >= 1.0 github "SwiftyJSON/SwiftyJSON" diff --git a/Cartfile.private b/Cartfile.private index 7c3e1ca..d3f519b 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1 +1 @@ -github "venmo/DVR" ~> 0.1.3 +github "venmo/DVR" diff --git a/Cartfile.resolved b/Cartfile.resolved index 06dc530..a6a393a 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "venmo/DVR" "v0.1.4" -github "antitypical/Result" "0.6.0-beta.6" -github "SwiftyJSON/SwiftyJSON" "2.3.1" -github "danthorpe/ValueCoding" "1.1.0" +github "venmo/DVR" "v0.2.0" +github "antitypical/Result" "1.0.1" +github "SwiftyJSON/SwiftyJSON" "2.3.3" +github "danthorpe/ValueCoding" "1.1.1" From 0e428fd7e3f763da411e0774a91616217c82d401 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 12:30:59 +0000 Subject: [PATCH 04/11] [MNY-30]: Xcode 7.2 issues --- .../Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Custom Money/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme b/Examples/Custom Money/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme index 2add980..f323f82 100644 --- a/Examples/Custom Money/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme +++ b/Examples/Custom Money/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Money.xcscheme @@ -14,7 +14,7 @@ buildForArchiving = "YES"> From a484fb285c48978d90aeb4508c629f2a2b9067e0 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 12:33:51 +0000 Subject: [PATCH 05/11] [MNY-30]: Updates Gems --- Gemfile.lock | 108 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a260f26..6bb9da6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,58 +13,64 @@ GEM extlib (>= 0.9.15) multi_json (>= 1.0.0) babosa (1.0.2) - cert (1.2.3) - fastlane_core (>= 0.19.0, < 1.0.0) - spaceship (>= 0.6.0) + cert (1.2.7) + fastlane_core (>= 0.26.4, < 1.0.0) + spaceship (>= 0.15.1, < 1.0.0) claide (0.9.1) coderay (1.1.0) colored (1.2) commander (4.3.5) highline (~> 1.7.2) - credentials_manager (0.11.0) + credentials_manager (0.13.0) colored highline (>= 1.7.1) security - deliver (1.5.1) - credentials_manager (>= 0.9.0) - fastimage (~> 1.6.3) - fastlane_core (>= 0.19.0, < 1.0.0) + deliver (1.6.4) + credentials_manager (>= 0.12.0, < 1.0.0) + fastimage (~> 1.6) + fastlane_core (>= 0.26.4, < 1.0.0) plist (~> 3.1.0) - spaceship (>= 0.14.0, <= 1.0.0) + spaceship (>= 0.15.0, <= 1.0.0) + domain_name (0.5.25) + unf (>= 0.0.5, < 1.0.0) dotenv (2.0.2) excon (0.45.4) extlib (0.9.16) faraday (0.9.2) multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) faraday_middleware (0.10.0) faraday (>= 0.7.4, < 0.10) fastimage (1.6.8) addressable (~> 2.3, >= 2.3.5) - fastlane (1.41.1) + fastlane (1.48.0) addressable (~> 2.3.8) - cert (>= 1.2.3, < 2.0.0) - credentials_manager (>= 0.10.0, < 1.0.0) - deliver (>= 1.5.1, < 2.0.0) - fastlane_core (>= 0.26.3, < 1.0.0) - frameit (>= 2.3.0, < 3.0.0) - gym (>= 1.1.5, < 2.0.0) + cert (>= 1.2.7, < 2.0.0) + credentials_manager (>= 0.13.0, < 1.0.0) + deliver (>= 1.6.4, < 2.0.0) + fastlane_core (>= 0.29.1, < 1.0.0) + frameit (>= 2.4.1, < 3.0.0) + gym (>= 1.1.6, < 2.0.0) krausefx-shenzhen (>= 0.14.6) - pem (>= 1.0.1, < 2.0.0) - pilot (>= 1.0.1, < 2.0.0) + match (>= 0.1.2, < 1.0.0) + pem (>= 1.1.0, < 2.0.0) + pilot (>= 1.1.0, < 2.0.0) plist (~> 3.1.0) - produce (>= 1.0.0, < 2.0.0) - scan (>= 0.3.0, < 1.0.0) - sigh (>= 1.1.3, < 2.0.0) + produce (>= 1.1.0, < 2.0.0) + scan (>= 0.3.2, < 1.0.0) + sigh (>= 1.2.1, < 2.0.0) slack-notifier (~> 1.3) - snapshot (>= 1.1.1, < 2.0.0) - spaceship (>= 0.14.2, < 1.0.0) - supply (>= 0.2.1, < 1.0.0) + snapshot (>= 1.4.2, < 2.0.0) + spaceship (>= 0.18.0, < 1.0.0) + supply (>= 0.2.2, < 1.0.0) terminal-notifier (~> 1.6.2) terminal-table (~> 1.4.5) xcode-install (~> 1.0.1) xcodeproj (>= 0.20, < 1.0.0) xcpretty (>= 0.2.1) - fastlane_core (0.26.5) + fastlane_core (0.29.1) babosa colored commander (>= 4.3.5) @@ -77,7 +83,7 @@ GEM rubyzip (~> 1.1.6) sentry-raven (~> 0.15) terminal-table (~> 1.4.5) - frameit (2.3.0) + frameit (2.4.1) deliver (> 0.3) fastimage (~> 1.6.3) fastlane_core (>= 0.16.0, < 1.0.0) @@ -93,20 +99,22 @@ GEM multi_json (~> 1.10) retriable (~> 1.4) signet (~> 0.6) - googleauth (0.4.2) + googleauth (0.5.0) faraday (~> 0.9) jwt (~> 1.4) logging (~> 2.0) memoist (~> 0.12) multi_json (~> 1.11) - signet (~> 0.6) - gym (1.1.6) + signet (~> 0.7) + gym (1.2.0) fastlane_core (>= 0.25.0, < 1.0.0) plist rubyzip (>= 1.1.7) terminal-table xcpretty (>= 0.2.1) highline (1.7.8) + http-cookie (1.0.2) + domain_name (~> 0.5) i18n (0.7.0) json (1.8.3) jwt (1.5.2) @@ -128,7 +136,14 @@ GEM logging (2.0.0) little-plugger (~> 1.1) multi_json (~> 1.10) - memoist (0.12.0) + match (0.1.2) + cert (>= 1.2.7, < 2.0.0) + credentials_manager (>= 0.13.0, < 1.0.0) + fastlane_core (>= 0.29.1, < 1.0.0) + security + sigh (>= 1.2.1, < 2.0.0) + spaceship (>= 0.16.0, < 1.0.0) + memoist (0.14.0) method_source (0.8.2) mini_magick (4.0.4) minitest (5.8.3) @@ -138,17 +153,17 @@ GEM net-sftp (2.1.2) net-ssh (>= 2.6.5) net-ssh (3.0.1) - pem (1.0.1) - fastlane_core (>= 0.21.0, < 1.0.0) + pem (1.1.0) + fastlane_core (>= 0.26.4, < 1.0.0) spaceship (>= 0.12.0, < 1.0.0) - pilot (1.0.1) + pilot (1.2.0) credentials_manager (>= 0.3.0) fastlane_core (>= 0.16.1, < 1.0.0) - spaceship (>= 0.14.0, < 1.0.0) + spaceship (>= 0.16.0, < 1.0.0) terminal-table (~> 1.4.5) plist (3.1.0) - produce (1.0.0) - fastlane_core (>= 0.22.3, < 1.0.0) + produce (1.1.0) + fastlane_core (>= 0.26.6, < 1.0.0) spaceship (>= 0.12.0) pry (0.10.3) coderay (~> 1.1.0) @@ -157,8 +172,8 @@ GEM retriable (1.4.1) rouge (1.10.1) rubyzip (1.1.7) - scan (0.3.1) - fastlane_core (>= 0.25.3, < 1.0.0) + scan (0.3.2) + fastlane_core (>= 0.26.6, < 1.0.0) slack-notifier (~> 1.3) terminal-table xcpretty (>= 0.2.1) @@ -166,27 +181,27 @@ GEM security (0.1.3) sentry-raven (0.15.2) faraday (>= 0.7.6) - sigh (1.1.3) - fastlane_core (>= 0.19.0, < 1.0.0) + sigh (1.2.1) + fastlane_core (>= 0.26.4, < 1.0.0) plist (~> 3.1) spaceship (>= 0.12.3) - signet (0.6.1) + signet (0.7.0) addressable (~> 2.3) - extlib (~> 0.9) faraday (~> 0.9) jwt (~> 1.5) multi_json (~> 1.10) - slack-notifier (1.4.0) + slack-notifier (1.5.1) slop (3.6.0) - snapshot (1.1.1) + snapshot (1.4.2) fastimage (~> 1.6.3) fastlane_core (>= 0.21.0, < 1.0.0) plist (~> 3.1.0) xcpretty (>= 0.2.1) - spaceship (0.14.2) + spaceship (0.18.0) colored credentials_manager (>= 0.9.0) faraday (~> 0.9) + faraday-cookie_jar (~> 0.0.6) faraday_middleware (~> 0.9) fastimage (~> 1.6) multi_xml (~> 0.5) @@ -201,6 +216,9 @@ GEM thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.1) xcode-install (1.0.1) claide (~> 0.9.1) spaceship (>= 0.13.0, < 1.0.0) From 85ffb736e4429a179505e9b5046d17ef2b4e82b1 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 12:46:02 +0000 Subject: [PATCH 06/11] [MNY-30]: Modifies coverage script --- .ci/scripts/send-coverage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/send-coverage b/.ci/scripts/send-coverage index 6369aab..0e7a4f1 100755 --- a/.ci/scripts/send-coverage +++ b/.ci/scripts/send-coverage @@ -1,2 +1,2 @@ #!/usr/bin/env bash -bash <(curl -s https://codecov.io/bash) -D .ci/xcodebuild-data \ No newline at end of file +bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -D .ci/xcodebuild-data \ No newline at end of file From 5f26d85a10e83c934103066cbce97f9784c8d7b5 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 13:08:31 +0000 Subject: [PATCH 07/11] [MNY-32]: Adjusts build pipeline --- .ci/buildkite/pipeline.template.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.ci/buildkite/pipeline.template.yml b/.ci/buildkite/pipeline.template.yml index d9d701f..e7d0b9e 100755 --- a/.ci/buildkite/pipeline.template.yml +++ b/.ci/buildkite/pipeline.template.yml @@ -1,9 +1,4 @@ steps: - - - name: ":bundler: Update Bundler" - command: .ci/scripts/update-bundler - agents: - name: "$BUILDKITE_AGENT_META_DATA_NAME" - name: ":fastlane: Test Mac OS X" command: .ci/scripts/test-osx From d2aaea8575e4fc4553c90782cd2ee7669711a3e2 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 14:27:47 +0000 Subject: [PATCH 08/11] [release]: Updates Jazzy config --- .jazzy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jazzy.yaml b/.jazzy.yaml index 3e6f7c7..e471087 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -6,7 +6,7 @@ github_url: https://github.com/danthorpe/Money readme: README.md podspec: Money.podspec -swift_version: 2.1 +swift_version: 2.1.1 xcodebuild-arguments: -scheme,Money-iOS custom_categories: From 75ebf09e921d7a79cd32d073f6ca7770396a50cd Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 14:28:11 +0000 Subject: [PATCH 09/11] [release]: Bumps versions --- Money.podspec | 4 ++-- Supporting Files/Money.xcconfig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Money.podspec b/Money.podspec index e63c28d..08ea2f4 100644 --- a/Money.podspec +++ b/Money.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Money" - s.version = "1.4.1" + s.version = "1.4.2" s.summary = "Swift types for working with Money." s.description = <<-DESC @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.author = { "Daniel Thorpe" => "@danthorpe" } s.source = { :git => "https://github.com/danthorpe/Money.git", :tag => s.version.to_s } s.module_name = 'Money' - s.documentation_url = 'http://docs.danthorpe.me/money/1.4.1/index.html' + s.documentation_url = 'http://docs.danthorpe.me/money/1.4.2/index.html' s.social_media_url = 'https://twitter.com/danthorpe' s.requires_arc = true s.ios.deployment_target = '8.0' diff --git a/Supporting Files/Money.xcconfig b/Supporting Files/Money.xcconfig index adabd06..71d18b0 100644 --- a/Supporting Files/Money.xcconfig +++ b/Supporting Files/Money.xcconfig @@ -6,7 +6,7 @@ // // -MONEY_VERSION = 1.4.1 +MONEY_VERSION = 1.4.2 APPLICATION_EXTENSION_API_ONLY = YES INFOPLIST_FILE = $(SRCROOT)/Supporting Files/Info.plist From 64bdd2a4dbcc88847ed689eeb9ce45138f2e8e6c Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 14:28:20 +0000 Subject: [PATCH 10/11] [release]: Updates CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f76900f..a7d14dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.4.2 +1. [[MNY-39](https://github.com/danthorpe/Money/pull/30)]: Updates to the latest version of [Result](https://github.com/antitypical/Result/releases/tag/1.0.1) dependency. Thanks to [@mrdavey](https://github.com/mrdavey) and [@hsoi](https://github.com/hsoi) for spotting this! + # 1.4.1 1. [[MNY-28](https://github.com/danthorpe/Money/pull/28)]: Documentation is now hosted at [docs.danthorpe.me](http://docs.danthorpe.me/money/1.4.1/). From 446ee2686237adbe67d3d2202f95377516bcd9b0 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Wed, 16 Dec 2015 14:32:50 +0000 Subject: [PATCH 11/11] [release]: Fixes mistake in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a1853f..009eae1 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ public static func quoteFromNetworkResult(result: Result<(NSData?, NSURLResponse return result.analysis( ifSuccess: { data, response in let rate: BankersDecimal = 1.5 // or whatever - return Result(value: FXQuote(rate: BankersDecimal(floatLiteral: rate))) + return Result(value: FXQuote(rate: rate)) }, ifFailure: { error in return Result(error: .NetworkError(error))