@@ -38,16 +38,15 @@ object Decoders {
3838 date <- c.downField(" commit" ).downField(" author" ).downField(" date" ).as[String ]
3939 url <- c.downField(" html_url" ).as[String ]
4040 author <- c.downField(" author" ).as[Option [Author ]]
41- } yield
42- Commit (
43- sha = sha,
44- message = message,
45- date = date,
46- url = url,
47- login = author.flatMap(_.login),
48- avatar_url = author.flatMap(_.avatar_url),
49- author_url = author.flatMap(_.html_url)
50- )
41+ } yield Commit (
42+ sha = sha,
43+ message = message,
44+ date = date,
45+ url = url,
46+ login = author.flatMap(_.login),
47+ avatar_url = author.flatMap(_.avatar_url),
48+ author_url = author.flatMap(_.html_url)
49+ )
5150 }
5251
5352 implicit val decodeBranch : Decoder [Branch ] = Decoder .instance { c =>
@@ -56,30 +55,26 @@ object Decoders {
5655 commit <- c.downField(" commit" ).as[BranchCommit ]
5756 branchProtected <- c.downField(" protected" ).as[Option [Boolean ]]
5857 protection_url <- c.downField(" protection_url" ).as[Option [String ]]
59- } yield
60- Branch (
61- name = name,
62- commit = commit,
63- `protected` = branchProtected,
64- protection_url = protection_url
65- )
58+ } yield Branch (
59+ name = name,
60+ commit = commit,
61+ `protected` = branchProtected,
62+ protection_url = protection_url
63+ )
6664 }
6765
6866 implicit val decodeBranchCommit : Decoder [BranchCommit ] = Decoder .instance { c =>
6967 for {
7068 url <- c.downField(" url" ).as[String ]
7169 sha <- c.downField(" sha" ).as[String ]
72- } yield
73- BranchCommit (
74- url = url,
75- sha = sha
76- )
70+ } yield BranchCommit (
71+ url = url,
72+ sha = sha
73+ )
7774 }
7875
7976 def readRepoUrls (c : HCursor ): Either [DecodingFailure , List [Option [String ]]] =
80- RepoUrlKeys .allFields.traverse { name =>
81- c.downField(name).as[Option [String ]]
82- }
77+ RepoUrlKeys .allFields.traverse(name => c.downField(name).as[Option [String ]])
8378
8479 implicit val decodeStatusRepository : Decoder [StatusRepository ] = {
8580 Decoder .instance { c =>
@@ -92,19 +87,18 @@ object Decoders {
9287 description <- c.downField(" description" ).as[Option [String ]]
9388 fork <- c.downField(" fork" ).as[Boolean ]
9489 repoUrls <- readRepoUrls(c)
95- } yield
96- StatusRepository (
97- id = id,
98- name = name,
99- full_name = full_name,
100- owner = owner,
101- `private` = priv,
102- description = description,
103- fork = fork,
104- urls = (RepoUrlKeys .allFields zip repoUrls.flatten map {
105- case (urlName, value) => urlName -> value
106- }).toMap
107- )
90+ } yield StatusRepository (
91+ id = id,
92+ name = name,
93+ full_name = full_name,
94+ owner = owner,
95+ `private` = priv,
96+ description = description,
97+ fork = fork,
98+ urls = (RepoUrlKeys .allFields zip repoUrls.flatten map {
99+ case (urlName, value) => urlName -> value
100+ }).toMap
101+ )
108102 }
109103 }
110104
@@ -145,46 +139,45 @@ object Decoders {
145139 clone_url <- c.downField(" clone_url" ).as[String ]
146140 svn_url <- c.downField(" svn_url" ).as[String ]
147141 repoUrls <- readRepoUrls(c)
148- } yield
149- Repository (
150- id = id,
151- name = name,
152- full_name = full_name,
153- owner = owner,
154- `private` = priv,
155- description = description,
156- fork = fork,
157- created_at = created_at,
158- updated_at = updated_at,
159- pushed_at = pushed_at,
160- homepage = homepage,
161- language = language,
162- organization = organization,
163- status = RepoStatus (
164- size = size,
165- stargazers_count = stargazers_count,
166- watchers_count = watchers_count,
167- forks_count = forks_count,
168- open_issues_count = open_issues_count,
169- open_issues = open_issues,
170- watchers = watchers,
171- network_count = network_count,
172- subscribers_count = subscribers_count,
173- has_issues = has_issues,
174- has_downloads = has_downloads,
175- has_wiki = has_wiki,
176- has_pages = has_pages
177- ),
178- urls = RepoUrls (
179- url = url,
180- html_url = html_url,
181- git_url = git_url,
182- ssh_url = ssh_url,
183- clone_url = clone_url,
184- svn_url = svn_url,
185- otherUrls = (RepoUrlKeys .allFields zip repoUrls.flatten).toMap
186- )
142+ } yield Repository (
143+ id = id,
144+ name = name,
145+ full_name = full_name,
146+ owner = owner,
147+ `private` = priv,
148+ description = description,
149+ fork = fork,
150+ created_at = created_at,
151+ updated_at = updated_at,
152+ pushed_at = pushed_at,
153+ homepage = homepage,
154+ language = language,
155+ organization = organization,
156+ status = RepoStatus (
157+ size = size,
158+ stargazers_count = stargazers_count,
159+ watchers_count = watchers_count,
160+ forks_count = forks_count,
161+ open_issues_count = open_issues_count,
162+ open_issues = open_issues,
163+ watchers = watchers,
164+ network_count = network_count,
165+ subscribers_count = subscribers_count,
166+ has_issues = has_issues,
167+ has_downloads = has_downloads,
168+ has_wiki = has_wiki,
169+ has_pages = has_pages
170+ ),
171+ urls = RepoUrls (
172+ url = url,
173+ html_url = html_url,
174+ git_url = git_url,
175+ ssh_url = ssh_url,
176+ clone_url = clone_url,
177+ svn_url = svn_url,
178+ otherUrls = (RepoUrlKeys .allFields zip repoUrls.flatten).toMap
187179 )
180+ )
188181 }
189182 }
190183
@@ -200,10 +193,9 @@ object Decoders {
200193 implicit val decodeGistFile : Decoder [GistFile ] = Decoder .instance { c =>
201194 for {
202195 content <- c.downField(" content" ).as[String ]
203- } yield
204- GistFile (
205- content = content
206- )
196+ } yield GistFile (
197+ content = content
198+ )
207199 }
208200
209201 implicit val decodeGist : Decoder [Gist ] = Decoder .instance { c =>
@@ -213,24 +205,26 @@ object Decoders {
213205 description <- c.downField(" description" ).as[String ]
214206 public <- c.downField(" public" ).as[Boolean ]
215207 files <- c.downField(" files" ).as[Map [String , GistFile ]]
216- } yield
217- Gist (
218- url = url,
219- id = id,
220- description = description,
221- public = public,
222- files = files
223- )
208+ } yield Gist (
209+ url = url,
210+ id = id,
211+ description = description,
212+ public = public,
213+ files = files
214+ )
224215 }
225216
226217 implicit val decodeStarredRepository : Decoder [StarredRepository ] =
227218 Decoder [Repository ]
228219 .map(StarredRepository (None , _))
229- .or(Decoder .instance(c =>
230- for {
231- starred_at <- c.downField(" starred_at" ).as[String ]
232- repo <- c.downField(" repo" ).as[Repository ]
233- } yield StarredRepository (Some (starred_at), repo)))
220+ .or(
221+ Decoder .instance(c =>
222+ for {
223+ starred_at <- c.downField(" starred_at" ).as[String ]
224+ repo <- c.downField(" repo" ).as[Repository ]
225+ } yield StarredRepository (Some (starred_at), repo)
226+ )
227+ )
234228
235229 implicit def decodeNonEmptyList [T ](implicit D : Decoder [T ]): Decoder [NonEmptyList [T ]] = {
236230
@@ -273,12 +267,14 @@ object Decoders {
273267 implicit val decodeStargazer : Decoder [Stargazer ] =
274268 decoderUser
275269 .map(Stargazer (None , _))
276- .or(Decoder .instance(c =>
277- for {
278- starred_at <- c.downField(" starred_at" ).as[String ]
279- user <- c.downField(" user" ).as[User ]
280- } yield Stargazer (Some (starred_at), user)))
270+ .or(
271+ Decoder .instance(c =>
272+ for {
273+ starred_at <- c.downField(" starred_at" ).as[String ]
274+ user <- c.downField(" user" ).as[User ]
275+ } yield Stargazer (Some (starred_at), user)
276+ )
277+ )
281278
282279 implicit val decodeTeam : Decoder [Team ] = deriveDecoder[Team ]
283-
284280}
0 commit comments