Skip to content

Commit

Permalink
Merge 47e8593 into 2d70e59
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydmeta committed Sep 29, 2016
2 parents 2d70e59 + 47e8593 commit 02c9686
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 44 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ scala:
- 2.11.8
script:
- sbt clean +test:compile
- sbt +test
# Manually select the JVM projects to run coverage on until Scoverage is compatible with ScalaJS
- sbt coverage coreJVM/test enumeratum-play/test enumeratum-play-json/test enumeratumCirceJVM/test enumeratumUPickleJVM/test enumeratum-reactivemongo-bson/test coverageReport && sbt coverageAggregate
- sbt coverage +test coverageReport && sbt coverageAggregate
after_success:
- sbt coveralls
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && sbt coreJVM/updateImpactSubmit || true'
Expand All @@ -23,4 +21,4 @@ before_cache:
- du -h -d 1 $HOME/.ivy2/
- du -h -d 2 $HOME/.sbt/
- find $HOME/.sbt -name "*.lock" -type f -delete
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete -print
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete -print
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 by Lloyd Chan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
27 changes: 1 addition & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Integrations are available for:
7. [ReactiveMongo BSON integration](#reactivemongo-bson)
8. [Slick integration](#slick-integration)
9. [Benchmarking](#benchmarking)
10. [Licence](#licence)


## Quick start
Expand Down Expand Up @@ -767,28 +766,4 @@ is acceptable for almost all use-cases. PRs that promise to increase performance

Also, Enumeratum's `withName` is faster than the standard library's `Enumeration`, by around 4x in the case where an entry exists with the given name.
My guess is this is because Enumeratum doesn't use any `synchronized` calls or `volatile` annotations. It is also faster in the case where there is no
corresponding name, but not by a significant amount, perhaps because the high cost of throwing an exception masks any benefits.

## Licence

The MIT License (MIT)

Copyright (c) 2016 by Lloyd Chan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
corresponding name, but not by a significant amount, perhaps because the high cost of throwing an exception masks any benefits.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ lazy val enumeratumCirceJvm = enumeratumCirce.jvm
lazy val commonSettings = Seq(
organization := "com.beachape",
version := theVersion,
incOptions := incOptions.value.withLogRecompileOnMacro(false),
scalaVersion := theScalaVersion
) ++
scalariformSettings ++
Expand Down
23 changes: 15 additions & 8 deletions enumeratum-circe/src/test/scala/enumeratum/CirceSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,27 @@ class CirceSpec extends FunSpec with Matchers {
}

it("should fail to parse random JSON to members") {
Json.fromString("XXL").as[ShirtSize].isLeft shouldBe true
Json.fromInt(Int.MaxValue).as[ShirtSize].isLeft shouldBe true
val failures = Seq(Json.fromString("XXL"), Json.fromInt(Int.MaxValue)).map(j => j.as[ShirtSize](Circe.decoder(ShirtSize)))
failures.foreach { f =>
f.isLeft shouldBe true
f.leftMap(_.history shouldBe Nil)
}
}

it("should fail to parse mixed but not upper case") {
Json.fromString("Small").as[ShirtSize](Circe.decoderUppercaseOnly(ShirtSize)).isLeft shouldBe true
Json.fromString("Medium").as[ShirtSize](Circe.decoderUppercaseOnly(ShirtSize)).isLeft shouldBe true
Json.fromString("Large").as[ShirtSize](Circe.decoderUppercaseOnly(ShirtSize)).isLeft shouldBe true
val failures = Seq("Small", "Medium", "Large").map(s => Json.fromString(s).as[ShirtSize](Circe.decoderUppercaseOnly(ShirtSize)))
failures.foreach { f =>
f.isLeft shouldBe true
f.leftMap(_.history shouldBe Nil)
}
}

it("should fail to parse mixed but not lower case") {
Json.fromString("Small").as[ShirtSize](Circe.decoderLowercaseOnly(ShirtSize)).isLeft shouldBe true
Json.fromString("Medium").as[ShirtSize](Circe.decoderLowercaseOnly(ShirtSize)).isLeft shouldBe true
Json.fromString("Large").as[ShirtSize](Circe.decoderLowercaseOnly(ShirtSize)).isLeft shouldBe true
val failures = Seq("Small", "Medium", "Large").map(s => Json.fromString(s).as[ShirtSize](Circe.decoderLowercaseOnly(ShirtSize)))
failures.foreach { f =>
f.isLeft shouldBe true
f.leftMap(_.history shouldBe Nil)
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ class CirceValueEnumSpec extends FunSpec with Matchers {
}

it("should fail to parse random JSON to members") {
Json.fromString("GOBBLYGOOKITY").as[EntryType].isLeft shouldBe true
Json.fromInt(Int.MaxValue).as[EntryType].isLeft shouldBe true
val failures = Seq(Json.fromString("GOBBLYGOOKITY"), Json.fromInt(Int.MaxValue)).map(_.as[EntryType])
failures.foreach { f =>
f.isLeft shouldBe true
f.leftMap(_.history shouldBe Nil)
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object Forms {
}
}

def unbind(key: String, value: EntryType): Map[String, String] = Map(key -> value.value.toString)
def unbind(key: String, value: EntryType): Map[String, String] = baseFormatter.unbind(key, value.value)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object UrlBinders {
}
}

def unbind(key: String, value: EntryType): String = value.value.toString
def unbind(key: String, value: EntryType): String = baseBindable.unbind(key, value.value)
}

/**
Expand All @@ -38,7 +38,7 @@ object UrlBinders {
})
}

def unbind(key: String, entry: EntryType): String = s"$key=${entry.value}"
def unbind(key: String, entry: EntryType): String = baseBindable.unbind(key, entry.value)
}

}
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resolvers ++= Seq(
// for code formatting
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.5")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.4.0")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.1.0")

Expand Down

0 comments on commit 02c9686

Please sign in to comment.