Skip to content
This repository was archived by the owner on Sep 19, 2021. It is now read-only.

Commit d6cb02d

Browse files
authored
Merge pull request #41 from eed3si9n/wip/bump
Update to dispatch-json4s-native 1.2.0
2 parents 03e99d8 + 902ba9f commit d6cb02d

12 files changed

+640
-465
lines changed

.scalafmt.conf

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version = 2.3.2
2+
edition = 2019-10
3+
maxColumn = 100
4+
project.git = true
5+
project.excludeFilters = [ "\\Wsbt-test\\W", "\\Winput_sources\\W", "\\Wcontraband-scala\\W" ]
6+
lineEndings = preserve
7+
8+
# https://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style.
9+
# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala
10+
docstrings = JavaDoc
11+
12+
# This also seems more idiomatic to include whitespace in import x.{ yyy }
13+
spaces.inImportCurlyBraces = true
14+
15+
# This is more idiomatic Scala.
16+
# https://docs.scala-lang.org/style/indentation.html#methods-with-numerous-arguments
17+
align.openParenCallSite = false
18+
align.openParenDefnSite = false
19+
20+
# For better code clarity
21+
danglingParentheses = true
22+
23+
trailingCommas = preserve

.travis.yml

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
language: scala
2-
sudo: false
3-
scala:
4-
- 2.12.10
5-
- 2.11.12
6-
- 2.10.7
7-
jdk:
8-
- openjdk8
2+
jdk: openjdk8
3+
4+
script: sbt +test scalafmtCheckAll
5+
6+
before_cache:
7+
- find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete
8+
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
9+
- find $HOME/.sbt -name "*.lock" -delete
10+
- rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true
11+
12+
cache:
13+
directories:
14+
- $HOME/.cache/coursier/v1
15+
- $HOME/.ivy2/cache
16+
- $HOME/.sbt/boot

build.sbt

+18-21
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
lazy val dispatchVersion = SettingKey[String]("dispatchVersion")
2-
lazy val unusedWarnings = Seq("-Ywarn-unused-import", "-Ywarn-unused")
1+
ThisBuild / version := "0.5.3-SNAPSHOT"
2+
ThisBuild / organization := "org.foundweekends"
3+
ThisBuild / homepage := Some(url(s"https://github.com/sbt/${name.value}/#readme"))
4+
ThisBuild / description := "your packages, delivered fresh"
5+
ThisBuild / developers := List(
6+
Developer("softprops", "Doug Tangren", "@softprops", url("https://github.com/softprops"))
7+
)
8+
ThisBuild / scmInfo := Some(ScmInfo(url(s"https://github.com/sbt/${name.value}"), s"[email protected]:sbt/{name.value}.git"))
9+
ThisBuild / crossScalaVersions := Seq("2.12.12", "2.13.3")
10+
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.last
11+
12+
lazy val dispatchVersion = settingKey[String]("")
13+
lazy val unusedWarnings = Seq("-Ywarn-unused")
314

415
lazy val commonSettings: Seq[Setting[_]] = Seq(
5-
version in ThisBuild := "0.5.3-SNAPSHOT",
6-
organization in ThisBuild := "org.foundweekends",
7-
homepage in ThisBuild := Some(url(s"https://github.com/sbt/${name.value}/#readme")),
8-
licenses in ThisBuild := Seq("MIT" ->
16+
licenses := Seq("MIT" ->
917
url(s"https://github.com/sbt/${name.value}/blob/${version.value}/LICENSE")),
10-
description in ThisBuild := "your packages, delivered fresh",
11-
developers in ThisBuild := List(
12-
Developer("softprops", "Doug Tangren", "@softprops", url("https://github.com/softprops"))
13-
),
14-
scmInfo in ThisBuild := Some(ScmInfo(url(s"https://github.com/sbt/${name.value}"), s"[email protected]:sbt/{name.value}.git")),
15-
crossScalaVersions in ThisBuild := Seq("2.10.7", "2.11.12", "2.12.10"),
16-
scalaVersion in ThisBuild := (crossScalaVersions in ThisBuild).value.last,
1718
scalacOptions ++= Seq(Opts.compile.deprecation, "-Xlint", "-feature"),
1819
scalacOptions ++= PartialFunction.condOpt(CrossVersion.partialVersion(scalaVersion.value)){
1920
case Some((2, v)) if v >= 11 => unusedWarnings
@@ -36,15 +37,11 @@ lazy val root = (project in file("."))
3637
.settings(
3738
name := "bintry",
3839
description := "your packages, delivered fresh",
39-
dispatchVersion := {
40-
CrossVersion.partialVersion(scalaVersion.value) match {
41-
case Some((2, 10)) => "0.11.2" // !WARNING! Don't upgrade! See sbt/sbt-bintray#104
42-
case _ => "0.12.0"
43-
}
44-
},
40+
dispatchVersion := "1.2.0",
4541
libraryDependencies ++= Seq(
46-
"net.databinder.dispatch" %% "dispatch-json4s-native" % dispatchVersion.value,
47-
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
42+
"org.dispatchhttp" %% "dispatch-json4s-native" % dispatchVersion.value,
43+
"com.eed3si9n.verify" %% "verify" % "0.2.0" % Test,
4844
),
45+
testFrameworks += new TestFramework("verify.runner.Framework"),
4946
initialCommands := "import scala.concurrent.ExecutionContext.Implicits.global;"
5047
)

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.17
1+
sbt.version=1.4.1

project/plugins.sbt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1")
1+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
2+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.0")

src/main/scala/Attrs.scala

+19-22
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ object AttrsSearchJson {
2020
pair match {
2121
case (name, query) =>
2222
(name -> (query match {
23-
case AttrOneOf(values) => values.toList.map(AttrsToJson(_))
24-
case AttrIs(value) => AttrsToJson.apply(value) :: Nil
23+
case AttrOneOf(values) => values.toList.map(AttrsToJson(_))
24+
case AttrIs(value) => AttrsToJson.apply(value) :: Nil
2525
}))
2626
}
2727

@@ -30,23 +30,23 @@ object AttrsSearchJson {
3030
}
3131

3232
object AttrsToJson {
33-
def apply[A <: Attr[_]](a: A): JValue =
34-
a match {
35-
case Attr.String(value) => JString(value)
36-
case Attr.Number(value) => JInt(value)
37-
case Attr.Boolean(value) => JBool(value)
38-
case Attr.Date(value) => JString(Iso8601(value))
39-
case Attr.Version(value) => JString(value)
40-
}
41-
def apply[A <: Attr[_]](attrs: Iterable[(String, Iterable[A])]): JValue =
42-
attrs.map {
43-
case (name, values) =>
44-
(("name" -> name) ~ {
45-
val tpe = values.headOption.map(_.tpe).getOrElse("string")
46-
("type" -> tpe) ~ ("values" ->
47-
values.map(apply(_)))
48-
})
49-
}
33+
def apply[A <: Attr[_]](a: A): JValue =
34+
a match {
35+
case Attr.String(value) => JString(value)
36+
case Attr.Number(value) => JInt(value)
37+
case Attr.Boolean(value) => JBool(value)
38+
case Attr.Date(value) => JString(Iso8601(value))
39+
case Attr.Version(value) => JString(value)
40+
}
41+
def apply[A <: Attr[_]](attrs: Iterable[(String, Iterable[A])]): JValue =
42+
attrs.map {
43+
case (name, values) =>
44+
(("name" -> name) ~ {
45+
val tpe = values.headOption.map(_.tpe).getOrElse("string")
46+
("type" -> tpe) ~ ("values" ->
47+
values.map(apply(_)))
48+
})
49+
}
5050
}
5151

5252
trait AttrQuery[A <: Attr[_]]
@@ -59,7 +59,6 @@ sealed trait Attr[T] {
5959
def value: T
6060
}
6161

62-
6362
object Attr {
6463
import java.lang.{ String => JString, Boolean => JBoolean }
6564
type AttrMap = Map[JString, Iterable[Attr[_]]]
@@ -69,5 +68,3 @@ object Attr {
6968
case class Boolean(value: JBoolean) extends Attr[JBoolean]
7069
case class Version(value: JString) extends Attr[JString]
7170
}
72-
73-

src/main/scala/Client.scala

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
package bintry
22

3-
import com.ning.http.client.{ AsyncHandler, Response }
3+
import org.asynchttpclient.{ AsyncHandler, Response }
44
import dispatch.{ FunctionHandler, Http, Req }
55
import scala.concurrent.{ ExecutionContext, Future }
66

77
object Client {
88
type Handler[T] = AsyncHandler[T]
99

10-
case class Error(code: Int, message: Message)
11-
extends RuntimeException(message.message)
10+
case class Error(code: Int, message: Message) extends RuntimeException(message.message)
1211

1312
abstract class Completion[T: Rep] {
1413

15-
def apply[TT]
16-
(handler: Client.Handler[TT]): Future[TT]
14+
def apply[TT](handler: Client.Handler[TT]): Future[TT]
1715

1816
def apply(): Future[T] =
1917
apply(implicitly[Rep[T]].map(_))
@@ -22,38 +20,37 @@ object Client {
2220
apply(new FunctionHandler(f) {
2321
override def onCompleted(response: Response) =
2422
if (response.getStatusCode / 100 == 2) f(response)
25-
else throw Error(
26-
response.getStatusCode,
27-
if (response.hasResponseBody) Message(response.getResponseBody)
28-
else Message.empty)
23+
else
24+
throw Error(
25+
response.getStatusCode,
26+
if (response.hasResponseBody) Message(response.getResponseBody)
27+
else Message.empty
28+
)
2929
})
3030
}
3131
}
3232

33-
abstract class Requests(
34-
credentials: Credentials, http: Http)
35-
(implicit ec: ExecutionContext)
36-
extends DefaultHosts
37-
with Methods {
33+
abstract class Requests(credentials: Credentials, http: Http)(implicit ec: ExecutionContext)
34+
extends DefaultHosts
35+
with Methods {
3836

39-
def request[T]
40-
(req: Req)
41-
(handler: Client.Handler[T]): Future[T] =
42-
http(credentials.sign(req) > handler)
37+
def request[T](req: Req)(handler: Client.Handler[T]): Future[T] =
38+
http(credentials.sign(req) > handler)
4339

4440
def complete[A: Rep](req: Req): Client.Completion[A] =
4541
new Client.Completion[A] {
46-
override def apply[T]
47-
(handler: Client.Handler[T]) =
48-
request(req)(handler)
42+
override def apply[T](handler: Client.Handler[T]) =
43+
request(req)(handler)
4944
}
5045
}
5146

5247
case class Client(
53-
user: String, token: String,
54-
private val http: Http = new Http)
55-
(implicit ec: ExecutionContext)
56-
extends Requests(Credentials.BasicAuth(user, token), http) {
48+
user: String,
49+
token: String,
50+
private val http: Http = Http(Http.defaultClientBuilder)
51+
)(implicit ec: ExecutionContext)
52+
extends Requests(Credentials.BasicAuth(user, token), http) {
53+
5754
/** releases http resources. once closed, this client may no longer be used */
5855
def close(): Unit = http.shutdown()
5956
}

src/main/scala/Licenses.scala

+123-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,127 @@
11
package bintry
22

33
object Licenses {
4-
val Names = Set("AFL-3.0","AGPL-V3","APL-1.0","Apache-1.0","Apache-1.1","APSL-2.0","Artistic-License-2.0","Attribution","BSL-1.0","CA-TOSL-1.1","CPAL-1.0","CPOL-1.02","CUAOFFICE-1.0","Day-Addendum","EUDATAGRID","Historical","IBMPL-1.0","IPAFont-1.0","ISC","Lucent-1.02","MirOS","MS-PL","MS-RL","MIT","BSD","GPL-2.0","JTidy","CPL-1.0","JA-SIG","JSON","Motosoto-0.9.1","ECL2","Eiffel-2.0","Entessa-1.0","EUPL-1.1","Fair","Frameworx-1.0","GPL-2.0+CE","Multics","NASA-1.3","NTP","NAUMEN","Nethack","Nokia-1.0a","NOSL-3.0","OCLC-2.0","Openfont-1.1","Opengroup","OSL-3.0","PHP-3.0","PostgreSQL","Public Domain - SUN","PythonPL","PythonSoftFoundation","QTPL-1.0","Real-1.0","RPL-1.5","RicohPL","SimPL-2.0","Sleepycat","SUNPublic-1.0","Sybase-1.0","UoI-NCSA","IU-Extreme-1.1.1","VovidaPL-1.0","wxWindows","Xnet","ZPL-2.0","ZLIB","Codehaus","TMate","WTFPL","MPL-2.0","Public Domain","Bouncy-Castle","Apache-2.0","BSD Simplified","BSD New","LGPL-3.0","GPL-3.0","CDDL-1.0","HSQLDB","Day","Mozilla-1.1","LGPL-2.1","W3C","Unlicense","BSD 2-Clause","NUnit-Test-Adapter-2.6.3","BSD 3-Clause","CDDL-1.1","Facebook-Platform","NUnit-2.6.3","OpenSSL","Scala","CeCILL-C","AFL-2.1","CC0-1.0","Go","CeCILL-2","Libpng","ImageMagick","VIM License","CeCILL-B","Copyfree","CeCILL-2.1","CeCILL-1","CPOL","LPPL-1.0","EPL-1.0","OpenLDAP","EPL-2.0","Unicode-DFS-2015","LGPL-2.0","EUPL-1.2","IJG","NCSA","UPL-1.0","GPL-3.0-only","GPL-3.0-or-later","Mulan PSL v1")
4+
val Names = Set(
5+
"AFL-3.0",
6+
"AGPL-V3",
7+
"APL-1.0",
8+
"Apache-1.0",
9+
"Apache-1.1",
10+
"APSL-2.0",
11+
"Artistic-License-2.0",
12+
"Attribution",
13+
"BSL-1.0",
14+
"CA-TOSL-1.1",
15+
"CPAL-1.0",
16+
"CPOL-1.02",
17+
"CUAOFFICE-1.0",
18+
"Day-Addendum",
19+
"EUDATAGRID",
20+
"Historical",
21+
"IBMPL-1.0",
22+
"IPAFont-1.0",
23+
"ISC",
24+
"Lucent-1.02",
25+
"MirOS",
26+
"MS-PL",
27+
"MS-RL",
28+
"MIT",
29+
"BSD",
30+
"GPL-2.0",
31+
"JTidy",
32+
"CPL-1.0",
33+
"JA-SIG",
34+
"JSON",
35+
"Motosoto-0.9.1",
36+
"ECL2",
37+
"Eiffel-2.0",
38+
"Entessa-1.0",
39+
"EUPL-1.1",
40+
"Fair",
41+
"Frameworx-1.0",
42+
"GPL-2.0+CE",
43+
"Multics",
44+
"NASA-1.3",
45+
"NTP",
46+
"NAUMEN",
47+
"Nethack",
48+
"Nokia-1.0a",
49+
"NOSL-3.0",
50+
"OCLC-2.0",
51+
"Openfont-1.1",
52+
"Opengroup",
53+
"OSL-3.0",
54+
"PHP-3.0",
55+
"PostgreSQL",
56+
"Public Domain - SUN",
57+
"PythonPL",
58+
"PythonSoftFoundation",
59+
"QTPL-1.0",
60+
"Real-1.0",
61+
"RPL-1.5",
62+
"RicohPL",
63+
"SimPL-2.0",
64+
"Sleepycat",
65+
"SUNPublic-1.0",
66+
"Sybase-1.0",
67+
"UoI-NCSA",
68+
"IU-Extreme-1.1.1",
69+
"VovidaPL-1.0",
70+
"wxWindows",
71+
"Xnet",
72+
"ZPL-2.0",
73+
"ZLIB",
74+
"Codehaus",
75+
"TMate",
76+
"WTFPL",
77+
"MPL-2.0",
78+
"Public Domain",
79+
"Bouncy-Castle",
80+
"Apache-2.0",
81+
"BSD Simplified",
82+
"BSD New",
83+
"LGPL-3.0",
84+
"GPL-3.0",
85+
"CDDL-1.0",
86+
"HSQLDB",
87+
"Day",
88+
"Mozilla-1.1",
89+
"LGPL-2.1",
90+
"W3C",
91+
"Unlicense",
92+
"BSD 2-Clause",
93+
"NUnit-Test-Adapter-2.6.3",
94+
"BSD 3-Clause",
95+
"CDDL-1.1",
96+
"Facebook-Platform",
97+
"NUnit-2.6.3",
98+
"OpenSSL",
99+
"Scala",
100+
"CeCILL-C",
101+
"AFL-2.1",
102+
"CC0-1.0",
103+
"Go",
104+
"CeCILL-2",
105+
"Libpng",
106+
"ImageMagick",
107+
"VIM License",
108+
"CeCILL-B",
109+
"Copyfree",
110+
"CeCILL-2.1",
111+
"CeCILL-1",
112+
"CPOL",
113+
"LPPL-1.0",
114+
"EPL-1.0",
115+
"OpenLDAP",
116+
"EPL-2.0",
117+
"Unicode-DFS-2015",
118+
"LGPL-2.0",
119+
"EUPL-1.2",
120+
"IJG",
121+
"NCSA",
122+
"UPL-1.0",
123+
"GPL-3.0-only",
124+
"GPL-3.0-or-later",
125+
"Mulan PSL v1"
126+
)
5127
}

0 commit comments

Comments
 (0)