Skip to content

Commit

Permalink
Use URL instead of Homepage type
Browse files Browse the repository at this point in the history
  • Loading branch information
dcaunt committed Oct 6, 2017
1 parent 17fac50 commit aa43141
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 38 deletions.
28 changes: 0 additions & 28 deletions Sources/Tentacle/Homepage.swift

This file was deleted.

44 changes: 42 additions & 2 deletions Sources/Tentacle/RepositoryInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public struct RepositoryInfo: CustomStringConvertible, ResourceType, Identifiabl
/// The URL of the repository to load in a browser
public let url: URL

/// The homepage of the repository
public let homepage: Homepage?
/// The URL of the homepage for this repository
public let homepage: URL?

/// Contains true if the repository is private
public let isPrivate: Bool
Expand Down Expand Up @@ -61,6 +61,46 @@ public struct RepositoryInfo: CustomStringConvertible, ResourceType, Identifiabl
return nameWithOwner
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

self.id = try container.decode(ID.self, forKey: .id)
self.owner = try container.decode(UserInfo.self, forKey: .owner)
self.name = try container.decode(String.self, forKey: .name)
self.nameWithOwner = try container.decode(String.self, forKey: .nameWithOwner)
self.body = try? container.decode(String.self, forKey: .body)
self.url = try container.decode(URL.self, forKey: .url)
self.homepage = try? container.decode(URL.self, forKey: .homepage)
self.isPrivate = try container.decode(Bool.self, forKey: .isPrivate)
self.isFork = try container.decode(Bool.self, forKey: .isFork)
self.forksCount = try container.decode(Int.self, forKey: .forksCount)
self.stargazersCount = try container.decode(Int.self, forKey: .stargazersCount)
self.watchersCount = try container.decode(Int.self, forKey: .watchersCount)
self.openIssuesCount = try container.decode(Int.self, forKey: .openIssuesCount)
self.pushedAt = try container.decode(Date.self, forKey: .pushedAt)
self.createdAt = try container.decode(Date.self, forKey: .createdAt)
self.updatedAt = try container.decode(Date.self, forKey: .updatedAt)
}

public init(id: ID<RepositoryInfo>, owner: UserInfo, name: String, nameWithOwner: String, body: String?, url: URL, homepage: URL?, isPrivate: Bool, isFork: Bool, forksCount: Int, stargazersCount: Int, watchersCount: Int, openIssuesCount: Int, pushedAt: Date, createdAt: Date, updatedAt: Date) {
self.id = id
self.owner = owner
self.name = name
self.nameWithOwner = nameWithOwner
self.body = body
self.url = url
self.homepage = homepage
self.isPrivate = isPrivate
self.isFork = isFork
self.forksCount = forksCount
self.stargazersCount = stargazersCount
self.watchersCount = watchersCount
self.openIssuesCount = openIssuesCount
self.pushedAt = pushedAt
self.createdAt = createdAt
self.updatedAt = updatedAt
}

private enum CodingKeys: String, CodingKey {
case id
case owner
Expand Down
6 changes: 0 additions & 6 deletions Tentacle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@
7A3CC6A51E01BC200025E711 /* repos-torvalds-linux-releases-tags-v4.4.data in Resources */ = {isa = PBXBuildFile; fileRef = 7A3CC65A1E01BC200025E711 /* repos-torvalds-linux-releases-tags-v4.4.data */; };
7A3CC6A61E01BC200025E711 /* repos-torvalds-linux-releases-tags-v4.4.response in Resources */ = {isa = PBXBuildFile; fileRef = 7A3CC65B1E01BC200025E711 /* repos-torvalds-linux-releases-tags-v4.4.response */; };
7A3CC6A71E01BC200025E711 /* repos-torvalds-linux-releases-tags-v4.4.response in Resources */ = {isa = PBXBuildFile; fileRef = 7A3CC65B1E01BC200025E711 /* repos-torvalds-linux-releases-tags-v4.4.response */; };
7A571AD31EF93A43008A171B /* Homepage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A571AD21EF93A43008A171B /* Homepage.swift */; };
7A571AD41EF93A43008A171B /* Homepage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A571AD21EF93A43008A171B /* Homepage.swift */; };
7A6F94C11DECF5FA006E9BAD /* Content.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6F94C01DECF5FA006E9BAD /* Content.swift */; };
7A6F94C21DECF93E006E9BAD /* Content.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6F94C01DECF5FA006E9BAD /* Content.swift */; };
7A8A9D621E5546AC0009DA9E /* Branch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8A9D611E5546AC0009DA9E /* Branch.swift */; };
Expand Down Expand Up @@ -272,7 +270,6 @@
7A3CC6591E01BC200025E711 /* repos-mdiep-NonExistent-releases-tags-tag.response */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = "repos-mdiep-NonExistent-releases-tags-tag.response"; sourceTree = "<group>"; };
7A3CC65A1E01BC200025E711 /* repos-torvalds-linux-releases-tags-v4.4.data */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "repos-torvalds-linux-releases-tags-v4.4.data"; sourceTree = "<group>"; };
7A3CC65B1E01BC200025E711 /* repos-torvalds-linux-releases-tags-v4.4.response */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = "repos-torvalds-linux-releases-tags-v4.4.response"; sourceTree = "<group>"; };
7A571AD21EF93A43008A171B /* Homepage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Homepage.swift; sourceTree = "<group>"; };
7A6F94C01DECF5FA006E9BAD /* Content.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Content.swift; sourceTree = "<group>"; };
7A8A9D611E5546AC0009DA9E /* Branch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Branch.swift; sourceTree = "<group>"; };
7A8A9D641E5547F50009DA9E /* BranchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BranchTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -484,7 +481,6 @@
BF01A25C1EAA5BEB0028ECFC /* Tree.swift */,
BECB8A8A1CBDCD17005D70A6 /* User.swift */,
7AC92F681EF72F18002ADBB5 /* Identifiable.swift */,
7A571AD21EF93A43008A171B /* Homepage.swift */,
);
name = Tentacle;
path = Sources/Tentacle;
Expand Down Expand Up @@ -837,7 +833,6 @@
928DF23F1E11187C00E6DE35 /* Sha.swift in Sources */,
BEEE47461C91BB3A000FFC21 /* JSONExtensions.swift in Sources */,
61377C791C8A2B760081FF24 /* Client.swift in Sources */,
7A571AD41EF93A43008A171B /* Homepage.swift in Sources */,
927847FB1E0C75B1003B9EE6 /* Commit.swift in Sources */,
BEEE47431C91B8DF000FFC21 /* ResourceType.swift in Sources */,
7A6F94C21DECF93E006E9BAD /* Content.swift in Sources */,
Expand Down Expand Up @@ -900,7 +895,6 @@
928DF23E1E1117D600E6DE35 /* Sha.swift in Sources */,
BEEE47451C91BB3A000FFC21 /* JSONExtensions.swift in Sources */,
BE88E82D1C88C94D0034A112 /* Server.swift in Sources */,
7A571AD31EF93A43008A171B /* Homepage.swift in Sources */,
927847FA1E0C74B2003B9EE6 /* Commit.swift in Sources */,
BEEE47421C91B8DF000FFC21 /* ResourceType.swift in Sources */,
7A6F94C11DECF5FA006E9BAD /* Content.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions Tests/TentacleTests/RepositoryInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class RepositoryInfoTests: XCTestCase {
nameWithOwner: "RACCommunity/racurated",
body: "Curated list of ReactiveCocoa projects.",
url: URL(string: "https://github.com/RACCommunity/racurated")!,
homepage: "https://raccommunity.github.io/racurated/",
homepage: URL(string: "https://raccommunity.github.io/racurated/"),
isPrivate: false,
isFork: false,
forksCount: 0,
Expand Down Expand Up @@ -152,7 +152,7 @@ class RepositoryInfoTests: XCTestCase {
nameWithOwner: "RACCommunity/jazzy",
body: "Soulful docs for Swift & Objective-C",
url: URL(string: "https://github.com/RACCommunity/jazzy")!,
homepage: "https://realm.io",
homepage: URL(string: "https://realm.io"),
isPrivate: false,
isFork: true,
forksCount: 0,
Expand Down

0 comments on commit aa43141

Please sign in to comment.