├── Cartfile
├── Cartfile.private
├── MatryoshkaPlayground
├── MatryoshkaPlayground.playground
│ ├── timeline.xctimeline
│ ├── contents.xcplayground
│ ├── Sources
│ │ └── SupportCode.swift
│ └── Contents.swift
├── MatryoshkaPlaygroundTests
│ ├── MatryoshkaPlaygroundTests.swift
│ └── Info.plist
├── MatryoshkaPlayground
│ ├── MatryoshkaPlayground.h
│ ├── Networking
│ │ ├── HTTPMethod.swift
│ │ ├── URLOperration.swift
│ │ ├── HTTPResponse.swift
│ │ ├── Operations
│ │ │ ├── GetUser.swift
│ │ │ └── GetTrack.swift
│ │ ├── HTTPRequest.swift
│ │ ├── HTTPOperation.swift
│ │ ├── NetworkManager.swift
│ │ ├── HTTPParameterEncoding.swift
│ │ └── HTTPStatusCode.swift
│ ├── Extensions
│ │ ├── SwiftExtensions.swift
│ │ └── DecodedExtensions.swift
│ ├── Info.plist
│ └── Models
│ │ ├── User.swift
│ │ └── Track.swift
├── MatryoshkaPlayground.xcworkspace
│ └── contents.xcworkspacedata
└── MatryoshkaPlayground.xcodeproj
│ └── project.pbxproj
├── MatryoshkaTests
├── MatryoshkaTests.swift
└── Info.plist
├── Matryoshka
├── Matryoshka.h
├── Info.plist
├── OperationFactory.swift
├── Operation.swift
├── OperationFactoryType.swift
└── OperationType.swift
├── Cartfile.resolved
├── .gitmodules
├── LICENSE
├── README.md
└── Matryoshka.xcodeproj
├── xcshareddata
└── xcschemes
│ ├── Matryoshka-Mac.xcscheme
│ └── Matryoshka-iOS.xcscheme
└── project.pbxproj
/Cartfile:
--------------------------------------------------------------------------------
1 | github "ReactiveCocoa/ReactiveCocoa" "v3.0-beta.7"
2 |
--------------------------------------------------------------------------------
/Cartfile.private:
--------------------------------------------------------------------------------
1 | github "rheinfabrik/Dobby" "develop"
2 |
3 | # MatryoshkaPlayground
4 | github "thoughtbot/Argo" ~> 1.0
5 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground.playground/timeline.xctimeline:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground.playground/contents.xcplayground:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MatryoshkaTests/MatryoshkaTests.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | import Foundation
4 | import XCTest
5 |
6 | class MatryoshkaTests: XCTestCase {
7 | func test() {
8 | XCTAssert(true, "Yeah")
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground.playground/Sources/SupportCode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to MatryoshkaPlayground.playground.
3 | //
4 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlaygroundTests/MatryoshkaPlaygroundTests.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | import XCTest
4 |
5 | class MatryoshkaPlaygroundTests: XCTestCase {
6 | func testExample() {
7 | XCTAssert(true, "Yeah")
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Matryoshka/Matryoshka.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | @import Foundation;
4 |
5 | //! Project version number for Matryoshka.
6 | FOUNDATION_EXPORT double MatryoshkaVersionNumber;
7 |
8 | //! Project version string for Matryoshka.
9 | FOUNDATION_EXPORT const unsigned char MatryoshkaVersionString[];
10 |
--------------------------------------------------------------------------------
/Cartfile.resolved:
--------------------------------------------------------------------------------
1 | github "robrix/Box" "1.2.2"
2 | github "Quick/Nimble" "v0.4.2"
3 | github "thoughtbot/Runes" "v2.0.0"
4 | github "antitypical/Result" "0.4.3"
5 | github "ReactiveCocoa/ReactiveCocoa" "c57928f8ccc455597bb6a5541eabef29bdd99bb3"
6 | github "thoughtbot/Argo" "v1.0.3"
7 | github "rheinfabrik/Dobby" "1f4e98f633cf5c16da179905697cab741835ef2d"
8 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/MatryoshkaPlayground.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | @import Foundation;
4 |
5 | //! Project version number for MatryoshkaPlayground.
6 | FOUNDATION_EXPORT double MatryoshkaPlaygroundVersionNumber;
7 |
8 | //! Project version string for MatryoshkaPlayground.
9 | FOUNDATION_EXPORT const unsigned char MatryoshkaPlaygroundVersionString[];
10 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/Networking/HTTPMethod.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | public enum HTTPMethod: String {
4 | case OPTIONS = "OPTIONS"
5 | case GET = "GET"
6 | case HEAD = "HEAD"
7 | case POST = "POST"
8 | case PUT = "PUT"
9 | case PATCH = "PATCH"
10 | case DELETE = "DELETE"
11 | case TRACE = "TRACE"
12 | case CONNECT = "CONNECT"
13 | }
14 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/Extensions/SwiftExtensions.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | public func == (lhs: [Key: Value]?, rhs: [Key: Value]?) -> Bool {
4 | switch (lhs, rhs) {
5 | case let (.Some(lhs), .Some(rhs)):
6 | return lhs == rhs
7 | case (nil, nil):
8 | return true
9 | default:
10 | return false
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/Networking/URLOperration.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | import Result
4 | import ReactiveCocoa
5 | import Matryoshka
6 |
7 | public struct URLOperation: OperationType {
8 | public var URLRequest: NSURLRequest
9 |
10 | public init(URLRequest: NSURLRequest) {
11 | self.URLRequest = URLRequest
12 | }
13 |
14 | public func execute(execute: NSURLRequest -> SignalProducer<(NSData, NSURLResponse), NSError>) -> SignalProducer<(NSData, NSURLResponse), NSError> {
15 | return execute(URLRequest)
16 | }
17 | }
18 |
19 | public struct URLOperationFactory: OperationFactoryType {
20 | public func create(input: NSURLRequest) -> URLOperation.Operation {
21 | return Operation(URLOperation(URLRequest: input))
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/MatryoshkaTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | is.felixjendrusch.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/Extensions/DecodedExtensions.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | import Result
4 | import ReactiveCocoa
5 | import Argo
6 |
7 | public let DecodedErrorDomain = "DecodedErrorDomain"
8 | public enum DecodedErrorCode: Int {
9 | case TypeMismatch = 1
10 | case MissingKey = 2
11 | }
12 |
13 | extension Decoded {
14 | var result: Result {
15 | switch self {
16 | case let .Success(value):
17 | return .success(value.value)
18 | case .TypeMismatch(_):
19 | return .failure(NSError(domain: DecodedErrorDomain, code: DecodedErrorCode.TypeMismatch.rawValue, userInfo: nil))
20 | case .MissingKey(_):
21 | return .failure(NSError(domain: DecodedErrorDomain, code: DecodedErrorCode.MissingKey.rawValue, userInfo: nil))
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlaygroundTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | is.felixjendrusch.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "Carthage/Checkouts/Box"]
2 | path = Carthage/Checkouts/Box
3 | url = https://github.com/robrix/Box.git
4 | [submodule "Carthage/Checkouts/Nimble"]
5 | path = Carthage/Checkouts/Nimble
6 | url = https://github.com/Quick/Nimble.git
7 | [submodule "Carthage/Checkouts/Result"]
8 | path = Carthage/Checkouts/Result
9 | url = https://github.com/antitypical/Result.git
10 | [submodule "Carthage/Checkouts/Runes"]
11 | path = Carthage/Checkouts/Runes
12 | url = https://github.com/thoughtbot/Runes.git
13 | [submodule "Carthage/Checkouts/ReactiveCocoa"]
14 | path = Carthage/Checkouts/ReactiveCocoa
15 | url = https://github.com/ReactiveCocoa/ReactiveCocoa.git
16 | [submodule "Carthage/Checkouts/Argo"]
17 | path = Carthage/Checkouts/Argo
18 | url = https://github.com/thoughtbot/Argo.git
19 | [submodule "Carthage/Checkouts/Dobby"]
20 | path = Carthage/Checkouts/Dobby
21 | url = https://github.com/rheinfabrik/Dobby.git
22 |
--------------------------------------------------------------------------------
/Matryoshka/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | is.felixjendrusch.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Matryoshka/OperationFactory.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | /// A closure-based operation factory.
4 | public struct OperationFactory: OperationFactoryType {
5 | private let createClosure: Input -> Operation
6 |
7 | /// Creates a closure-based operation factory with the given closure.
8 | public init(_ create: Input -> Operation) {
9 | createClosure = create
10 | }
11 |
12 | public func create(input: Input) -> Operation {
13 | return createClosure(input)
14 | }
15 | }
16 |
17 | extension OperationFactory {
18 | /// Creates a closure-based operation factory that wraps the given operation
19 | /// factory.
20 | public init(_ factory: F) {
21 | self.init({ input in
22 | return factory.create(input)
23 | })
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | is.felixjendrusch.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/Models/User.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | import Runes
4 | import Argo
5 |
6 | public struct User: Equatable {
7 | public var id: Int
8 | public var username: String
9 |
10 | public init(id: Int, username: String) {
11 | self.id = id
12 | self.username = username
13 | }
14 | }
15 |
16 | public func == (lhs: User, rhs: User) -> Bool {
17 | return lhs.id == rhs.id
18 | && lhs.username == rhs.username
19 | }
20 |
21 | extension User: Printable {
22 | public var description: String {
23 | return "User(id: \(id), username: \(username))"
24 | }
25 | }
26 |
27 | extension User: Decodable {
28 | private static func create(id: Int)(username: String) -> User {
29 | return User(id: id, username: username)
30 | }
31 |
32 | public static func decode(json: JSON) -> Decoded {
33 | return create
34 | <^> json <| "id"
35 | <*> json <| "username"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/Networking/HTTPResponse.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | import Foundation
4 |
5 | import Result
6 | import Argo
7 |
8 | public struct HTTPResponse: Equatable {
9 | public var statusCode: HTTPStatusCode
10 | public var data: NSData?
11 |
12 | public var json: Result {
13 | return try { error in
14 | return NSJSONSerialization.JSONObjectWithData(self.data!, options: NSJSONReadingOptions(0), error: error)
15 | }.map(JSON.parse)
16 | }
17 |
18 | public init(statusCode: HTTPStatusCode, data: NSData? = nil) {
19 | self.statusCode = statusCode
20 | self.data = data
21 | }
22 | }
23 |
24 | public func == (lhs: HTTPResponse, rhs: HTTPResponse) -> Bool {
25 | return lhs.statusCode == rhs.statusCode && lhs.data == rhs.data
26 | }
27 |
28 | extension HTTPResponse: Printable {
29 | public var description: String {
30 | return "HTTPResponse(statusCode: \(statusCode), data: \(data))"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
12 |
13 |
15 |
16 |
18 |
19 |
21 |
22 |
24 |
25 |
27 |
28 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Felix Jendrusch
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.
22 |
--------------------------------------------------------------------------------
/MatryoshkaPlayground/MatryoshkaPlayground/Models/Track.swift:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Felix Jendrusch. All rights reserved.
2 |
3 | import Runes
4 | import Argo
5 |
6 | public struct Track: Equatable {
7 | public var id: Int
8 | public var userId: Int
9 | public var title: String
10 |
11 | public init(id: Int, userId: Int, title: String) {
12 | self.id = id
13 | self.userId = userId
14 | self.title = title
15 | }
16 | }
17 |
18 | public func == (lhs: Track, rhs: Track) -> Bool {
19 | return lhs.id == rhs.id
20 | && lhs.userId == rhs.userId
21 | && lhs.title == rhs.title
22 | }
23 |
24 | extension Track: Printable {
25 | public var description: String {
26 | return "Track(id: \(id), userId: \(userId), title: \(title))"
27 | }
28 | }
29 |
30 | extension Track: Decodable {
31 | private static func create(id: Int)(userId: Int)(title: String) -> Track {
32 | return Track(id: id, userId: userId, title: title)
33 | }
34 |
35 | public static func decode(json: JSON) -> Decoded