Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #275 from guardian/add-scala-2.13-support
Browse files Browse the repository at this point in the history
Add Scala 2.13 support
  • Loading branch information
DanielaSfregola authored Oct 31, 2019
2 parents f26e50b + 34571e8 commit e13b6f6
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ after_success:
- bash <(curl -s https://codecov.io/bash)

scala:
- 2.12.4
- 2.13.0
- 2.12.10
- 2.11.12

# whitelist
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ enablePlugins(GhpagesPlugin, SiteScaladocPlugin)
name := "twitter4s"
version := "6.2-SNAPSHOT"

scalaVersion := "2.12.4"
scalaVersion := "2.13.0"

resolvers ++= Seq(
"Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/",
Resolver.sonatypeRepo("releases"),
Resolver.jcenterRepo
)

Expand Down Expand Up @@ -53,7 +53,7 @@ lazy val standardSettings = Seq(
ScmInfo(url("https://github.com/DanielaSfregola/twitter4s"),
"scm:git:[email protected]:DanielaSfregola/twitter4s.git")),
apiURL := Some(url("http://DanielaSfregola.github.io/twitter4s/latest/api/")),
crossScalaVersions := Seq("2.12.4", "2.11.12"),
crossScalaVersions := Seq(scalaVersion.value, "2.12.10", "2.11.12"),
pomExtra := (
<developers>
<developer>
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
resolvers += "jgit-repo" at "https://download.eclipse.org/jgit/maven"

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait Client extends OAuthClient {
protected def sendAndReceive[T](request: HttpRequest, f: HttpResponse => Future[T])(
implicit system: ActorSystem,
materializer: Materializer): Future[T] = {
implicit val _ = request
implicit val r: HttpRequest = request
val requestStartTime = System.currentTimeMillis

if (withLogRequest) logRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ trait BodyEncoder {

// TODO - improve performance with Macros?
private def asMap(cc: Product): Map[String, Any] =
cc.getClass.getDeclaredFields.map(_.getName).zip(cc.productIterator.to).toMap
cc.getClass.getDeclaredFields.map(_.getName).zip(cc.productIterator.toSeq).toMap

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private[twitter4s] class OAuth1Provider(consumerToken: ConsumerToken, accessToke
val params = basicOAuth2Params(callback)
for {
signature <- oauth1Signature(params)
} yield (params + signature).mapValues(_.urlEncoded)
} yield (params + signature).mapValues(_.urlEncoded).toMap
}

def oauth1Signature(oauth2Params: Map[String, String])(implicit request: HttpRequest, materializer: Materializer) = {
Expand Down Expand Up @@ -67,7 +67,7 @@ private[twitter4s] class OAuth1Provider(consumerToken: ConsumerToken, accessToke
val method = request.method.name.urlEncoded
val baseUrl = request.uri.endpoint.urlEncoded
val oauthParams = oauth2Params.map {
case (k, v) =>
case (k: String, v: String) =>
if (k == "oauth_callback") k -> v.urlEncoded
else k -> v
}
Expand All @@ -90,7 +90,8 @@ private[twitter4s] class OAuth1Provider(consumerToken: ConsumerToken, accessToke
}
}

def queryParams(implicit request: HttpRequest) = request.uri.query().toMap.mapValues(_.urlEncoded)
def queryParams(implicit request: HttpRequest): Map[String, String] =
request.uri.query().toMap.mapValues(_.urlEncoded).toMap

private def encodeParams(params: Map[String, String]) =
params.keySet.toList.sorted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private[twitter4s] object StreamingMessageFormats extends FormatsComposer {
private val tweetUnmarshaller = FieldSerializer[Tweet](deserializer = FieldSerializer.renameFrom("full_text", "text"))

private def withCustomUnmarshaller[T <: StreamingMessage: Manifest](json: JValue, formatter: Formats): Option[T] = {
implicit val _: Formats = formatter
implicit val formats: Formats = formatter
Extraction.extractOpt[T](json)
}

Expand Down

0 comments on commit e13b6f6

Please sign in to comment.