Skip to content

Commit abc53f6

Browse files
author
Rafa Paradela
committed
Initial approach with tests
1 parent 0d0ddc3 commit abc53f6

19 files changed

Lines changed: 185 additions & 93 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Changelog
2+
=============
3+
4+
## 2016/05/11 - Version 0.1
5+
6+
- First version

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (C) 2012 47 Degrees, LLC http://47deg.com hello@47deg.com
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Github4s
2+
=============
3+
4+
**Github4s** is a GitHub API wrapper written in Scala.
5+
6+
7+
8+
# License
9+
10+
The MIT License (MIT)
11+
12+
Copyright (C) 2012 47 Degrees, LLC http://47deg.com hello@47deg.com
13+
14+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

build.sbt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ libraryDependencies ++= Seq(
1212
"org.scalaj" %% "scalaj-http" % "2.2.1",
1313
"io.circe" %% "circe-core" % "0.3.0",
1414
"io.circe" %% "circe-generic" % "0.3.0",
15-
"io.circe" %% "circe-parser" % "0.3.0"
15+
"io.circe" %% "circe-parser" % "0.3.0",
16+
"org.scalatest" %% "scalatest" % "2.2.6" % "test",
17+
"com.ironcorelabs" %% "cats-scalatest" % "1.1.2" % "test"
1618
)

src/main/scala/com/fortysevendeg/github4s/Github.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import cats.{MonadError, ~>}
55
import com.fortysevendeg.github4s.GithubResponses._
66
import com.fortysevendeg.github4s.app._
77

8-
9-
case class GithubConfig(accessToken : Option[String] = None)
10-
11-
128
class Github(accessToken : Option[String] = None) {
139

1410
lazy val users = new GHUsers(accessToken)

src/main/scala/com/fortysevendeg/github4s/GithubResponses.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ object GithubResponses {
5454

5555
private def toLowerCase(headers: Map[String, IndexedSeq[String]]): Map[String, IndexedSeq[String]] = headers.map(e => (e._1.toLowerCase, e._2))
5656

57+
implicit class GHEntity[A](result: GHResult[A]) {
58+
def entity[A] = result match {
59+
case GHListResult(r, _, _, _) => r
60+
case GHItemResult(r, _, _) => r
61+
}
62+
63+
def statusCode[A] = result match {
64+
case GHListResult(_, sc, _, _) => sc
65+
case GHItemResult(_, sc, _) => sc
66+
}
5767

68+
}
5869

5970
}

src/main/scala/com/fortysevendeg/github4s/api/Repos.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.fortysevendeg.github4s.api
22

33
import com.fortysevendeg.github4s.GithubResponses.GHResponse
44
import com.fortysevendeg.github4s.free.domain.{Pagination, Commit, Repository, User}
5-
import com.fortysevendeg.github4s.{Decoders, GithubConfig, HttpClient}
5+
import com.fortysevendeg.github4s.{Decoders, HttpClient}
66
import io.circe.generic.auto._
77

88
object Repos {

src/main/scala/com/fortysevendeg/github4s/api/Users.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.fortysevendeg.github4s.api
22

33
import com.fortysevendeg.github4s.GithubResponses.GHResponse
4-
import com.fortysevendeg.github4s.{GithubConfig, HttpClient}
4+
import com.fortysevendeg.github4s.HttpClient
55
import com.fortysevendeg.github4s.free.domain.{Pagination, User}
66
import io.circe.generic.auto._
77

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.fortysevendeg.github4s
2+
3+
import cats.data.Coproduct
4+
import com.fortysevendeg.github4s.free.algebra._
5+
6+
object app {
7+
type COGH01[A] = Coproduct[RepositoryOp, UserOp, A]
8+
type COGH02[A] = Coproduct[RequestOp, COGH01, A]
9+
type GitHub4s[A] = Coproduct[AuthOp, COGH02, A]
10+
}

src/main/scala/com/fortysevendeg/github4s/client.sc

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)