Skip to content

Commit

Permalink
Merge pull request #74 from alexarchambault/topic/argonaut-6.2
Browse files Browse the repository at this point in the history
Switch to argonaut 6.2
  • Loading branch information
alexarchambault authored Jun 28, 2016
2 parents 6d5a597 + 6d00ba4 commit 3811a78
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 34 deletions.
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ lazy val doc = project

val shapelessVersion = "2.3.1"

lazy val coreName = "argonaut-shapeless_6.1"
lazy val coreName = "argonaut-shapeless_6.2"

lazy val coreSettings = Seq(
organization := "com.github.alexarchambault",
name := coreName,
moduleName := coreName,
libraryDependencies ++= Seq(
"io.argonaut" %% "argonaut" % "6.1a",
"io.argonaut" %% "argonaut" % "6.2-M3",
"com.chuusai" %% "shapeless" % shapelessVersion
)
)

lazy val refinedName = "argonaut-refined_6.1"
lazy val refinedName = "argonaut-refined_6.2"

lazy val refinedSettings = Seq(
organization := "com.github.alexarchambault",
Expand All @@ -65,7 +65,7 @@ lazy val refinedSettings = Seq(
libraryDependencies ++= Seq(
"io.argonaut" %% "argonaut" % "6.1",
"com.chuusai" %% "shapeless" % shapelessVersion,
"eu.timepit" %% "refined" % "0.4.0"
"eu.timepit" %% "refined" % "0.5.0"
)
)

Expand Down
10 changes: 4 additions & 6 deletions core/src/main/scala/argonaut/derive/JsonSumCodec.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package argonaut
package derive

import scalaz.{ -\/, \/- }

trait JsonSumCodec {
def encodeEmpty: Nothing
def encodeField(fieldOrObj: Either[Json, (String, Json)]): Json
Expand Down Expand Up @@ -47,9 +45,9 @@ class JsonSumObjCodec extends JsonSumCodec {
DecodeResult.fail(s"unrecognized type(s): ${cursor.fields.getOrElse(Nil).mkString(", ")}", cursor.history)
def decodeField[A](name: String, cursor: HCursor, decode: DecodeJson[A]): DecodeResult[Either[ACursor, A]] =
cursor.--\(toJsonName(name)).either match {
case -\/(_) =>
case Left(_) =>
DecodeResult.ok(Left(ACursor.ok(cursor)))
case \/-(content) =>
case Right(content) =>
decode.decode(content).map(Right(_))
}
}
Expand Down Expand Up @@ -78,8 +76,8 @@ class JsonSumTypeFieldCodec extends JsonSumCodec {
cursor.history
)
def decodeField[A](name: String, cursor: HCursor, decode: DecodeJson[A]): DecodeResult[Either[ACursor, A]] =
cursor.--\(typeField).as[String].toDisjunction match {
case \/-(name0) if toTypeValue(name) == name0 =>
cursor.--\(typeField).as[String].result match {
case Right(name0) if toTypeValue(name) == name0 =>
decode.decode(cursor).map(Right(_))
case _ =>
DecodeResult.ok(Left(ACursor.ok(cursor)))
Expand Down
16 changes: 8 additions & 8 deletions test/src/test/scala-2.11/argonaut/Refined211DecodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ object Refined211DecodeTests extends TestSuite {

val json = n0.asJson

val n = json.as[Int].toDisjunction.getOrElse(???)
val nT = json.as[Int @@ Positive].toDisjunction.getOrElse(???)
val n = json.as[Int].getOr(???)
val nT = json.as[Int @@ Positive].getOr(???)

assert(n == n0)
assert(nT == nT0)
Expand All @@ -29,8 +29,8 @@ object Refined211DecodeTests extends TestSuite {

val json = s0.asJson

val s = json.as[String].toDisjunction.getOrElse(???)
val sT = json.as[String @@ NonEmpty].toDisjunction.getOrElse(???)
val s = json.as[String].getOr(???)
val sT = json.as[String @@ NonEmpty].getOr(???)

assert(s == s0)
assert(sT == sT0)
Expand All @@ -42,8 +42,8 @@ object Refined211DecodeTests extends TestSuite {

val json = n0.asJson

val n = json.as[Int].toDisjunction.getOrElse(???)
val nT = json.as[Int @@ (Not[Less[_0]] And Not[Greater[_3]])].toDisjunction.getOrElse(???)
val n = json.as[Int].getOr(???)
val nT = json.as[Int @@ (Not[Less[_0]] And Not[Greater[_3]])].getOr(???)

assert(n == n0)
assert(nT == nT0)
Expand All @@ -55,8 +55,8 @@ object Refined211DecodeTests extends TestSuite {

val json = n0.asJson

val n = json.as[List[Int]].toDisjunction.getOrElse(???)
val nT = json.as[List[Int] @@ Size[Greater[_3]]].toDisjunction.getOrElse(???)
val n = json.as[List[Int]].getOr(???)
val nT = json.as[List[Int] @@ Size[Greater[_3]]].getOr(???)

assert(n == n0)
assert(nT == nT0)
Expand Down
2 changes: 1 addition & 1 deletion test/src/test/scala/argonaut/ProductEncodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object ProductEncodeTests extends TestSuite {
Default.AsOptions[WrappedMap],
HListProductEncodeJson.hcons(
Witness('m),
MapLikeEncodeJson[Map, Json](JsonEncodeJson),
MapEncodeJson[String, Json](EncodeJsonKey.StringEncodeJsonKey, JsonEncodeJson),
HListProductEncodeJson.hnil
)
),
Expand Down
16 changes: 8 additions & 8 deletions test/src/test/scala/argonaut/RefinedDecodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ object RefinedDecodeTests extends TestSuite {

val json = n0.asJson

val n = json.as[Int].toDisjunction.getOrElse(???)
val nV = json.as[Refined[Int, Positive]].toDisjunction.getOrElse(???)
val n = json.as[Int].getOr(???)
val nV = json.as[Refined[Int, Positive]].getOr(???)

assert(n == n0)
assert(nV == nV0)
Expand All @@ -29,8 +29,8 @@ object RefinedDecodeTests extends TestSuite {

val json = s0.asJson

val s = json.as[String].toDisjunction.getOrElse(???)
val sV = json.as[Refined[String, NonEmpty]].toDisjunction.getOrElse(???)
val s = json.as[String].getOr(???)
val sV = json.as[Refined[String, NonEmpty]].getOr(???)

assert(s == s0)
assert(sV == sV0)
Expand All @@ -42,8 +42,8 @@ object RefinedDecodeTests extends TestSuite {

val json = n0.asJson

val n = json.as[Int].toDisjunction.getOrElse(???)
val nV = json.as[Refined[Int, Not[Less[_0]] And Not[Greater[_3]]]].toDisjunction.getOrElse(???)
val n = json.as[Int].getOr(???)
val nV = json.as[Refined[Int, Not[Less[_0]] And Not[Greater[_3]]]].getOr(???)

assert(n == n0)
assert(nV == nV0)
Expand All @@ -55,8 +55,8 @@ object RefinedDecodeTests extends TestSuite {

val json = n0.asJson

val n = json.as[List[Int]].toDisjunction.getOrElse(???)
val nV = json.as[Refined[List[Int], Size[Greater[_3]]]].toDisjunction.getOrElse(???)
val n = json.as[List[Int]].getOr(???)
val nV = json.as[Refined[List[Int], Size[Greater[_3]]]].getOr(???)

assert(n == n0)
assert(nV == nV0)
Expand Down
6 changes: 3 additions & 3 deletions test/src/test/scala/argonaut/RefinedFieldDecodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ object RefinedFieldDecodeTests extends TestSuite {

val json = simple0.asJson

val simple = json.as[Simple0].toDisjunction.getOrElse(???)
val simpleV = json.as[SimpleV].toDisjunction.getOrElse(???)
val simple = json.as[Simple0].getOr(???)
val simpleV = json.as[SimpleV].getOr(???)

assert(simple == simple0)
assert(simpleV == simpleV0)
Expand All @@ -30,7 +30,7 @@ object RefinedFieldDecodeTests extends TestSuite {

val json = simple0.asJson

val simple = json.as[Simple0].toDisjunction.getOrElse(???)
val simple = json.as[Simple0].getOr(???)
val resultV = json.as[SimpleV]

assert(simple == simple0)
Expand Down
5 changes: 2 additions & 3 deletions test/src/test/scala/argonaut/ShapelessTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package argonaut

import argonaut.Argonaut.ToJsonIdentity
import scalaz.Scalaz.ToEitherOps

import org.scalacheck.{ Arbitrary, Prop }
import shapeless.test.illTyped
Expand All @@ -15,7 +14,7 @@ object ShapelessTests extends TestSuite {
private def sameAfterBeforeSerialization[T: Arbitrary : EncodeJson : DecodeJson]: Unit =
Prop.forAll {
t: T =>
toFromJson(t).result == t.right
toFromJson(t).result == Right(t)
}.validate

import org.scalacheck.Shapeless._
Expand Down Expand Up @@ -59,7 +58,7 @@ object ShapelessTests extends TestSuite {
val json = Parse.parseOption("{}").get
// assert macro crashes if result is substituted by its value below
val result = json.as[OI].result
assert(result == OI(None).right)
assert(result == Right(OI(None)))
}

'base - {
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "1.1.1-SNAPSHOT"
version in ThisBuild := "1.2.0-SNAPSHOT"

0 comments on commit 3811a78

Please sign in to comment.