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

Update to dispatch-json4s-native 1.2.0 #41

Merged
merged 2 commits into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version = 2.3.2
edition = 2019-10
maxColumn = 100
project.git = true
project.excludeFilters = [ "\\Wsbt-test\\W", "\\Winput_sources\\W", "\\Wcontraband-scala\\W" ]
lineEndings = preserve

# https://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style.
# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala
docstrings = JavaDoc

# This also seems more idiomatic to include whitespace in import x.{ yyy }
spaces.inImportCurlyBraces = true

# This is more idiomatic Scala.
# https://docs.scala-lang.org/style/indentation.html#methods-with-numerous-arguments
align.openParenCallSite = false
align.openParenDefnSite = false

# For better code clarity
danglingParentheses = true

trailingCommas = preserve
22 changes: 15 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
language: scala
sudo: false
scala:
- 2.12.10
- 2.11.12
- 2.10.7
jdk:
- openjdk8
jdk: openjdk8

script: sbt +test scalafmtCheckAll

before_cache:
- find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete
- rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true

cache:
directories:
- $HOME/.cache/coursier/v1
- $HOME/.ivy2/cache
- $HOME/.sbt/boot
39 changes: 18 additions & 21 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
lazy val dispatchVersion = SettingKey[String]("dispatchVersion")
lazy val unusedWarnings = Seq("-Ywarn-unused-import", "-Ywarn-unused")
ThisBuild / version := "0.5.3-SNAPSHOT"
ThisBuild / organization := "org.foundweekends"
ThisBuild / homepage := Some(url(s"https://github.com/sbt/${name.value}/#readme"))
ThisBuild / description := "your packages, delivered fresh"
ThisBuild / developers := List(
Developer("softprops", "Doug Tangren", "@softprops", url("https://github.com/softprops"))
)
ThisBuild / scmInfo := Some(ScmInfo(url(s"https://github.com/sbt/${name.value}"), s"git@github.com:sbt/{name.value}.git"))
ThisBuild / crossScalaVersions := Seq("2.12.12", "2.13.3")
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.last

lazy val dispatchVersion = settingKey[String]("")
lazy val unusedWarnings = Seq("-Ywarn-unused")

lazy val commonSettings: Seq[Setting[_]] = Seq(
version in ThisBuild := "0.5.3-SNAPSHOT",
organization in ThisBuild := "org.foundweekends",
homepage in ThisBuild := Some(url(s"https://github.com/sbt/${name.value}/#readme")),
licenses in ThisBuild := Seq("MIT" ->
licenses := Seq("MIT" ->
url(s"https://github.com/sbt/${name.value}/blob/${version.value}/LICENSE")),
description in ThisBuild := "your packages, delivered fresh",
developers in ThisBuild := List(
Developer("softprops", "Doug Tangren", "@softprops", url("https://github.com/softprops"))
),
scmInfo in ThisBuild := Some(ScmInfo(url(s"https://github.com/sbt/${name.value}"), s"git@github.com:sbt/{name.value}.git")),
crossScalaVersions in ThisBuild := Seq("2.10.7", "2.11.12", "2.12.10"),
scalaVersion in ThisBuild := (crossScalaVersions in ThisBuild).value.last,
scalacOptions ++= Seq(Opts.compile.deprecation, "-Xlint", "-feature"),
scalacOptions ++= PartialFunction.condOpt(CrossVersion.partialVersion(scalaVersion.value)){
case Some((2, v)) if v >= 11 => unusedWarnings
Expand All @@ -36,15 +37,11 @@ lazy val root = (project in file("."))
.settings(
name := "bintry",
description := "your packages, delivered fresh",
dispatchVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) => "0.11.2" // !WARNING! Don't upgrade! See sbt/sbt-bintray#104
case _ => "0.12.0"
}
},
dispatchVersion := "1.2.0",
libraryDependencies ++= Seq(
"net.databinder.dispatch" %% "dispatch-json4s-native" % dispatchVersion.value,
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
"org.dispatchhttp" %% "dispatch-json4s-native" % dispatchVersion.value,
"com.eed3si9n.verify" %% "verify" % "0.2.0" % Test,
),
testFrameworks += new TestFramework("verify.runner.Framework"),
initialCommands := "import scala.concurrent.ExecutionContext.Implicits.global;"
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.17
sbt.version=1.4.1
3 changes: 2 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.0")
41 changes: 19 additions & 22 deletions src/main/scala/Attrs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ object AttrsSearchJson {
pair match {
case (name, query) =>
(name -> (query match {
case AttrOneOf(values) => values.toList.map(AttrsToJson(_))
case AttrIs(value) => AttrsToJson.apply(value) :: Nil
case AttrOneOf(values) => values.toList.map(AttrsToJson(_))
case AttrIs(value) => AttrsToJson.apply(value) :: Nil
}))
}

Expand All @@ -30,23 +30,23 @@ object AttrsSearchJson {
}

object AttrsToJson {
def apply[A <: Attr[_]](a: A): JValue =
a match {
case Attr.String(value) => JString(value)
case Attr.Number(value) => JInt(value)
case Attr.Boolean(value) => JBool(value)
case Attr.Date(value) => JString(Iso8601(value))
case Attr.Version(value) => JString(value)
}
def apply[A <: Attr[_]](attrs: Iterable[(String, Iterable[A])]): JValue =
attrs.map {
case (name, values) =>
(("name" -> name) ~ {
val tpe = values.headOption.map(_.tpe).getOrElse("string")
("type" -> tpe) ~ ("values" ->
values.map(apply(_)))
})
}
def apply[A <: Attr[_]](a: A): JValue =
a match {
case Attr.String(value) => JString(value)
case Attr.Number(value) => JInt(value)
case Attr.Boolean(value) => JBool(value)
case Attr.Date(value) => JString(Iso8601(value))
case Attr.Version(value) => JString(value)
}
def apply[A <: Attr[_]](attrs: Iterable[(String, Iterable[A])]): JValue =
attrs.map {
case (name, values) =>
(("name" -> name) ~ {
val tpe = values.headOption.map(_.tpe).getOrElse("string")
("type" -> tpe) ~ ("values" ->
values.map(apply(_)))
})
}
}

trait AttrQuery[A <: Attr[_]]
Expand All @@ -59,7 +59,6 @@ sealed trait Attr[T] {
def value: T
}


object Attr {
import java.lang.{ String => JString, Boolean => JBoolean }
type AttrMap = Map[JString, Iterable[Attr[_]]]
Expand All @@ -69,5 +68,3 @@ object Attr {
case class Boolean(value: JBoolean) extends Attr[JBoolean]
case class Version(value: JString) extends Attr[JString]
}


47 changes: 22 additions & 25 deletions src/main/scala/Client.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package bintry

import com.ning.http.client.{ AsyncHandler, Response }
import org.asynchttpclient.{ AsyncHandler, Response }
import dispatch.{ FunctionHandler, Http, Req }
import scala.concurrent.{ ExecutionContext, Future }

object Client {
type Handler[T] = AsyncHandler[T]

case class Error(code: Int, message: Message)
extends RuntimeException(message.message)
case class Error(code: Int, message: Message) extends RuntimeException(message.message)

abstract class Completion[T: Rep] {

def apply[TT]
(handler: Client.Handler[TT]): Future[TT]
def apply[TT](handler: Client.Handler[TT]): Future[TT]

def apply(): Future[T] =
apply(implicitly[Rep[T]].map(_))
Expand All @@ -22,38 +20,37 @@ object Client {
apply(new FunctionHandler(f) {
override def onCompleted(response: Response) =
if (response.getStatusCode / 100 == 2) f(response)
else throw Error(
response.getStatusCode,
if (response.hasResponseBody) Message(response.getResponseBody)
else Message.empty)
else
throw Error(
response.getStatusCode,
if (response.hasResponseBody) Message(response.getResponseBody)
else Message.empty
)
})
}
}

abstract class Requests(
credentials: Credentials, http: Http)
(implicit ec: ExecutionContext)
extends DefaultHosts
with Methods {
abstract class Requests(credentials: Credentials, http: Http)(implicit ec: ExecutionContext)
extends DefaultHosts
with Methods {

def request[T]
(req: Req)
(handler: Client.Handler[T]): Future[T] =
http(credentials.sign(req) > handler)
def request[T](req: Req)(handler: Client.Handler[T]): Future[T] =
http(credentials.sign(req) > handler)

def complete[A: Rep](req: Req): Client.Completion[A] =
new Client.Completion[A] {
override def apply[T]
(handler: Client.Handler[T]) =
request(req)(handler)
override def apply[T](handler: Client.Handler[T]) =
request(req)(handler)
}
}

case class Client(
user: String, token: String,
private val http: Http = new Http)
(implicit ec: ExecutionContext)
extends Requests(Credentials.BasicAuth(user, token), http) {
user: String,
token: String,
private val http: Http = Http(Http.defaultClientBuilder)
)(implicit ec: ExecutionContext)
extends Requests(Credentials.BasicAuth(user, token), http) {

/** releases http resources. once closed, this client may no longer be used */
def close(): Unit = http.shutdown()
}
124 changes: 123 additions & 1 deletion src/main/scala/Licenses.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,127 @@
package bintry

object Licenses {
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")
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"
)
}
Loading