From 668964a5963cac2c0414e24b27031dda23b91b94 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Fri, 1 Jan 2016 16:07:41 +0000 Subject: [PATCH 1/3] [VCD-9]: Adds single level of nesting. E.g. Now supports [[Foo]] types. --- Tests/ValueCodingTests.swift | 16 +++++++++++++++- ValueCoding/ValueCoding.swift | 30 +++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Tests/ValueCodingTests.swift b/Tests/ValueCodingTests.swift index 598b5a3..080ad28 100644 --- a/Tests/ValueCodingTests.swift +++ b/Tests/ValueCodingTests.swift @@ -14,8 +14,8 @@ import XCTest class ValueCodingTests: XCTestCase { var item: Foo! - var items: [Foo]! + var nested: [[Foo]]! override func setUp() { super.setUp() @@ -38,6 +38,9 @@ class ValueCodingTests: XCTestCase { Foo(bar: "हैलो वर्ल्ड"), Foo(bar: "こんにちは世界"), ] + nested = [ + items + ] } func test__single_archiving() { @@ -51,6 +54,12 @@ class ValueCodingTests: XCTestCase { XCTAssertEqual(unarchived, items) } + func test__nested_archiving() { + let unarchived = Foo.decode(nested.encoded) + XCTAssertEqual(unarchived.count, 1) + XCTAssertEqual(unarchived[0], nested[0]) + } + func test__with_single_nil() { let empty: AnyObject? = .None XCTAssertNil(Foo.decode(empty)) @@ -61,6 +70,11 @@ class ValueCodingTests: XCTestCase { XCTAssertTrue(Foo.decode(empty).isEmpty) } + func test__with_nested_nil() { + let empty: [[AnyObject]]? = .None + XCTAssertTrue(Foo.decode(empty).isEmpty) + } + func test__get_values_from_sequence_of_archivers() { XCTAssertEqual(items.encoded.values, items) } diff --git a/ValueCoding/ValueCoding.swift b/ValueCoding/ValueCoding.swift index 623f02c..753d4fa 100644 --- a/ValueCoding/ValueCoding.swift +++ b/ValueCoding/ValueCoding.swift @@ -66,6 +66,10 @@ extension CodingType where ValueType: ValueCoding, ValueType.Coder == Self { internal static func decode(objects: S?) -> [ValueType] { return objects?.flatMap(decode) ?? [] } + + internal static func decode(objects: S?) -> [[ValueType]] { + return objects?.flatMap(decode) ?? [] + } } extension SequenceType where @@ -110,6 +114,16 @@ extension ValueCoding where Coder: NSCoding, Coder.ValueType == Self { return Coder.decode(objects) } + /** + Decodes the values from a sequence of sequence of coders, if possible + + - parameter objects: a `SequenceType` of `SequenceType` of `AnyObject`. + - returns: the array of arrays of values which were able to be unarchived. + */ + public static func decode(objects: S?) -> [[Self]] { + return Coder.decode(objects) + } + /** Encodes the value type into its Coder. @@ -131,7 +145,7 @@ extension SequenceType where Generator.Element.Coder.ValueType == Generator.Element { /** - Encodes the sequence of value types into a sequence of coders. + Encodes the sequence of value types into an array of coders. Typically this would be used inside of `encodeWithCoder:` when a sequence of values is @@ -146,6 +160,20 @@ extension SequenceType where } } +extension SequenceType where + Generator.Element: SequenceType, + Generator.Element.Generator.Element: ValueCoding, + Generator.Element.Generator.Element.Coder: NSCoding, + Generator.Element.Generator.Element.Coder.ValueType == Generator.Element.Generator.Element { + + /** + Encodes a sequence of sequences of value types into + an array of arrays of coders. + */ + public var encoded: [[Generator.Element.Generator.Element.Coder]] { + return map { $0.encoded } + } +} From 24a3bbbab4ef0a47e55ac23a666e590201f1e699 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Fri, 1 Jan 2016 16:10:37 +0000 Subject: [PATCH 2/3] [VCD-9]: Updates gems --- Gemfile.lock | 122 +++++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 52 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cca8e3a..4f975ac 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.6) + credentials_manager (>= 0.12.0, < 1.0.0) + fastimage (~> 1.6) + fastlane_core (>= 0.31.0, < 1.0.0) plist (~> 3.1.0) - spaceship (>= 0.14.0, <= 1.0.0) + spaceship (>= 0.19.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.49.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) - krausefx-shenzhen (>= 0.14.6) - pem (>= 1.0.1, < 2.0.0) - pilot (>= 1.0.1, < 2.0.0) + cert (>= 1.2.7, < 2.0.0) + credentials_manager (>= 0.13.0, < 1.0.0) + deliver (>= 1.6.5, < 2.0.0) + fastlane_core (>= 0.31.0, < 1.0.0) + frameit (>= 2.4.1, < 3.0.0) + gym (>= 1.1.6, < 2.0.0) + krausefx-shenzhen (>= 0.14.7) + match (>= 0.2.2, < 1.0.0) + pem (>= 1.1.1, < 2.0.0) + pilot (>= 1.2.1, < 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.3, < 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.1, < 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.6) + fastlane_core (0.32.0) 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.4.0) + frameit (2.4.1) deliver (> 0.3) fastimage (~> 1.6.3) fastlane_core (>= 0.16.0, < 1.0.0) @@ -93,24 +99,26 @@ 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) - krausefx-shenzhen (0.14.6) + krausefx-shenzhen (0.14.7) commander (~> 4.3) dotenv (>= 0.7) faraday (~> 0.9) @@ -128,7 +136,14 @@ GEM logging (2.0.0) little-plugger (~> 1.1) multi_json (~> 1.10) - memoist (0.13.0) + match (0.2.3) + cert (>= 1.2.7, < 2.0.0) + credentials_manager (>= 0.13.0, < 1.0.0) + fastlane_core (>= 0.31.0, < 1.0.0) + security + sigh (>= 1.2.1, < 2.0.0) + spaceship (>= 0.18.1, < 1.0.0) + memoist (0.14.0) method_source (0.8.2) mini_magick (4.0.4) minitest (5.8.3) @@ -137,19 +152,19 @@ GEM multipart-post (2.0.0) 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) - spaceship (>= 0.12.0, < 1.0.0) - pilot (1.0.1) + net-ssh (3.0.2) + pem (1.1.1) + fastlane_core (>= 0.30.0, < 1.0.0) + spaceship (>= 0.18.1, < 1.0.0) + pilot (1.2.1) credentials_manager (>= 0.3.0) - fastlane_core (>= 0.16.1, < 1.0.0) - spaceship (>= 0.14.0, < 1.0.0) + fastlane_core (>= 0.31.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) - spaceship (>= 0.12.0) + produce (1.1.1) + fastlane_core (>= 0.30.0, < 1.0.0) + spaceship (>= 0.16.0) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -157,7 +172,7 @@ GEM retriable (1.4.1) rouge (1.10.1) rubyzip (1.1.7) - scan (0.3.2) + scan (0.3.3) fastlane_core (>= 0.26.6, < 1.0.0) slack-notifier (~> 1.3) terminal-table @@ -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.2) 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.2.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.19.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) @@ -208,7 +226,7 @@ GEM activesupport (>= 3) claide (~> 0.9.1) colored (~> 1.2) - xcpretty (0.2.1) + xcpretty (0.2.2) rouge (~> 1.8) xcpretty-travis-formatter (0.0.4) xcpretty (~> 0.2, >= 0.0.7) @@ -222,4 +240,4 @@ DEPENDENCIES xcpretty BUNDLED WITH - 1.10.6 + 1.11.2 From 031cf3375c29f8b4e8c4d537a209605365d73e9a Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Fri, 1 Jan 2016 17:43:44 +0000 Subject: [PATCH 3/3] [VCD-9]: Updates gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1d00516..ede0334 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,6 @@ DerivedData Carthage/Build .fastlane/report.xml -.fastlane/xcodebuild-data +.ci/xcodebuild-data *.coverage.txt docs