Skip to content
This repository was archived by the owner on Jun 11, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ DerivedData

Carthage/Build
.fastlane/report.xml
.fastlane/xcodebuild-data
.ci/xcodebuild-data
*.coverage.txt
docs
122 changes: 70 additions & 52 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -137,27 +152,27 @@ 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)
slop (~> 3.4)
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
Expand All @@ -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)
Expand All @@ -201,14 +216,17 @@ 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)
xcodeproj (0.28.2)
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)
Expand All @@ -222,4 +240,4 @@ DEPENDENCIES
xcpretty

BUNDLED WITH
1.10.6
1.11.2
16 changes: 15 additions & 1 deletion Tests/ValueCodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import XCTest
class ValueCodingTests: XCTestCase {

var item: Foo!

var items: [Foo]!
var nested: [[Foo]]!

override func setUp() {
super.setUp()
Expand All @@ -38,6 +38,9 @@ class ValueCodingTests: XCTestCase {
Foo(bar: "हैलो वर्ल्ड"),
Foo(bar: "こんにちは世界"),
]
nested = [
items
]
}

func test__single_archiving() {
Expand All @@ -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))
Expand All @@ -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)
}
Expand Down
30 changes: 29 additions & 1 deletion ValueCoding/ValueCoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ extension CodingType where ValueType: ValueCoding, ValueType.Coder == Self {
internal static func decode<S: SequenceType where S.Generator.Element: AnyObject>(objects: S?) -> [ValueType] {
return objects?.flatMap(decode) ?? []
}

internal static func decode<S: SequenceType where S.Generator.Element: SequenceType, S.Generator.Element.Generator.Element: AnyObject>(objects: S?) -> [[ValueType]] {
return objects?.flatMap(decode) ?? []
}
}

extension SequenceType where
Expand Down Expand Up @@ -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<S: SequenceType where S.Generator.Element: SequenceType, S.Generator.Element.Generator.Element: AnyObject>(objects: S?) -> [[Self]] {
return Coder.decode(objects)
}

/**
Encodes the value type into its Coder.

Expand All @@ -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
Expand All @@ -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 }
}
}