Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qualify Argo.Decodable for Swift 3.2 #83

Merged
merged 1 commit into from
Jun 6, 2017
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
4 changes: 2 additions & 2 deletions Sources/Tentacle/ArgoExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension JSON {
}
}

internal func decode<T: Decodable>(_ object: Any) -> Result<T, DecodeError> where T == T.DecodedType {
internal func decode<T: Argo.Decodable>(_ object: Any) -> Result<T, DecodeError> where T == T.DecodedType {
let decoded: Decoded<T> = decode(object)
switch decoded {
case let .success(object):
Expand All @@ -47,7 +47,7 @@ internal func decode<T: Decodable>(_ object: Any) -> Result<T, DecodeError> wher
}
}

internal func decode<T: Decodable>(_ object: Any) -> Result<[T], DecodeError> where T == T.DecodedType {
internal func decode<T: Argo.Decodable>(_ object: Any) -> Result<[T], DecodeError> where T == T.DecodedType {
let decoded: Decoded<[T]> = decode(object)
switch decoded {
case let .success(object):
Expand Down
2 changes: 1 addition & 1 deletion Sources/Tentacle/Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func decodeSubmodule(_ j: JSON) -> Decoded<Content.File.ContentType> {
}


extension Content.File.ContentType: Decodable {
extension Content.File.ContentType: Argo.Decodable {
public static func decode(_ json: JSON) -> Decoded<Content.File.ContentType> {
guard case let .object(payload) = json else {
return .failure(.typeMismatch(expected: "object", actual: "\(json)"))
Expand Down
2 changes: 1 addition & 1 deletion Sources/Tentacle/Decodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Argo
import Foundation

extension URL: Decodable {
extension URL: Argo.Decodable {
public static func decode(_ json: JSON) -> Decoded<URL> {
return String.decode(json).flatMap { URLString in
return .fromOptional(self.init(string: URLString))
Expand Down
2 changes: 1 addition & 1 deletion Sources/Tentacle/GitHubError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension GitHubError: Hashable {
}
}

extension GitHubError: Decodable {
extension GitHubError: Argo.Decodable {
public static func decode(_ j: JSON) -> Decoded<GitHubError> {
return curry(self.init) <^> j <| "message"
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Tentacle/ResourceType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
import Argo

/// A Resource from the GitHub API.
public protocol ResourceType: Decodable, Hashable {
public protocol ResourceType: Argo.Decodable, Hashable {
static func decode(_ json: JSON) -> Decoded<Self>
}
4 changes: 2 additions & 2 deletions Sources/Tentacle/Tree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func decodeTree(_ j: JSON) -> Decoded<Tree.Entry.EntryType> {
<^> j <| "url"
}

extension Tree.Entry.EntryType: Decodable {
extension Tree.Entry.EntryType: Argo.Decodable {
public static func decode(_ json: JSON) -> Decoded<Tree.Entry.EntryType> {
guard case let .object(payload) = json else {
return .failure(.typeMismatch(expected: "object", actual: "\(json)"))
Expand All @@ -161,7 +161,7 @@ extension Tree.Entry.EntryType: Decodable {
}
}

extension Tree.Entry.Mode: Decodable {}
extension Tree.Entry.Mode: Argo.Decodable {}

extension Tree.Entry.EntryType: Encodable {
public func encode() -> JSON {
Expand Down
4 changes: 2 additions & 2 deletions Tests/TentacleTests/Fixture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extension EndpointFixtureType {
}

/// Decode the fixture's JSON as an object of the returned type.
func decode<Object: Decodable>() -> Object? where Object.DecodedType == Object {
func decode<Object: Argo.Decodable>() -> Object? where Object.DecodedType == Object {
let decoded: Decoded<Object> = Argo.decode(JSON)
if case let .failure(error) = decoded {
print("Failure: \(error)")
Expand All @@ -118,7 +118,7 @@ extension EndpointFixtureType {
}

/// Decode the fixture's JSON as an array of objects of the returned type.
func decode<Object: Decodable>() -> [Object]? where Object.DecodedType == Object {
func decode<Object: Argo.Decodable>() -> [Object]? where Object.DecodedType == Object {
let decoded: Decoded<[Object]> = Argo.decode(JSON)
if case let .failure(error) = decoded {
print("Failure from collection: \(error)")
Expand Down