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

Add support for scala 2.13.0 #97

Merged
merged 1 commit into from
Jul 20, 2019
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
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ script:
- if [[ -n "$CODACY_PROJECT_TOKEN" && $TRAVIS_SCALA_VERSION == 2.12* ]]; then sbt ++$TRAVIS_SCALA_VERSION clean coverage test coverageReport coverageAggregate codacyCoverage; else sbt ++$TRAVIS_SCALA_VERSION test; fi

scala:
- 2.11.12
- 2.12.8
# - 2.13.0-M5
- 2.13.0

before_install:
- pip install --user codecov
Expand Down
6 changes: 3 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Gnieh Diffson [![Build Status](https://travis-ci.org/gnieh/diffson.png)](https://travis-ci.org/gnieh/diffson) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/9892e2c968974ecb951d21969adbadaa)](https://www.codacy.com/app/satabin/diffson?utm_source=github.com&utm_medium=referral&utm_content=gnieh/diffson&utm_campaign=Badge_Grade) [![Code Coverage](https://codecov.io/github/gnieh/diffson/coverage.svg?branch=master)](https://codecov.io/github/gnieh/diffson?branch=master) [![Maven Central](https://img.shields.io/maven-central/v/org.gnieh/diffson-core_2.11.svg)](https://maven-badges.herokuapp.com/maven-central/org.gnieh/diffson-core_2.11) [![Scaladoc](https://javadoc.io/badge/org.gnieh/diffson-core_2.12.svg)](https://javadoc.io/doc/org.gnieh/diffson-core_2.12)
Gnieh Diffson [![Build Status](https://travis-ci.org/gnieh/diffson.png)](https://travis-ci.org/gnieh/diffson) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/9892e2c968974ecb951d21969adbadaa)](https://www.codacy.com/app/satabin/diffson?utm_source=github.com&utm_medium=referral&utm_content=gnieh/diffson&utm_campaign=Badge_Grade) [![Code Coverage](https://codecov.io/github/gnieh/diffson/coverage.svg?branch=master)](https://codecov.io/github/gnieh/diffson?branch=master) [![Maven Central](https://img.shields.io/maven-central/v/org.gnieh/diffson-core_2.12.svg)](https://maven-badges.herokuapp.com/maven-central/org.gnieh/diffson-core_2.12) [![Scaladoc](https://javadoc.io/badge/org.gnieh/diffson-core_2.12.svg)](https://javadoc.io/doc/org.gnieh/diffson-core_2.12)
=============

[![Join the chat at https://gitter.im/gnieh/diffson](https://badges.gitter.im/gnieh/diffson.svg)](https://gitter.im/gnieh/diffson?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand Down Expand Up @@ -37,9 +37,9 @@ where `jsonLib` is either:
- `play-json`
- `circe`

These versions are built for Scala 2.11 and 2.12.
These versions are built for Scala 2.12 and 2.13.

Scala.JS is also supported for both Scala 2.11 and 2.12. To use it, add this dependency to your build file:
Scala.JS is also supported for both Scala 2.12 and 2.13. To use it, add this dependency to your build file:
```scala
libraryDependencies += "org.gnieh" %%% f"diffson-$jsonLib" % "4.0.0-M3"
```
Expand Down
33 changes: 18 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import scalariform.formatter.preferences._
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

val scala211 = "2.11.12"
val scala212 = "2.12.8"
val scala213 = "2.13.0-M5"
val scala213 = "2.13.0"

lazy val commonSettings = Seq(
organization := "org.gnieh",
scalaVersion := scala212,
scalaVersion := scala213,
version := "4.0.0-M3",
description := "Json diff/patch library",
licenses += ("The Apache Software License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
Expand All @@ -26,10 +25,10 @@ lazy val commonSettings = Seq(
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)
)
case _ =>
// if scala 2.13.0-M4 or later, macro annotations merged into scala-reflect
// if scala 2.13.0 or later, macro annotations merged into scala-reflect
Nil
}),
addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.10" cross CrossVersion.binary),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.10.3" cross CrossVersion.binary),
scalariformAutoformat := true,
scalariformPreferences := {
scalariformPreferences.value
Expand Down Expand Up @@ -63,10 +62,11 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
.settings(commonSettings: _*)
.settings(
name := "diffson-core",
crossScalaVersions := Seq(scala211, scala212/*, scala213*/),
crossScalaVersions := Seq(scala212, scala213),
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "1.6.0",
"io.estatico" %%% "newtype" % "0.4.2",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.1.1",
"org.typelevel" %%% "cats-core" % "2.0.0-M4",
"io.estatico" %%% "newtype" % "0.4.3",
"org.scalatest" %%% "scalatest" % "3.1.0-SNAP13" % Test,
"org.scalacheck" %%% "scalacheck" % "1.14.0" % Test
))
Expand All @@ -78,7 +78,7 @@ lazy val testkit = crossProject(JSPlatform, JVMPlatform)
.settings(commonSettings: _*)
.settings(
name := "diffson-testkit",
crossScalaVersions := Seq(scala211, scala212/*, scala213*/),
crossScalaVersions := Seq(scala212, scala213),
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % "3.1.0-SNAP13",
"org.scalacheck" %%% "scalacheck" % "1.14.0"))
Expand All @@ -90,7 +90,7 @@ lazy val sprayJson = project.in(file("sprayJson"))
.settings(commonSettings: _*)
.settings(
name := "diffson-spray-json",
crossScalaVersions := Seq(scala211, scala212),
crossScalaVersions := Seq(scala212, scala213),
libraryDependencies += "io.spray" %% "spray-json" % "1.3.5")
.dependsOn(core.jvm, testkit.jvm % Test)

Expand All @@ -100,12 +100,12 @@ lazy val playJson = crossProject(JSPlatform, JVMPlatform)
.settings(commonSettings: _*)
.settings(
name := "diffson-play-json",
libraryDependencies += "com.typesafe.play" %%% "play-json" % "2.7.4",
crossScalaVersions := Seq(scala211, scala212))
libraryDependencies += "com.typesafe.play" %%% "play-json" % "2.8.0-M4",
crossScalaVersions := Seq(scala212, scala213))
.jsSettings(coverageEnabled := false)
.dependsOn(core, testkit % Test)

val circeVersion = "0.11.1"
val circeVersion = "0.12.0-M4"
lazy val circe = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Full).in(file("circe"))
.enablePlugins(ScoverageSbtPlugin)
Expand All @@ -117,8 +117,11 @@ lazy val circe = crossProject(JSPlatform, JVMPlatform)
"io.circe" %%% "circe-parser" % circeVersion,
"io.circe" %%% "circe-generic" % circeVersion % Test
),
crossScalaVersions := Seq(scala211, scala212))
.jsSettings(coverageEnabled := false)
crossScalaVersions := Seq(scala212, scala213))
.jsSettings(
coverageEnabled := false,
libraryDependencies += "io.circe" %%% "not-java-time" % "0.2.0"
)
.dependsOn(core, testkit % Test)

lazy val publishSettings = Seq(
Expand Down
4 changes: 2 additions & 2 deletions circe/shared/src/test/scala/diffson/circe/TestProtocol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import scala.language.implicitConversions

trait CirceTestProtocol extends TestProtocol[Json] {
implicit def intSeqMarshaller(is: Seq[Int]) = is.asJson
implicit def intSeqUnmarshaller(json: Json) = json.as[Seq[Int]].right.get
implicit def intSeqUnmarshaller(json: Json) = json.as[Seq[Int]].fold(throw _, identity)
implicit def boolMarshaller(b: Boolean) = Json.fromBoolean(b)
implicit def intMarshaller(i: Int) = Json.fromInt(i)
implicit def stringMarshaller(s: String) = Json.fromString(s)
implicit def jsonEq = Json.eqJson

def parseJson(s: String): Json =
parse(s).right.get
parse(s).fold(throw _, identity)
def parsePatch(s: String): JsonPatch[Json] =
parse(s).flatMap(_.as[JsonPatch[Json]]).toTry.get
def parsePatch(json: Json): JsonPatch[Json] =
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/scala/diffson/jsonpointer/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import io.estatico.newtype.macros.newtype
import scala.util.Try

import scala.language.{ implicitConversions, higherKinds }
import scala.collection.compat._
import scala.collection.compat.immutable.ArraySeq

package object jsonpointer {

Expand Down Expand Up @@ -92,7 +94,7 @@ package object jsonpointer {
// transform the occurrences of '~1' into occurrences of '/'
// transform the occurrences of '~0' into occurrences of '~'
.map(_.replace("~1", "/").replace("~0", "~"))
F.pure(Pointer(elems: _*))
F.pure(Pointer(ArraySeq.unsafeWrapArray(elems): _*))
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/scala/diffson/lcs/Patience.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import cats.implicits._
import scala.annotation.tailrec
import scala.collection.SortedMap
import scala.collection.immutable.TreeMap
import scala.collection.compat._

/** Implementation of the patience algorithm [1] to compute the longest common subsequence
*
Expand Down Expand Up @@ -99,7 +100,7 @@ class Patience[T: Eq](withFallback: Boolean = true) extends Lcs[T] {
val chainCont = {
// we have to find a previous stack
// don't know how efficient `until` is...
stacks.until(idx).lastOption.flatMap(_._2.headOption)
stacks.rangeUntil(idx).lastOption.flatMap(_._2.headOption)
}
(stacks - idx).updated(idx1, Stacked(idx1, idx2, chainCont) :: oldStack)
}
Expand Down Expand Up @@ -163,7 +164,7 @@ class Patience[T: Eq](withFallback: Boolean = true) extends Lcs[T] {
var lastPos1 = low1 - 1
var lastPos2 = low2 - 1
var answer = acc
for ((p1, p2) <- longest(uniqueCommons(seq1.view(low1, high1).toList, seq2.view(low2, high2).toList))) {
for ((p1, p2) <- longest(uniqueCommons(seq1.view.slice(low1, high1).toList, seq2.view.slice(low2, high2).toList))) {
// recurse between lines which are unique in each sequence
val pos1 = p1 + low1
val pos2 = p2 + low2
Expand Down
3 changes: 2 additions & 1 deletion core/src/test/scala/diffson/TestLcs.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package diffson.lcs

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec

abstract class TestLcs extends FlatSpec with Matchers {
abstract class TestLcs extends AnyFlatSpec with Matchers {

val lcsImpl: Lcs[Char]

Expand Down
3 changes: 2 additions & 1 deletion core/src/test/scala/diffson/TestPatienceBigArray.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package diffson.lcs
import cats.implicits._

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec

class TestPatienceBigArray extends FlatSpec with Matchers {
class TestPatienceBigArray extends AnyFlatSpec with Matchers {

val lcsImpl = new Patience[Int].savedHashes

Expand Down
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")

addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2")

addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.15")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28")
3 changes: 2 additions & 1 deletion testkit/shared/src/main/scala/diffson/TestJsonDiff.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import cats._
import cats.implicits._

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec

import scala.util.Try

import scala.language.implicitConversions

abstract class TestJsonDiff[Json](implicit Json: Jsony[Json]) extends FlatSpec with Matchers with TestProtocol[Json] {
abstract class TestJsonDiff[Json](implicit Json: Jsony[Json]) extends AnyFlatSpec with Matchers with TestProtocol[Json] {

implicit val lcsalg = new lcs.Patience[Json]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ package jsonmergepatch
import cats._

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec

import scala.language.implicitConversions

abstract class TestJsonMergeDiff[Json](implicit Json: Jsony[Json]) extends FlatSpec with Matchers with TestProtocol[Json] {
abstract class TestJsonMergeDiff[Json](implicit Json: Jsony[Json]) extends AnyFlatSpec with Matchers with TestProtocol[Json] {

"a diff" should "be empty if created between two equal objects" in {
val json = parseJson("""{"a": true}""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ package jsonmergepatch
import cats.implicits._

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec

import scala.util.Try

abstract class TestJsonMergePatch[Json](implicit Json: Jsony[Json]) extends FlatSpec with Matchers with TestProtocol[Json] {
abstract class TestJsonMergePatch[Json](implicit Json: Jsony[Json]) extends AnyFlatSpec with Matchers with TestProtocol[Json] {

val samples = List(
("""{"a":"b"}""", """{"a":"c"}""", """{"a":"c"}"""),
Expand Down
Loading