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

Adds crossover for Scala 2.10 and upgrades libraries #46

Merged
merged 5 commits into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ lazy val buildSettings = Seq(
homepage := Option(url("http://47deg.github.io/github4s/")),
organizationHomepage := Option(new URL("http://47deg.com")),
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.10.6", scalaVersion.value),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please solve this issue by the way?
#40

crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.1") would be great ;) . Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some incompatibilities with the RosHTTP library (see this build). I'm going to send a PR for adding support to Scala 2.12 in RosHTTP but in the meantime, I think we should go forward with this. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

scalacOptions ++= (scalaBinaryVersion.value match {
case "2.10" => Seq("-Xdivergence211")
case _ => Nil
}),
scalafmtConfig in ThisBuild := Some(file(".scalafmt")),
headers := Map(
"scala" -> MIT("2016", "47 Degrees, LLC. <http://www.47deg.com>")
Expand Down Expand Up @@ -49,7 +54,7 @@ lazy val commonDeps = addLibs(vAll,
addCompilerPlugins(vAll, "paradise") ++
Seq(libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % "3.0.0" % "test",
"com.github.marklister" %%% "base64" % "0.2.2"
"com.github.marklister" %%% "base64" % "0.2.3"
))

lazy val jvmDeps = Seq(
Expand Down Expand Up @@ -108,4 +113,4 @@ lazy val scalaz = (project in file("scalaz"))

lazy val testSettings = Seq(
fork in Test := false
)
)
244 changes: 96 additions & 148 deletions github4s/shared/src/main/scala/github4s/Decoders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

package github4s

import cats.syntax.either._
import github4s.free.domain._
import io.circe._, io.circe.generic.auto._, io.circe.syntax._
import io.circe._, io.circe.generic.auto._

/** Implicit circe decoders of domains objects */
object Decoders {
Expand All @@ -41,157 +42,104 @@ object Decoders {
message = message,
date = date,
url = url,
login = author.map(_.login).flatten,
avatar_url = author.map(_.avatar_url).flatten,
author_url = author.map(_.html_url).flatten
login = author.flatMap(_.login),
avatar_url = author.flatMap(_.avatar_url),
author_url = author.flatMap(_.html_url)
)
}

implicit val decodeRepository: Decoder[Repository] = Decoder.instance { c ⇒
for {
id ← c.downField("id").as[Int]
name ← c.downField("name").as[String]
full_name ← c.downField("full_name").as[String]
owner ← c.downField("owner").as[User]
priv ← c.downField("private").as[Boolean]
description ← c.downField("description").as[String]
fork ← c.downField("fork").as[Boolean]
created_at ← c.downField("created_at").as[String]
updated_at ← c.downField("updated_at").as[String]
pushed_at ← c.downField("pushed_at").as[String]
homepage ← c.downField("homepage").as[Option[String]]
language ← c.downField("language").as[Option[String]]
organization ← c.downField("organization").as[Option[User]]
size ← c.downField("size").as[Int]
stargazers_count ← c.downField("stargazers_count").as[Int]
watchers_count ← c.downField("watchers_count").as[Int]
forks_count ← c.downField("forks_count").as[Int]
open_issues_count ← c.downField("open_issues_count").as[Int]
open_issues ← c.downField("open_issues").as[Int]
watchers ← c.downField("watchers").as[Int]
network_count ← c.downField("network_count").as[Int]
subscribers_count ← c.downField("subscribers_count").as[Int]
has_issues ← c.downField("has_issues").as[Boolean]
has_downloads ← c.downField("has_downloads").as[Boolean]
has_wiki ← c.downField("has_wiki").as[Boolean]
has_pages ← c.downField("has_pages").as[Boolean]
url ← c.downField("url").as[String]
html_url ← c.downField("html_url").as[String]
git_url ← c.downField("git_url").as[String]
ssh_url ← c.downField("ssh_url").as[String]
clone_url ← c.downField("clone_url").as[String]
svn_url ← c.downField("svn_url").as[String]
forks_url ← c.downField("forks_url").as[Option[String]]
keys_url ← c.downField("keys_url").as[Option[String]]
collaborators_url ← c.downField("collaborators_url").as[Option[String]]
teams_url ← c.downField("teams_url").as[Option[String]]
hooks_url ← c.downField("hooks_url").as[Option[String]]
issue_events_url ← c.downField("issue_events_url").as[Option[String]]
events_url ← c.downField("events_url").as[Option[String]]
assignees_url ← c.downField("assignees_url").as[Option[String]]
branches_url ← c.downField("branches_url").as[Option[String]]
tags_url ← c.downField("tags_url").as[Option[String]]
blobs_url ← c.downField("blobs_url").as[Option[String]]
git_tags_url ← c.downField("git_tags_url").as[Option[String]]
git_refs_url ← c.downField("git_refs_url").as[Option[String]]
trees_url ← c.downField("trees_url").as[Option[String]]
statuses_url ← c.downField("statuses_url").as[Option[String]]
languages_url ← c.downField("languages_url").as[Option[String]]
stargazers_url ← c.downField("stargazers_url").as[Option[String]]
contributors_url ← c.downField("contributors_url").as[Option[String]]
subscribers_url ← c.downField("subscribers_url").as[Option[String]]
subscription_url ← c.downField("subscription_url").as[Option[String]]
commits_url ← c.downField("commits_url").as[Option[String]]
git_commits_url ← c.downField("git_commits_url").as[Option[String]]
comments_url ← c.downField("comments_url").as[Option[String]]
issue_comment_url ← c.downField("issue_comment_url").as[Option[String]]
contents_url ← c.downField("contents_url").as[Option[String]]
compare_url ← c.downField("compare_url").as[Option[String]]
merges_url ← c.downField("merges_url").as[Option[String]]
archive_url ← c.downField("archive_url").as[Option[String]]
downloads_url ← c.downField("downloads_url").as[Option[String]]
issues_url ← c.downField("issues_url").as[Option[String]]
pulls_url ← c.downField("pulls_url").as[Option[String]]
milestones_url ← c.downField("milestones_url").as[Option[String]]
notifications_url ← c.downField("notifications_url").as[Option[String]]
labels_url ← c.downField("labels_url").as[Option[String]]
releases_url ← c.downField("releases_url").as[Option[String]]
deployments_url ← c.downField("deployments_url").as[Option[String]]
} yield
Repository(
id = id,
name = name,
full_name = full_name,
owner = owner,
`private` = priv,
description = description,
fork = fork,
created_at = created_at,
updated_at = updated_at,
pushed_at = pushed_at,
homepage = homepage,
language = language,
organization = organization,
status = RepoStatus(
size = size,
stargazers_count = stargazers_count,
watchers_count = watchers_count,
forks_count = forks_count,
open_issues_count = open_issues_count,
open_issues = open_issues,
watchers = watchers,
network_count = network_count,
subscribers_count = subscribers_count,
has_issues = has_issues,
has_downloads = has_downloads,
has_wiki = has_wiki,
has_pages = has_pages
),
urls = RepoUrls(
url = url,
html_url = html_url,
git_url = git_url,
ssh_url = ssh_url,
clone_url = clone_url,
svn_url = svn_url,
forks_url = forks_url,
keys_url = keys_url,
collaborators_url = collaborators_url,
teams_url = teams_url,
hooks_url = hooks_url,
issue_events_url = issue_events_url,
events_url = events_url,
assignees_url = assignees_url,
branches_url = branches_url,
tags_url = tags_url,
blobs_url = blobs_url,
git_tags_url = git_tags_url,
git_refs_url = git_refs_url,
trees_url = trees_url,
statuses_url = statuses_url,
languages_url = languages_url,
stargazers_url = stargazers_url,
contributors_url = contributors_url,
subscribers_url = subscribers_url,
subscription_url = subscription_url,
commits_url = commits_url,
git_commits_url = git_commits_url,
comments_url = comments_url,
issue_comment_url = issue_comment_url,
contents_url = contents_url,
compare_url = compare_url,
merges_url = merges_url,
archive_url = archive_url,
downloads_url = downloads_url,
issues_url = issues_url,
pulls_url = pulls_url,
milestones_url = milestones_url,
notifications_url = notifications_url,
labels_url = labels_url,
releases_url = releases_url,
deployments_url = deployments_url
implicit val decodeRepository: Decoder[Repository] = {

def readRepoUrls(c: HCursor): Either[DecodingFailure, List[Option[String]]] = {
RepoUrlKeys.allFields.foldLeft(
Either.right[DecodingFailure, List[Option[String]]](List.empty)) {
case (Left(e), name) => Left(e)
case (Right(list), name) =>
c.downField(name).as[Option[String]] match {
case Left(e) => Left(e)
case Right(maybeUrl) => Right(list :+ maybeUrl)
}
}
}

Decoder.instance { c ⇒
for {
id ← c.downField("id").as[Int]
name ← c.downField("name").as[String]
full_name ← c.downField("full_name").as[String]
owner ← c.downField("owner").as[User]
priv ← c.downField("private").as[Boolean]
description ← c.downField("description").as[String]
fork ← c.downField("fork").as[Boolean]
created_at ← c.downField("created_at").as[String]
updated_at ← c.downField("updated_at").as[String]
pushed_at ← c.downField("pushed_at").as[String]
homepage ← c.downField("homepage").as[Option[String]]
language ← c.downField("language").as[Option[String]]
organization ← c.downField("organization").as[Option[User]]
size ← c.downField("size").as[Int]
stargazers_count ← c.downField("stargazers_count").as[Int]
watchers_count ← c.downField("watchers_count").as[Int]
forks_count ← c.downField("forks_count").as[Int]
open_issues_count ← c.downField("open_issues_count").as[Int]
open_issues ← c.downField("open_issues").as[Int]
watchers ← c.downField("watchers").as[Int]
network_count ← c.downField("network_count").as[Int]
subscribers_count ← c.downField("subscribers_count").as[Int]
has_issues ← c.downField("has_issues").as[Boolean]
has_downloads ← c.downField("has_downloads").as[Boolean]
has_wiki ← c.downField("has_wiki").as[Boolean]
has_pages ← c.downField("has_pages").as[Boolean]
url ← c.downField("url").as[String]
html_url ← c.downField("html_url").as[String]
git_url ← c.downField("git_url").as[String]
ssh_url ← c.downField("ssh_url").as[String]
clone_url ← c.downField("clone_url").as[String]
svn_url ← c.downField("svn_url").as[String]
repoUrls ← readRepoUrls(c)
} yield
Repository(
id = id,
name = name,
full_name = full_name,
owner = owner,
`private` = priv,
description = description,
fork = fork,
created_at = created_at,
updated_at = updated_at,
pushed_at = pushed_at,
homepage = homepage,
language = language,
organization = organization,
status = RepoStatus(
size = size,
stargazers_count = stargazers_count,
watchers_count = watchers_count,
forks_count = forks_count,
open_issues_count = open_issues_count,
open_issues = open_issues,
watchers = watchers,
network_count = network_count,
subscribers_count = subscribers_count,
has_issues = has_issues,
has_downloads = has_downloads,
has_wiki = has_wiki,
has_pages = has_pages
),
urls = RepoUrls(
url = url,
html_url = html_url,
git_url = git_url,
ssh_url = ssh_url,
clone_url = clone_url,
svn_url = svn_url,
otherUrls = (RepoUrlKeys.allFields zip repoUrls.flatten map {
case (urlName, value) => urlName -> value
}).toMap
)
)
)
}
}

implicit val decodeGist: Decoder[Gist] = Decoder.instance { c ⇒
Expand Down
7 changes: 2 additions & 5 deletions github4s/shared/src/main/scala/github4s/Github.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

package github4s

import cats.data.{EitherT, Kleisli, OptionT}
import cats.{MonadError, RecursiveTailRecM, ~>}
import cats.data.{EitherT, Kleisli}
import cats.MonadError
import cats.implicits._
import github4s.GithubResponses._
import github4s.app._
Expand Down Expand Up @@ -52,21 +52,18 @@ object Github {
def execK[M[_], C](
implicit I: Interpreters[M, C],
A: MonadError[M, Throwable],
TR: RecursiveTailRecM[M],
H: HttpRequestBuilderExtension[C, M]): Kleisli[M, Map[String, String], GHResponse[A]] =
gio foldMap I.interpreters

def exec[M[_], C](headers: Map[String, String] = Map())(
implicit I: Interpreters[M, C],
A: MonadError[M, Throwable],
TR: RecursiveTailRecM[M],
H: HttpRequestBuilderExtension[C, M]): M[GHResponse[A]] =
execK.run(headers)

def execFuture[C](headers: Map[String, String] = Map())(
implicit I: Interpreters[Future, C],
A: MonadError[Future, Throwable],
TR: RecursiveTailRecM[Future],
H: HttpRequestBuilderExtension[C, Future]): Future[GHResponse[A]] =
exec[Future, C](headers)

Expand Down
Loading