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

support scala 2.13 #39

Merged
merged 6 commits into from Jul 7, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions .travis.yml
@@ -1,8 +1,9 @@
language: scala
scala:
- 2.12.0
- 2.11.8
- 2.10.6
- 2.13.0
- 2.12.8
- 2.11.12

jdk:
- oraclejdk8
script: |
Expand All @@ -14,7 +15,7 @@ script: |
after_success: |
if [[ "$TRAVIS_SCALA_VERSION" == 2.11.* ]]; then
sbt ++$TRAVIS_SCALA_VERSION coverageReport coverageAggregate coveralls
fi
fi
cache:
directories:
- $HOME/.ivy2/cache
Expand Down
15 changes: 8 additions & 7 deletions build.sbt
Expand Up @@ -4,29 +4,30 @@ name := "moultingyaml"

organization := "net.jcazevedo"

version := "0.4.1-SNAPSHOT"
version := "0.4.1"

scalaVersion := "2.12.0"
scalaVersion := "2.13.0"

crossScalaVersions := Seq("2.12.0", "2.11.8", "2.10.6")
crossScalaVersions := Seq("2.13.0", "2.12.8", "2.11.12")

libraryDependencies ++= Seq(
"com.github.nscala-time" %% "nscala-time" % "2.14.0",
"com.github.nscala-time" %% "nscala-time" % "2.22.0",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.yaml" % "snakeyaml" % "1.17",
"org.specs2" %% "specs2-core" % "3.8.6" % "test")
"org.yaml" % "snakeyaml" % "1.24",
"org.specs2" %% "specs2-core" % "4.5.1" % "test")

scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
"-feature",
"-language:implicitConversions") ++
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, major)) if major >= 13 => Seq("-Ywarn-unused:imports")
case Some((2, major)) if major >= 11 => Seq("-Ywarn-unused-import")
case _ => Seq()
})

scalacOptions in (Compile, console) ~= (_ filterNot (_ == "-Ywarn-unused-import"))
scalacOptions in (Compile, console) ~= (_ filterNot (_ == "-Ywarn-unused:imports"))
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value

scalariformSettings
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
@@ -1 +1 @@
sbt.version=0.13.13
sbt.version=0.13.18
4 changes: 2 additions & 2 deletions project/plugins.sbt
@@ -1,5 +1,5 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")

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

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.1.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")
Expand Up @@ -13,8 +13,7 @@ trait CollectionFormats {
implicit def listFormat[A: YF] = new YF[List[A]] {
def write(list: List[A]) = YamlArray(list.map(_.toYaml).toVector)
def read(value: YamlValue): List[A] = value match {
case YamlArray(elements) =>
elements.map(_.convertTo[A])(collection.breakOut)
case YamlArray(elements) => elements.map(_.convertTo[A]).toList
case x =>
deserializationError("Expected List as YamlArray, but got " + x)
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/scala/net/jcazevedo/moultingyaml/YamlValue.scala
@@ -1,7 +1,7 @@
package net.jcazevedo.moultingyaml

import com.github.nscala_time.time.Imports._
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._

/**
* The general type of a YAML AST node.
Expand Down Expand Up @@ -31,13 +31,13 @@ case class YamlObject(fields: Map[YamlValue, YamlValue]) extends YamlValue {
override def asYamlObject(errorMsg: String) = this

def getFields(fieldKeys: YamlValue*): Seq[YamlValue] =
fieldKeys.flatMap(fields.get)(collection.breakOut)
fieldKeys.flatMap(fields.get).toSeq

private[moultingyaml] lazy val snakeYamlObject: Object = {
mapAsJavaMap(fields.map {
fields.map {
case (k, v) =>
k.snakeYamlObject -> v.snakeYamlObject
})
}.asJava
}
}

Expand All @@ -50,7 +50,7 @@ object YamlObject {
*/
case class YamlArray(elements: Vector[YamlValue]) extends YamlValue {
private[moultingyaml] lazy val snakeYamlObject: Object = {
seqAsJavaList(elements.map(_.snakeYamlObject))
elements.map(_.snakeYamlObject).asJava
}
}

Expand All @@ -63,7 +63,7 @@ object YamlArray {
*/
case class YamlSet(set: Set[YamlValue]) extends YamlValue {
private[moultingyaml] lazy val snakeYamlObject: Object = {
setAsJavaSet(set.map(_.snakeYamlObject))
set.map(_.snakeYamlObject).asJava
}
}

Expand Down
Expand Up @@ -199,11 +199,11 @@ class BasicFormatsSpec extends Specification with BasicFormats {
"The SymbolYamlFormat" should {

"convert a Symbol to a YamlString" in {
'Hello.toYaml mustEqual YamlString("Hello")
Symbol("Hello").toYaml mustEqual YamlString("Hello")
}

"convert a YamlString to a Symbol" in {
YamlString("Hello").convertTo[Symbol] mustEqual 'Hello
YamlString("Hello").convertTo[Symbol] mustEqual Symbol("Hello")
}
}

Expand Down
Expand Up @@ -197,7 +197,11 @@ class ProductFormatsSpec extends Specification {
|""".stripMargin

"produce the correct YAML" in {
TestMangled(42, "Karl", true, 26, 1.0f).toYaml.prettyPrint === yaml
val result = TestMangled(42, "Karl", true, 26, 1.0f).toYaml.prettyPrint

yaml.split("\n").forall { line =>
result must contain(line)
}
}

"convert a YamlObject to the respective case class instance" in {
Expand Down