Skip to content

Commit

Permalink
Merge pull request #84 from mdiep/swift-4
Browse files Browse the repository at this point in the history
Migrate to Swift 4's Decodable APIs
  • Loading branch information
mdiep authored Oct 17, 2017
2 parents 3a0ac44 + 11b759b commit 90c5757
Show file tree
Hide file tree
Showing 58 changed files with 781 additions and 1,081 deletions.
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
[submodule "Carthage/Checkouts/Result"]
path = Carthage/Checkouts/Result
url = https://github.com/antitypical/Result.git
[submodule "Carthage/Checkouts/Argo"]
path = Carthage/Checkouts/Argo
url = https://github.com/thoughtbot/Argo.git
[submodule "Carthage/Checkouts/Curry"]
path = Carthage/Checkouts/Curry
url = https://github.com/thoughtbot/Curry.git
[submodule "Carthage/Checkouts/ReactiveSwift"]
path = Carthage/Checkouts/ReactiveSwift
url = https://github.com/ReactiveCocoa/ReactiveSwift.git
[submodule "Carthage/Checkouts/Runes"]
path = Carthage/Checkouts/Runes
url = https://github.com/thoughtbot/Runes.git
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1
4.0
4 changes: 4 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
included:
- Sources
whitelist_rules:
- trailing_closure
30 changes: 5 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.3
osx_image: xcode9
branches:
only:
- master
Expand All @@ -9,33 +9,13 @@ script: script/cibuild "$TRAVIS_XCODE_WORKSPACE" "$TRAVIS_XCODE_SCHEME" "$XCODE_
xcode_workspace: Tentacle.xcworkspace
matrix:
include:
- osx_image: xcode8.3
xcode_scheme: Tentacle-OSX
- xcode_scheme: Tentacle-OSX
env: XCODE_ACTION="build-for-testing test-without-building"
- osx_image: xcode8.3
xcode_scheme: Tentacle-iOS
- xcode_scheme: Tentacle-iOS
env: XCODE_ACTION="build-for-testing test-without-building"
- osx_image: xcode8.3
xcode_scheme: update-test-fixtures
- xcode_scheme: update-test-fixtures
env: XCODE_ACTION=build
- osx_image: xcode8.3
before_script: true
script:
- swift build
- swift test
env:
- JOB=SWIFTPM_DARWIN
- osx_image: xcode9
xcode_scheme: Tentacle-OSX
env: XCODE_ACTION="build-for-testing test-without-building"
- osx_image: xcode9
xcode_scheme: Tentacle-iOS
env: XCODE_ACTION="build-for-testing test-without-building"
- osx_image: xcode9
xcode_scheme: update-test-fixtures
env: XCODE_ACTION=build
- osx_image: xcode9
before_script: true
- before_script: true
script:
- swift build
- swift test
Expand Down
2 changes: 0 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
github "ReactiveCocoa/ReactiveSwift" ~> 2.0
github "thoughtbot/Argo" ~> 4.1.2
github "thoughtbot/Curry" ~> 3.0
5 changes: 1 addition & 4 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
github "ReactiveCocoa/ReactiveSwift" "2.0.0"
github "ReactiveCocoa/ReactiveSwift" "2.0.1"
github "antitypical/Result" "3.2.3"
github "thoughtbot/Argo" "v4.1.2"
github "thoughtbot/Curry" "v3.0.0"
github "thoughtbot/Runes" "v4.0.1"
1 change: 0 additions & 1 deletion Carthage/Checkouts/Argo
Submodule Argo deleted from 203daf
1 change: 0 additions & 1 deletion Carthage/Checkouts/Curry
Submodule Curry deleted from c9f1a3
1 change: 0 additions & 1 deletion Carthage/Checkouts/Runes
Submodule Runes deleted from 727fcf
36 changes: 0 additions & 36 deletions Package.pins

This file was deleted.

25 changes: 25 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"object": {
"pins": [
{
"package": "ReactiveSwift",
"repositoryURL": "https://github.com/ReactiveCocoa/ReactiveSwift.git",
"state": {
"branch": null,
"revision": "b9d5b350a446b85704396ce332a1f9e4960cfc6b",
"version": "2.0.1"
}
},
{
"package": "Result",
"repositoryURL": "https://github.com/antitypical/Result.git",
"state": {
"branch": null,
"revision": "7477584259bfce2560a19e06ad9f71db441fff11",
"version": "3.2.4"
}
}
]
},
"version": 1
}
15 changes: 11 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
// swift-tools-version:4.0
import PackageDescription

let package = Package(
name: "Tentacle",
products: [
.library(name: "Tentacle", targets: ["Tentacle"]),
],
dependencies: [
.Package(url: "https://github.com/thoughtbot/Argo.git", versions: Version(4, 1, 2)..<Version(4, .max, .max)),
.Package(url: "https://github.com/thoughtbot/Curry.git", majorVersion: 3),
.Package(url: "https://github.com/ReactiveCocoa/ReactiveSwift.git", majorVersion: 2),
]
.package(url: "https://github.com/ReactiveCocoa/ReactiveSwift.git", from: "2.0.0"),
],
targets: [
.target(name: "Tentacle", dependencies: ["ReactiveSwift"]),
.testTarget(name: "TentacleTests", dependencies: ["Tentacle"]),
],
swiftLanguageVersions: [4]
)
127 changes: 0 additions & 127 deletions Sources/Tentacle/ArgoExtensions.swift

This file was deleted.

12 changes: 1 addition & 11 deletions Sources/Tentacle/Author.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
//

import Foundation
import Argo

public struct Author {
public struct Author: ResourceType, Encodable {
/// Name of the Author
let name: String
/// Email of the Author
Expand All @@ -21,15 +20,6 @@ public struct Author {
}
}

extension Author: Encodable {
public func encode() -> JSON {
return JSON.object([
"name": .string(name),
"email": .string(email)
])
}
}

extension Author: Hashable, Equatable {
public var hashValue: Int {
return name.hashValue ^ email.hashValue
Expand Down
36 changes: 20 additions & 16 deletions Sources/Tentacle/Branch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
//

import Foundation
import Argo
import Runes
import Curry

extension Repository {
/// A request for the branches in the repository.
Expand All @@ -20,36 +17,43 @@ extension Repository {
}
}

public struct Branch {
public struct Branch: ResourceType {

public struct Commit: Decodable {
public let sha: SHA
}

/// Name of the branch
public let name: String

/// Sha of the commit the branch points to
public let sha: SHA
/// The commit the branch points to
public let commit: Commit

public init(name: String, sha: SHA) {
public init(name: String, commit: Commit) {
self.name = name
self.sha = sha
self.commit = commit
}

}

extension Branch: Hashable {
public static func ==(lhs: Branch, rhs: Branch) -> Bool {
return lhs.name == rhs.name && lhs.sha == rhs.sha
return lhs.name == rhs.name && lhs.commit == rhs.commit
}

public var hashValue: Int {
return name.hashValue ^ sha.hashValue
return name.hashValue ^ commit.hashValue
}
}

extension Branch: ResourceType {
public static func decode(_ j: JSON) -> Decoded<Branch> {
let f = curry(Branch.init)
extension Branch.Commit: Hashable {
public var hashValue: Int {
return sha.hashValue
}
}

return f
<^> j <| "name"
<*> j <| "commit"
extension Branch.Commit: Equatable {
public static func ==(lhs: Branch.Commit, rhs: Branch.Commit) -> Bool {
return lhs.sha == rhs.sha
}
}
Loading

0 comments on commit 90c5757

Please sign in to comment.