From 3c0e475c362bc59ded3bb5601d9f3b6a8ea3e841 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 17:38:14 -0700 Subject: [PATCH 01/18] ignore paulp lib dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d32978b..e8fa6a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.lib/ .idea .iml lib_managed From 1edd1b054f6d76f1c4e4a4bf633622d66da1d879 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 17:40:12 -0700 Subject: [PATCH 02/18] make throwable catch explicit to get rid of warning --- src/main/scala/com/codahale/jerkson/AST.scala | 2 +- .../scala/com/codahale/jerkson/deser/EitherDeserializer.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/codahale/jerkson/AST.scala b/src/main/scala/com/codahale/jerkson/AST.scala index c999f7f..f602766 100644 --- a/src/main/scala/com/codahale/jerkson/AST.scala +++ b/src/main/scala/com/codahale/jerkson/AST.scala @@ -32,7 +32,7 @@ object AST { try { elements(index) } catch { - case _ => JNull + case _: Throwable => JNull } } } diff --git a/src/main/scala/com/codahale/jerkson/deser/EitherDeserializer.scala b/src/main/scala/com/codahale/jerkson/deser/EitherDeserializer.scala index 75ab212..d9a2373 100644 --- a/src/main/scala/com/codahale/jerkson/deser/EitherDeserializer.scala +++ b/src/main/scala/com/codahale/jerkson/deser/EitherDeserializer.scala @@ -17,7 +17,7 @@ class EitherDeserializer(config: DeserializationConfig, try { Left(tp.getCodec.readValue[Object](tp, javaType.containedType(0))) } catch { - case _ => Right(tp.getCodec.readValue[Object](tp, javaType.containedType(1))) + case _: Throwable => Right(tp.getCodec.readValue[Object](tp, javaType.containedType(1))) } } } From b2e002056285054ce89b0da95ed526a5a871a8be Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 17:40:29 -0700 Subject: [PATCH 03/18] add paulp script --- sbt | 442 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 442 insertions(+) create mode 100755 sbt diff --git a/sbt b/sbt new file mode 100755 index 0000000..d238b2b --- /dev/null +++ b/sbt @@ -0,0 +1,442 @@ +#!/usr/bin/env bash +# +# A more capable sbt runner, coincidentally also called sbt. +# Author: Paul Phillips + +# todo - make this dynamic +declare -r sbt_release_version=0.12.1 +declare -r sbt_snapshot_version=0.13.0-SNAPSHOT + +unset sbt_jar sbt_dir sbt_create sbt_snapshot sbt_launch_dir +unset scala_version java_home sbt_explicit_version +unset verbose debug quiet + +for arg in "$@"; do + case $arg in + -q|-quiet) quiet=1 ;; + *) ;; + esac +done + +build_props_sbt () { + if [[ -f project/build.properties ]]; then + versionLine=$(grep ^sbt.version project/build.properties) + versionString=${versionLine##sbt.version=} + echo "$versionString" + fi +} + +update_build_props_sbt () { + local ver="$1" + local old=$(build_props_sbt) + + if [[ $ver == $old ]]; then + return + elif [[ -f project/build.properties ]]; then + perl -pi -e "s/^sbt\.version=.*\$/sbt.version=${ver}/" project/build.properties + grep -q '^sbt.version=' project/build.properties || echo "sbt.version=${ver}" >> project/build.properties + + echo !!! + echo !!! Updated file project/build.properties setting sbt.version to: $ver + echo !!! Previous value was: $old + echo !!! + fi +} + +sbt_version () { + if [[ -n $sbt_explicit_version ]]; then + echo $sbt_explicit_version + else + local v=$(build_props_sbt) + if [[ -n $v ]]; then + echo $v + else + echo $sbt_release_version + fi + fi +} + +echoerr () { + [[ -z $quiet ]] && echo 1>&2 "$@" +} +vlog () { + [[ $verbose || $debug ]] && echoerr "$@" +} +dlog () { + [[ $debug ]] && echoerr "$@" +} + +# this seems to cover the bases on OSX, and someone will +# have to tell me about the others. +get_script_path () { + local path="$1" + [[ -L "$path" ]] || { echo "$path" ; return; } + + local target=$(readlink "$path") + if [[ "${target:0:1}" == "/" ]]; then + echo "$target" + else + echo "$(dirname $path)/$target" + fi +} + +# a ham-fisted attempt to move some memory settings in concert +# so they need not be dicked around with individually. +get_mem_opts () { + local mem=${1:-1536} + local perm=$(( $mem / 4 )) + (( $perm > 256 )) || perm=256 + (( $perm < 1024 )) || perm=1024 + local codecache=$(( $perm / 2 )) + + echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" +} + +die() { + echo "Aborting: $@" + exit 1 +} + +make_url () { + groupid="$1" + category="$2" + version="$3" + + echo "http://typesafe.artifactoryonline.com/typesafe/ivy-$category/$groupid/sbt-launch/$version/sbt-launch.jar" +} + +declare -r default_jvm_opts="-Dfile.encoding=UTF8" +declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" +declare -r default_sbt_mem=1536 +declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" +declare -r sbt_opts_file=".sbtopts" +declare -r jvm_opts_file=".jvmopts" +declare -r latest_28="2.8.2" +declare -r latest_29="2.9.2" +declare -r latest_210="2.10.0-SNAPSHOT" + +declare -r script_path=$(get_script_path "$BASH_SOURCE") +declare -r script_dir="$(dirname $script_path)" +declare -r script_name="$(basename $script_path)" + +# some non-read-onlies set with defaults +declare java_cmd=java +declare sbt_launch_dir="$script_dir/.lib" +declare sbt_universal_launcher="$script_dir/lib/sbt-launch.jar" +declare sbt_mem=$default_sbt_mem +declare sbt_jar=$sbt_universal_launcher + +# pull -J and -D options to give to java. +declare -a residual_args +declare -a java_args +declare -a scalac_args +declare -a sbt_commands + +build_props_scala () { + if [[ -f project/build.properties ]]; then + versionLine=$(grep ^build.scala.versions project/build.properties) + versionString=${versionLine##build.scala.versions=} + echo ${versionString%% .*} + fi +} + +execRunner () { + # print the arguments one to a line, quoting any containing spaces + [[ $verbose || $debug ]] && echo "# Executing command line:" && { + for arg; do + if printf "%s\n" "$arg" | grep -q ' '; then + printf "\"%s\"\n" "$arg" + else + printf "%s\n" "$arg" + fi + done + echo "" + } + + exec "$@" +} + +sbt_groupid () { + case $(sbt_version) in + 0.7.*) echo org.scala-tools.sbt ;; + 0.10.*) echo org.scala-tools.sbt ;; + 0.11.[12]) echo org.scala-tools.sbt ;; + *) echo org.scala-sbt ;; + esac +} + +sbt_artifactory_list () { + local version0=$(sbt_version) + local version=${version0%-SNAPSHOT} + local url="http://typesafe.artifactoryonline.com/typesafe/ivy-snapshots/$(sbt_groupid)/sbt-launch/" + dlog "Looking for snapshot list at: $url " + + curl -s --list-only "$url" | \ + grep -F $version | \ + perl -e 'print reverse <>' | \ + perl -pe 's#^/dev/null + dlog "curl returned: $?" + echo "$url" + return + done +} + +jar_url () { + case $(sbt_version) in + 0.7.*) echo "http://simple-build-tool.googlecode.com/files/sbt-launch-0.7.7.jar" ;; + *-SNAPSHOT) make_snapshot_url ;; + *) make_release_url ;; + esac +} + +jar_file () { + echo "$sbt_launch_dir/$1/sbt-launch.jar" +} + +download_url () { + local url="$1" + local jar="$2" + + echo "Downloading sbt launcher $(sbt_version):" + echo " From $url" + echo " To $jar" + + mkdir -p $(dirname "$jar") && { + if which curl >/dev/null; then + curl --fail --silent "$url" --output "$jar" + elif which wget >/dev/null; then + wget --quiet -O "$jar" "$url" + fi + } && [[ -f "$jar" ]] +} + +acquire_sbt_jar () { + sbt_url="$(jar_url)" + sbt_jar="$(jar_file $(sbt_version))" + + [[ -f "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar" +} + +usage () { + cat < path to global settings/plugins directory (default: ~/.sbt/) + -sbt-boot path to shared boot directory (default: ~/.sbt/boot in 0.11+) + -ivy path to local Ivy repository (default: ~/.ivy2) + -mem set memory options (default: $sbt_mem, which is + $(get_mem_opts $sbt_mem) ) + -no-share use all local caches; no sharing + -offline put sbt in offline mode + -jvm-debug Turn on JVM debugging, open at the given port. + -batch Disable interactive mode + + # sbt version (default: from project/build.properties if present, else latest release) + !!! The only way to accomplish this pre-0.12.0 if there is a build.properties file which + !!! contains an sbt.version property is to update the file on disk. That's what this does. + -sbt-version use the specified version of sbt + -sbt-jar use the specified jar as the sbt launcher + -sbt-snapshot use a snapshot version of sbt + -sbt-launch-dir directory to hold sbt launchers (default: $sbt_launch_dir) + + # scala version (default: as chosen by sbt) + -28 use $latest_28 + -29 use $latest_29 + -210 use $latest_210 + -scala-home use the scala build at the specified directory + -scala-version use the specified version of scala + + # java version (default: java from PATH, currently $(java -version |& grep version)) + -java-home alternate JAVA_HOME + + # jvm options and output control + JAVA_OPTS environment variable holding jvm args, if unset uses "$default_jvm_opts" + SBT_OPTS environment variable holding jvm args, if unset uses "$default_sbt_opts" + .jvmopts if file is in sbt root, it is prepended to the args given to the jvm + .sbtopts if file is in sbt root, it is prepended to the args given to **sbt** + -Dkey=val pass -Dkey=val directly to the jvm + -J-X pass option -X directly to the jvm (-J is stripped) + -S-X add -X to sbt's scalacOptions (-J is stripped) + +In the case of duplicated or conflicting options, the order above +shows precedence: JAVA_OPTS lowest, command line options highest. +EOM +} + +addJava () { + dlog "[addJava] arg = '$1'" + java_args=( "${java_args[@]}" "$1" ) +} +addSbt () { + dlog "[addSbt] arg = '$1'" + sbt_commands=( "${sbt_commands[@]}" "$1" ) +} +addScalac () { + dlog "[addScalac] arg = '$1'" + scalac_args=( "${scalac_args[@]}" "$1" ) +} +addResidual () { + dlog "[residual] arg = '$1'" + residual_args=( "${residual_args[@]}" "$1" ) +} +addResolver () { + addSbt "set resolvers in ThisBuild += $1" +} +addDebugger () { + addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" +} +get_jvm_opts () { + # echo "${JAVA_OPTS:-$default_jvm_opts}" + # echo "${SBT_OPTS:-$default_sbt_opts}" + + [[ -f "$jvm_opts_file" ]] && cat "$jvm_opts_file" +} + +process_args () +{ + require_arg () { + local type="$1" + local opt="$2" + local arg="$3" + + if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then + die "$opt requires <$type> argument" + fi + } + while [[ $# -gt 0 ]]; do + case "$1" in + -h|-help) usage; exit 1 ;; + -v|-verbose) verbose=1 && shift ;; + -d|-debug) debug=1 && shift ;; + -q|-quiet) quiet=1 && shift ;; + + -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; + -mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;; + -no-colors) addJava "-Dsbt.log.noformat=true" && shift ;; + -no-share) addJava "$noshare_opts" && shift ;; + -sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;; + -sbt-dir) require_arg path "$1" "$2" && sbt_dir="$2" && shift 2 ;; + -debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;; + -offline) addSbt "set offline := true" && shift ;; + -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;; + -batch) exec 0 )) || echo "Starting $script_name: invoke with -help for other options" + +# verify this is an sbt dir or -create was given +[[ -f ./build.sbt || -d ./project || -n "$sbt_create" ]] || { + cat < Date: Wed, 27 Mar 2013 17:41:07 -0700 Subject: [PATCH 04/18] remove maven --- pom.xml | 195 -------------------------------------------------- pom_2.8.2.xml | 184 ----------------------------------------------- 2 files changed, 379 deletions(-) delete mode 100644 pom.xml delete mode 100644 pom_2.8.2.xml diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 606530d..0000000 --- a/pom.xml +++ /dev/null @@ -1,195 +0,0 @@ - - - 4.0.0 - - com.codahale - jerkson_2.9.1 - 0.5.1-SNAPSHOT - Jerkson for Scala ${scala.version} - - - 2.9.1 - [1.9.0,2.0.0) - - - - - Coda Hale - coda.hale@gmail.com - -8 - - - - - - http://codahale.com/mit.txt - The MIT License - repo - - - - - - scala-tools-releases - http://scala-tools.org/repo-releases/ - - - repo.codahale.com - http://repo.codahale.com - - - nativelibs4java - http://nativelibs4java.sourceforge.net/maven - - - - - - scala-tools-releases - http://scala-tools.org/repo-releases/ - - - - - - repo.codahale.com - scp://codahale.com/home/codahale/repo.codahale.com - - - - - - org.scala-lang - scala-library - ${scala.version} - - - org.codehaus.jackson - jackson-core-asl - ${jackson.version} - - - org.codehaus.jackson - jackson-mapper-asl - ${jackson.version} - - - com.codahale - simplespec_${scala.version} - [0.5.0,0.6.0) - test - - - - - - sign - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.2 - - - sign-artifacts - verify - - sign - - - - - - - - - - - - - org.scala-tools - maven-scala-plugin - 2.15.2 - - - - compile - testCompile - - - - - - -optimise - -unchecked - -deprecation - - - - com.nativelibs4java - scalacl-compiler-plugin - 0.2 - - - UTF-8 - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - UTF-8 - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - UTF-8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.8.1 - - false - -Xmx1024m - - **/*Spec.java - - - **/*Test.java - - - - - - - org.apache.maven.wagon - wagon-ssh - 1.0-beta-7 - - - - diff --git a/pom_2.8.2.xml b/pom_2.8.2.xml deleted file mode 100644 index 598d33b..0000000 --- a/pom_2.8.2.xml +++ /dev/null @@ -1,184 +0,0 @@ - - - 4.0.0 - - com.codahale - jerkson_2.8.2 - 0.5.1-SNAPSHOT - Jerkson for Scala ${scala.version} - - - 2.8.2 - [1.9.0,2.0.0) - - - - - Coda Hale - coda.hale@gmail.com - -8 - - - - - - http://codahale.com/mit.txt - The MIT License - repo - - - - - - scala-tools-releases - http://scala-tools.org/repo-releases/ - - - repo.codahale.com - http://repo.codahale.com - - - - - - scala-tools-releases - http://scala-tools.org/repo-releases/ - - - - - - repo.codahale.com - scp://codahale.com/home/codahale/repo.codahale.com - - - - - - org.scala-lang - scala-library - ${scala.version} - - - org.codehaus.jackson - jackson-core-asl - ${jackson.version} - - - org.codehaus.jackson - jackson-mapper-asl - ${jackson.version} - - - com.codahale - simplespec_2.8.1 - [0.5.0,0.6.0) - test - - - - - - sign - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.2 - - - sign-artifacts - verify - - sign - - - - - - - - - - - - - org.scala-tools - maven-scala-plugin - 2.15.2 - - - - compile - testCompile - - - - - - -optimise - -unchecked - -deprecation - - UTF-8 - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - UTF-8 - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - UTF-8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.8.1 - - false - -Xmx1024m - - **/*Spec.java - - - **/*Test.java - - - - - - - org.apache.maven.wagon - wagon-ssh - 1.0-beta-7 - - - - From 76a2c12ac776edb2c3aa21dcd37b455c9004ee13 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 17:47:57 -0700 Subject: [PATCH 05/18] eliminate deprecation warnings --- src/main/scala/com/codahale/jerkson/Generator.scala | 2 +- src/main/scala/com/codahale/jerkson/Parser.scala | 2 +- src/main/scala/com/codahale/jerkson/Types.scala | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/codahale/jerkson/Generator.scala b/src/main/scala/com/codahale/jerkson/Generator.scala index 2cc4623..7c53d94 100644 --- a/src/main/scala/com/codahale/jerkson/Generator.scala +++ b/src/main/scala/com/codahale/jerkson/Generator.scala @@ -37,7 +37,7 @@ trait Generator extends Factory { /** * Returns true if the given class is serializable. */ - def canSerialize[A](implicit mf: Manifest[A]) = mapper.canSerialize(mf.erasure) + def canSerialize[A](implicit mf: Manifest[A]) = mapper.canSerialize(mf.runtimeClass) private def generate[A](obj: A, generator: JsonGenerator) { generator.writeObject(obj) diff --git a/src/main/scala/com/codahale/jerkson/Parser.scala b/src/main/scala/com/codahale/jerkson/Parser.scala index a2b35fb..200735a 100644 --- a/src/main/scala/com/codahale/jerkson/Parser.scala +++ b/src/main/scala/com/codahale/jerkson/Parser.scala @@ -85,7 +85,7 @@ trait Parser extends Factory { private[jerkson] def parse[A](parser: JsonParser, mf: Manifest[A]): A = { try { - if (mf.erasure == classOf[JValue] || mf.erasure == JNull.getClass) { + if (mf.runtimeClass == classOf[JValue] || mf.runtimeClass == JNull.getClass) { val value: A = parser.getCodec.readValue(parser, Types.build(mapper.getTypeFactory, mf)) if (value == null) JNull.asInstanceOf[A] else value } else { diff --git a/src/main/scala/com/codahale/jerkson/Types.scala b/src/main/scala/com/codahale/jerkson/Types.scala index 0c7066e..f9d2f97 100644 --- a/src/main/scala/com/codahale/jerkson/Types.scala +++ b/src/main/scala/com/codahale/jerkson/Types.scala @@ -12,11 +12,11 @@ private[jerkson] object Types { cachedTypes.getOrElseUpdate(manifest, constructType(factory, manifest)) private def constructType(factory: TypeFactory, manifest: Manifest[_]): JavaType = { - if (manifest.erasure.isArray) { - ArrayType.construct(factory.constructType(manifest.erasure.getComponentType), null, null) + if (manifest.runtimeClass.isArray) { + ArrayType.construct(factory.constructType(manifest.runtimeClass.getComponentType), null, null) } else { factory.constructParametricType( - manifest.erasure, + manifest.runtimeClass, manifest.typeArguments.map {m => build(factory, m)}.toArray: _*) } } From a7f89f513a047716ae768b2e011a1176d5a1a5c5 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 17:48:36 -0700 Subject: [PATCH 06/18] build with sbt --- build.sbt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 build.sbt diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..8a4adbe --- /dev/null +++ b/build.sbt @@ -0,0 +1,107 @@ +/* basic project info */ +name := "jerkson" + +organization := "com.cloudphysics" + +version := "0.5.1-SNAPSHOT" + +licenses := Seq( + ("The MIT License", url("http://codahale.com/mit.txt")) +) + +scmInfo := Some( + ScmInfo( + url("https://github.com/CloudPhysics/jerkson"), + "scm:git:https://github.com/CloudPhysics/jerkson.git", + Some("scm:git:git@github.com:CloudPhysics/jerkson.git") + ) +) + +/* scala versions and options */ +scalaVersion := "2.10.1" + +crossScalaVersions ++= Seq( + "2.10.0" + // "2.9.3-RC1", + // "2.9.2", + // "2.9.1", "2.9.1-1", + // "2.9.0", "2.9.0-1" +) + +// These options will be used for *all* versions. +scalacOptions ++= Seq( + "-deprecation", + "-unchecked", + "-encoding", "UTF-8", + "-optimise" // this option will slow your build +) + +scalacOptions ++= Seq( + "-Yclosure-elim", + "-Yinline" +) + +// These language flags will be used only for 2.10.x. +// Uncomment those you need, or if you hate SIP-18, all of them. +scalacOptions <++= scalaVersion map { sv => + if (sv startsWith "2.10") List( + "-Xverify", + "-Ywarn-all", + "-feature", + "-language:postfixOps", + "-language:reflectiveCalls", + "-language:implicitConversions", + "-language:higherKinds", + "-language:existentials" + ) + else Nil +} + +javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation") + +/* dependencies */ +libraryDependencies ++= Seq( + "org.codehaus.jackson" % "jackson-core-asl" % "1.9.12", + "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.12", + "org.scala-lang" % "scala-reflect" % "2.10.1" + // "com.codahale" %% "simplespec" % "0.6.0" % "test" +) + +/* testing */ +parallelExecution in Test := false + +/* sbt behavior */ +logLevel in compile := Level.Warn + +traceLevel := 5 + +offline := false + +/* publishing */ +publishMavenStyle := true + +publishTo <<= version { (v: String) => + val nexus = "https://oss.sonatype.org/" + if (v.trim.endsWith("SNAPSHOT")) Some( + "snapshots" at nexus + "content/repositories/snapshots" + ) + else Some("releases" at nexus + "service/local/staging/deploy/maven2") +} + +publishArtifact in Test := false + +pomIncludeRepository := { _ => false } + +pomExtra := ( + + + ymasory + Yuvi Masory + yuvi@cloudphysics.com + + +) + +// Josh Suereth's step-by-step guide to publishing on sonatype +// http://www.scala-sbt.org/using_sonatype.html + From 433053b469adc77d3dcc52b99aa6ac12430f0571 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 17:49:17 -0700 Subject: [PATCH 07/18] fix scm links --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 8a4adbe..f4d8c7b 100644 --- a/build.sbt +++ b/build.sbt @@ -11,9 +11,9 @@ licenses := Seq( scmInfo := Some( ScmInfo( - url("https://github.com/CloudPhysics/jerkson"), - "scm:git:https://github.com/CloudPhysics/jerkson.git", - Some("scm:git:git@github.com:CloudPhysics/jerkson.git") + url("https://github.com/cphylabs/jerkson"), + "scm:git:https://github.com/cphylabs/jerkson.git", + Some("scm:git:git@github.com:cphylabs/jerkson.git") ) ) From 6530b9c2ddc4f8971cfc104547b93db1caa7e6eb Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 19:10:08 -0700 Subject: [PATCH 08/18] change ByteCodecs package import for 2.10 --- .../scala/com/codahale/jerkson/util/CaseClassSigParser.scala | 2 +- .../jerkson/util/scalax/rules/scalasig/ScalaSig.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/codahale/jerkson/util/CaseClassSigParser.scala b/src/main/scala/com/codahale/jerkson/util/CaseClassSigParser.scala index 3895ea8..974c3e0 100644 --- a/src/main/scala/com/codahale/jerkson/util/CaseClassSigParser.scala +++ b/src/main/scala/com/codahale/jerkson/util/CaseClassSigParser.scala @@ -4,7 +4,7 @@ import com.codahale.jerkson.util.scalax.rules.scalasig._ import org.codehaus.jackson.`type`.JavaType import org.codehaus.jackson.map.`type`.TypeFactory import scala.reflect.ScalaSignature -import scala.reflect.generic.ByteCodecs +import scala.reflect.internal.pickling.ByteCodecs class MissingPickledSig(clazz: Class[_]) extends Error("Failed to parse pickled Scala signature from: %s".format(clazz)) diff --git a/src/main/scala/com/codahale/jerkson/util/scalax/rules/scalasig/ScalaSig.scala b/src/main/scala/com/codahale/jerkson/util/scalax/rules/scalasig/ScalaSig.scala index 0e12b42..b284ee1 100644 --- a/src/main/scala/com/codahale/jerkson/util/scalax/rules/scalasig/ScalaSig.scala +++ b/src/main/scala/com/codahale/jerkson/util/scalax/rules/scalasig/ScalaSig.scala @@ -4,7 +4,7 @@ package rules package scalasig import ClassFileParser.{ConstValueIndex, Annotation} -import scala.reflect.generic.ByteCodecs +import scala.reflect.internal.pickling.ByteCodecs object ScalaSigParser { @@ -272,7 +272,7 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { ) as "type" lazy val literal = oneOf( - 24 -^ (), + (24).-^(()), 25 -~ longValue ^^ (_ != 0L), 26 -~ longValue ^^ (_.toByte), 27 -~ longValue ^^ (_.toShort), From 3eabdb11e3dcefad1afb60a0856984243b8a0fd3 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 19:17:06 -0700 Subject: [PATCH 09/18] fix scala version dependent dependency --- build.sbt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index f4d8c7b..997961c 100644 --- a/build.sbt +++ b/build.sbt @@ -62,11 +62,15 @@ javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation") /* dependencies */ libraryDependencies ++= Seq( "org.codehaus.jackson" % "jackson-core-asl" % "1.9.12", - "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.12", - "org.scala-lang" % "scala-reflect" % "2.10.1" + "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.12" // "com.codahale" %% "simplespec" % "0.6.0" % "test" ) +libraryDependencies <+= scalaVersion { + "org.scala-lang" % "scala-reflect" % _ +} + + /* testing */ parallelExecution in Test := false From 7fef0e3c28fbbfddc09f576a5680389a6f5b6091 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 19:29:06 -0700 Subject: [PATCH 10/18] add explicit return type. now compiles --- .../scala/com/codahale/jerkson/deser/ScalaDeserializers.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/codahale/jerkson/deser/ScalaDeserializers.scala b/src/main/scala/com/codahale/jerkson/deser/ScalaDeserializers.scala index 620ba70..5e0fadb 100644 --- a/src/main/scala/com/codahale/jerkson/deser/ScalaDeserializers.scala +++ b/src/main/scala/com/codahale/jerkson/deser/ScalaDeserializers.scala @@ -9,7 +9,7 @@ import scala.collection.generic.{MapFactory, GenericCompanion} class ScalaDeserializers(classLoader: ClassLoader) extends Deserializers.Base { override def findBeanDeserializer(javaType: JavaType, config: DeserializationConfig, provider: DeserializerProvider, beanDesc: BeanDescription, - property: BeanProperty) = { + property: BeanProperty): JsonDeserializer[_] = { val klass = javaType.getRawClass if (klass == classOf[Range] || klass == classOf[immutable.Range]) { new RangeDeserializer From 68b1a21efdcb5e58cb733eb26f270ecc03a2accf Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 20:01:53 -0700 Subject: [PATCH 11/18] remove unused build configs --- build.sbt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 997961c..22944be 100644 --- a/build.sbt +++ b/build.sbt @@ -22,10 +22,6 @@ scalaVersion := "2.10.1" crossScalaVersions ++= Seq( "2.10.0" - // "2.9.3-RC1", - // "2.9.2", - // "2.9.1", "2.9.1-1", - // "2.9.0", "2.9.0-1" ) // These options will be used for *all* versions. @@ -63,13 +59,16 @@ javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation") libraryDependencies ++= Seq( "org.codehaus.jackson" % "jackson-core-asl" % "1.9.12", "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.12" - // "com.codahale" %% "simplespec" % "0.6.0" % "test" ) libraryDependencies <+= scalaVersion { "org.scala-lang" % "scala-reflect" % _ } +resolvers ++= Seq( + "Local Maven" at Path.userHome.asFile.toURI.toURL + ".m2/repository" +) + /* testing */ parallelExecution in Test := false From b1d099f99ae0869497c40f7f05238a4e58f7b1ad Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 20:02:16 -0700 Subject: [PATCH 12/18] remove tests, since sbt can't run simplespec --- .../jerkson/tests/ASTTypeSupportSpec.scala | 125 -------- .../jerkson/tests/BasicTypeSupportSpec.scala | 217 ------------- .../jerkson/tests/CaseClassSupportSpec.scala | 239 --------------- .../jerkson/tests/CollectionSupportSpec.scala | 177 ----------- .../tests/DefaultCollectionSupportSpec.scala | 247 --------------- .../codahale/jerkson/tests/EdgeCaseSpec.scala | 69 ----- .../jerkson/tests/ExampleCaseClasses.scala | 74 ----- .../jerkson/tests/FancyTypeSupportSpec.scala | 31 -- .../ImmutableCollectionSupportSpec.scala | 285 ------------------ .../codahale/jerkson/tests/JValueSpec.scala | 54 ---- .../tests/MutableCollectionSupportSpec.scala | 189 ------------ .../jerkson/tests/StreamingSpec.scala | 23 -- 12 files changed, 1730 deletions(-) delete mode 100644 src/test/scala/com/codahale/jerkson/tests/ASTTypeSupportSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/BasicTypeSupportSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/CaseClassSupportSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/CollectionSupportSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/DefaultCollectionSupportSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/EdgeCaseSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/ExampleCaseClasses.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/FancyTypeSupportSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/ImmutableCollectionSupportSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/JValueSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/MutableCollectionSupportSpec.scala delete mode 100644 src/test/scala/com/codahale/jerkson/tests/StreamingSpec.scala diff --git a/src/test/scala/com/codahale/jerkson/tests/ASTTypeSupportSpec.scala b/src/test/scala/com/codahale/jerkson/tests/ASTTypeSupportSpec.scala deleted file mode 100644 index 95e1040..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/ASTTypeSupportSpec.scala +++ /dev/null @@ -1,125 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.jerkson.Json._ -import com.codahale.jerkson.AST._ -import com.codahale.simplespec.Spec -import org.junit.Test - -class ASTTypeSupportSpec extends Spec { - class `An AST.JInt` { - @Test def `generates a JSON int` = { - generate(JInt(15)).must(be("15")) - } - - @Test def `is parsable from a JSON int` = { - parse[JInt]("15").must(be(JInt(15))) - } - - @Test def `is parsable from a JSON int as a JValue` = { - parse[JValue]("15").must(be(JInt(15))) - } - } - - class `An AST.JFloat` { - @Test def `generates a JSON int` = { - generate(JFloat(15.1)).must(be("15.1")) - } - - @Test def `is parsable from a JSON float` = { - parse[JFloat]("15.1").must(be(JFloat(15.1))) - } - - @Test def `is parsable from a JSON float as a JValue` = { - parse[JValue]("15.1").must(be(JFloat(15.1))) - } - } - - - class `An AST.JString` { - @Test def `generates a JSON string` = { - generate(JString("woo")).must(be("\"woo\"")) - } - - @Test def `is parsable from a JSON string` = { - parse[JString]("\"woo\"").must(be(JString("woo"))) - } - - @Test def `is parsable from a JSON string as a JValue` = { - parse[JValue]("\"woo\"").must(be(JString("woo"))) - } - } - - class `An AST.JNull` { - @Test def `generates a JSON null` = { - generate(JNull).must(be("null")) - } - - @Test def `is parsable from a JSON null` = { - parse[JNull.type]("null").must(be(JNull)) - } - - @Test def `is parsable from a JSON null as a JValue` = { - parse[JValue]("null").must(be(JNull)) - } - } - - class `An AST.JBoolean` { - @Test def `generates a JSON true` = { - generate(JBoolean(true)).must(be("true")) - } - - @Test def `generates a JSON false` = { - generate(JBoolean(false)).must(be("false")) - } - - @Test def `is parsable from a JSON true` = { - parse[JBoolean]("true").must(be(JBoolean(true))) - } - - @Test def `is parsable from a JSON false` = { - parse[JBoolean]("false").must(be(JBoolean(false))) - } - - @Test def `is parsable from a JSON true as a JValue` = { - parse[JValue]("true").must(be(JBoolean(true))) - } - - @Test def `is parsable from a JSON false as a JValue` = { - parse[JValue]("false").must(be(JBoolean(false))) - } - } - - class `An AST.JArray of JInts` { - @Test def `generates a JSON array of ints` = { - generate(JArray(List(JInt(1), JInt(2), JInt(3)))).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[JArray]("[1,2,3]").must(be(JArray(List(JInt(1), JInt(2), JInt(3))))) - } - - @Test def `is parsable from a JSON array of ints as a JValue` = { - parse[JValue]("[1,2,3]").must(be(JArray(List(JInt(1), JInt(2), JInt(3))))) - } - } - - class `An AST.JObject` { - val obj = JObject(List(JField("id", JInt(1)), JField("name", JString("Coda")))) - - @Test def `generates a JSON object with matching field values` = { - generate(obj).must(be("""{"id":1,"name":"Coda"}""")) - } - - @Test def `is parsable from a JSON object` = { - parse[JObject]("""{"id":1,"name":"Coda"}""").must(be(obj)) - } - - @Test def `is parsable from a JSON object as a JValue` = { - parse[JValue]("""{"id":1,"name":"Coda"}""").must(be(obj)) - } - - @Test def `is parsable from an empty JSON object` = { - parse[JObject]("""{}""").must(be(JObject(Nil))) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/BasicTypeSupportSpec.scala b/src/test/scala/com/codahale/jerkson/tests/BasicTypeSupportSpec.scala deleted file mode 100644 index 0eb97dd..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/BasicTypeSupportSpec.scala +++ /dev/null @@ -1,217 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.simplespec.Spec -import com.codahale.jerkson.Json._ -import org.codehaus.jackson.node.IntNode -import org.codehaus.jackson.JsonNode -import org.junit.Test - -class BasicTypeSupportSpec extends Spec { - class `A Byte` { - @Test def `generates a JSON int` = { - generate(15.toByte).must(be("15")) - } - - @Test def `is parsable from a JSON int` = { - parse[Byte]("15").must(be(15)) - } - } - - class `A Short` { - @Test def `generates a JSON int` = { - generate(15.toShort).must(be("15")) - } - - @Test def `is parsable from a JSON int` = { - parse[Short]("15").must(be(15)) - } - } - - class `An Int` { - @Test def `generates a JSON int` = { - generate(15).must(be("15")) - } - - @Test def `is parsable from a JSON int` = { - parse[Int]("15").must(be(15)) - } - } - - class `A Long` { - @Test def `generates a JSON int` = { - generate(15L).must(be("15")) - } - - @Test def `is parsable from a JSON int` = { - parse[Long]("15").must(be(15L)) - } - } - - class `A BigInt` { - @Test def `generates a JSON int` = { - generate(BigInt(15)).must(be("15")) - } - - @Test def `is parsable from a JSON int` = { - parse[BigInt]("15").must(be(BigInt(15))) - } - - @Test def `is parsable from a JSON string` = { - parse[BigInt]("\"15\"").must(be(BigInt(15))) - } - } - - class `A Float` { - @Test def `generates a JSON float` = { - generate(15.1F).must(be("15.1")) - } - - @Test def `is parsable from a JSON float` = { - parse[Float]("15.1").must(be(15.1F)) - } - } - - class `A Double` { - @Test def `generates a JSON float` = { - generate(15.1).must(be("15.1")) - } - - @Test def `is parsable from a JSON float` = { - parse[Double]("15.1").must(be(15.1D)) - } - } - - class `A BigDecimal` { - @Test def `generates a JSON float` = { - generate(BigDecimal(15.5)).must(be("15.5")) - } - - @Test def `is parsable from a JSON float` = { - parse[BigDecimal]("15.5").must(be(BigDecimal(15.5))) - } - - @Test def `is parsable from a JSON int` = { - parse[BigDecimal]("15").must(be(BigDecimal(15.0))) - } - } - - class `A String` { - @Test def `generates a JSON string` = { - generate("woo").must(be("\"woo\"")) - } - - @Test def `is parsable from a JSON string` = { - parse[String]("\"woo\"").must(be("woo")) - } - } - - class `A StringBuilder` { - @Test def `generates a JSON string` = { - generate(new StringBuilder("foo")).must(be("\"foo\"")) - } - - @Test def `is parsable from a JSON string` = { - parse[StringBuilder]("\"foo\"").toString().must(be("foo")) - } - } - - class `A null Object` { - @Test def `generates a JSON null` = { - generate[Object](null).must(be("null")) - } - - @Test def `is parsable from a JSON null` = { - parse[Object]("null").must(be(not(notNull))) - } - } - - class `A Boolean` { - @Test def `generates a JSON true` = { - generate(true).must(be("true")) - } - - @Test def `generates a JSON false` = { - generate(false).must(be("false")) - } - - @Test def `is parsable from a JSON true` = { - parse[Boolean]("true").must(be(true)) - } - - @Test def `is parsable from a JSON false` = { - parse[Boolean]("false").must(be(false)) - } - } - - class `A Some[Int]` { - @Test def `generates a JSON int` = { - generate(Some(12)).must(be("12")) - } - - @Test def `is parsable from a JSON int as an Option[Int]` = { - parse[Option[Int]]("12").must(be(Some(12))) - } - } - - class `A None` { - @Test def `generates a JSON null` = { - generate(None).must(be("null")) - } - - @Test def `is parsable from a JSON null as an Option[Int]` = { - parse[Option[Int]]("null").must(be(None)) - } - } - - class `A Left[String]` { - @Test def `generates a JSON string` = { - generate(Left("woo")).must(be("\"woo\"")) - } - - @Test def `is parsable from a JSON string as an Either[String, Int]` = { - parse[Either[String, Int]]("\"woo\"").must(be(Left("woo"))) - } - } - - class `A Right[String]` { - @Test def `generates a JSON string` = { - generate(Right("woo")).must(be("\"woo\"")) - } - - @Test def `is parsable from a JSON string as an Either[Int, String]` = { - parse[Either[Int, String]]("\"woo\"").must(be(Right("woo"))) - } - } - - class `A JsonNode` { - @Test def `generates whatever the JsonNode is` = { - generate(new IntNode(2)).must(be("2")) - } - - @Test def `is parsable from a JSON AST node` = { - parse[JsonNode]("2").must(be(new IntNode(2))) - } - - @Test def `is parsable from a JSON AST node as a specific type` = { - parse[IntNode]("2").must(be(new IntNode(2))) - } - - @Test def `is itself parsable` = { - parse[Int](new IntNode(2)).must(be(2)) - } - } - - class `An Array[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Array(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Array[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Array[Int]]("[]").toList.must(be(List.empty)) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/CaseClassSupportSpec.scala b/src/test/scala/com/codahale/jerkson/tests/CaseClassSupportSpec.scala deleted file mode 100644 index 7a562f5..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/CaseClassSupportSpec.scala +++ /dev/null @@ -1,239 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.jerkson.Json._ -import com.codahale.simplespec.Spec -import com.codahale.jerkson.ParsingException -import org.codehaus.jackson.node.IntNode -import org.junit.Test - -class CaseClassSupportSpec extends Spec { - class `A basic case class` { - @Test def `generates a JSON object with matching field values` = { - generate(CaseClass(1, "Coda")).must(be("""{"id":1,"name":"Coda"}""")) - } - - @Test def `is parsable from a JSON object with corresponding fields` = { - parse[CaseClass]("""{"id":1,"name":"Coda"}""").must(be(CaseClass(1, "Coda"))) - } - - @Test def `is parsable from a JSON object with extra fields` = { - parse[CaseClass]("""{"id":1,"name":"Coda","derp":100}""").must(be(CaseClass(1, "Coda"))) - } - - @Test def `is not parsable from an incomplete JSON object` = { - evaluating { - parse[CaseClass]("""{"id":1}""") - }.must(throwA[ParsingException]("""Invalid JSON. Needed [id, name], but found [id].""")) - } - } - - class `A case class with lazy fields` { - @Test def `generates a JSON object with those fields evaluated` = { - generate(CaseClassWithLazyVal(1)).must(be("""{"id":1,"woo":"yeah"}""")) - } - - @Test def `is parsable from a JSON object without those fields` = { - parse[CaseClassWithLazyVal]("""{"id":1}""").must(be(CaseClassWithLazyVal(1))) - } - - @Test def `is not parsable from an incomplete JSON object` = { - evaluating { - parse[CaseClassWithLazyVal]("""{}""") - }.must(throwA[ParsingException]("""Invalid JSON. Needed [id], but found [].""")) - } - } - - class `A case class with ignored members` { - @Test def `generates a JSON object without those fields` = { - generate(CaseClassWithIgnoredField(1)).must(be("""{"id":1}""")) - generate(CaseClassWithIgnoredFields(1)).must(be("""{"id":1}""")) - } - - @Test def `is parsable from a JSON object without those fields` = { - parse[CaseClassWithIgnoredField]("""{"id":1}""").must(be(CaseClassWithIgnoredField(1))) - parse[CaseClassWithIgnoredFields]("""{"id":1}""").must(be(CaseClassWithIgnoredFields(1))) - } - - @Test def `is not parsable from an incomplete JSON object` = { - evaluating { - parse[CaseClassWithIgnoredField]("""{}""") - }.must(throwA[ParsingException]("""Invalid JSON. Needed [id], but found [].""")) - - evaluating { - parse[CaseClassWithIgnoredFields]("""{}""") - }.must(throwA[ParsingException]("""Invalid JSON. Needed [id], but found [].""")) - } - } - - class `A case class with transient members` { - @Test def `generates a JSON object without those fields` = { - generate(CaseClassWithTransientField(1)).must(be("""{"id":1}""")) - } - - @Test def `is parsable from a JSON object without those fields` = { - parse[CaseClassWithTransientField]("""{"id":1}""").must(be(CaseClassWithTransientField(1))) - } - - @Test def `is not parsable from an incomplete JSON object` = { - evaluating { - parse[CaseClassWithTransientField]("""{}""") - }.must(throwA[ParsingException]("""Invalid JSON. Needed [id], but found [].""")) - } - } - - class `A case class with an overloaded field` { - @Test def `generates a JSON object with the nullary version of that field` = { - generate(CaseClassWithOverloadedField(1)).must(be("""{"id":1}""")) - } - } - - class `A case class with an Option[String] member` { - @Test def `generates a field if the member is Some` = { - generate(CaseClassWithOption(Some("what"))).must(be("""{"value":"what"}""")) - } - - @Test def `is parsable from a JSON object with that field` = { - parse[CaseClassWithOption]("""{"value":"what"}""").must(be(CaseClassWithOption(Some("what")))) - } - - @Test def `doesn't generate a field if the member is None` = { - generate(CaseClassWithOption(None)).must(be("""{}""")) - } - - @Test def `is parsable from a JSON object without that field` = { - parse[CaseClassWithOption]("""{}""").must(be(CaseClassWithOption(None))) - } - - @Test def `is parsable from a JSON object with a null value for that field` = { - parse[CaseClassWithOption]("""{"value":null}""").must(be(CaseClassWithOption(None))) - } - } - - class `A case class with a JsonNode member` { - @Test def `generates a field of the given type` = { - generate(CaseClassWithJsonNode(new IntNode(2))).must(be("""{"value":2}""")) - } - } - - class `A case class with members of all ScalaSig types` { - val json = """ - { - "map": { - "one": "two" - }, - "set": [1, 2, 3], - "string": "woo", - "list": [4, 5, 6], - "seq": [7, 8, 9], - "sequence": [10, 11, 12], - "collection": [13, 14, 15], - "indexedSeq": [16, 17, 18], - "randomAccessSeq": [19, 20, 21], - "vector": [22, 23, 24], - "bigDecimal": 12.0, - "bigInt": 13, - "int": 1, - "long": 2, - "char": "x", - "bool": false, - "short": 14, - "byte": 15, - "float": 34.5, - "double": 44.9, - "any": true, - "anyRef": "wah", - "intMap": { - "1": "1" - }, - "longMap": { - "2": 2 - } - } - """ - - - @Test def `is parsable from a JSON object with those fields` = { - parse[CaseClassWithAllTypes](json).must(be( - CaseClassWithAllTypes( - map = Map("one" -> "two"), - set = Set(1, 2, 3), - string = "woo", - list = List(4, 5, 6), - seq = Seq(7, 8, 9), - indexedSeq = IndexedSeq(16, 17, 18), - vector = Vector(22, 23, 24), - bigDecimal = BigDecimal("12.0"), - bigInt = BigInt("13"), - int = 1, - long = 2L, - char = 'x', - bool = false, - short = 14, - byte = 15, - float = 34.5f, - double = 44.9d, - any = true, - anyRef = "wah", - intMap = Map(1 -> 1), - longMap = Map(2L -> 2L) - ) - )) - } - } - - class `A case class nested inside of an object` { - @Test def `is parsable from a JSON object` = { - parse[OuterObject.NestedCaseClass]("""{"id": 1}""").must(be(OuterObject.NestedCaseClass(1))) - } - } - - class `A case class nested inside of an object nested inside of an object` { - @Test def `is parsable from a JSON object` = { - parse[OuterObject.InnerObject.SuperNestedCaseClass]("""{"id": 1}""").must(be(OuterObject.InnerObject.SuperNestedCaseClass(1))) - } - } - - class `A case class with two constructors` { - @Test def `is parsable from a JSON object with the same parameters as the case accessor` = { - parse[CaseClassWithTwoConstructors]("""{"id":1,"name":"Bert"}""").must(be(CaseClassWithTwoConstructors(1, "Bert"))) - } - - @Test def `is parsable from a JSON object which works with the second constructor` = { - evaluating { - parse[CaseClassWithTwoConstructors]("""{"id":1}""") - }.must(throwA[ParsingException]) - } - } - - class `A case class with snake-cased fields` { - @Test def `is parsable from a snake-cased JSON object` = { - parse[CaseClassWithSnakeCase]("""{"one_thing":"yes","two_thing":"good"}""").must(be(CaseClassWithSnakeCase("yes", "good"))) - } - - @Test def `generates a snake-cased JSON object` = { - generate(CaseClassWithSnakeCase("yes", "good")).must(be("""{"one_thing":"yes","two_thing":"good"}""")) - } - - @Test def `throws errors with the snake-cased field names present` = { - evaluating { - parse[CaseClassWithSnakeCase]("""{"one_thing":"yes"}""") - }.must(throwA[ParsingException]("Invalid JSON. Needed [one_thing, two_thing], but found [one_thing].")) - } - } - - class `A case class with array members` { - @Test def `is parsable from a JSON object` = { - val c = parse[CaseClassWithArrays]("""{"one":"1","two":["a","b","c"],"three":[1,2,3]}""") - - c.one.must(be("1")) - c.two.must(be(Array("a", "b", "c"))) - c.three.must(be(Array(1, 2, 3))) - } - - @Test def `generates a JSON object` = { - generate(CaseClassWithArrays("1", Array("a", "b", "c"), Array(1, 2, 3))).must(be( - """{"one":"1","two":["a","b","c"],"three":[1,2,3]}""" - )) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/CollectionSupportSpec.scala b/src/test/scala/com/codahale/jerkson/tests/CollectionSupportSpec.scala deleted file mode 100644 index 98e139d..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/CollectionSupportSpec.scala +++ /dev/null @@ -1,177 +0,0 @@ -package com.codahale.jerkson.tests - -import scala.collection._ -import com.codahale.jerkson.Json._ -import com.codahale.simplespec.Spec -import org.junit.{Ignore, Test} - -class CollectionSupportSpec extends Spec { - class `A collection.BitSet` { - @Test def `generates a JSON array of ints` = { - generate(BitSet(1)).must(be("[1]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[BitSet]("[1,2,3]").must(be(BitSet(1, 2, 3))) - } - } - - class `A collection.Iterator[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3).iterator).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Iterator[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Iterator[Int]]("[]").toList.must(be(List.empty[Int])) - } - } - - class `A collection.Traversable[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3).toTraversable).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Traversable[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Traversable[Int]]("[]").toList.must(be(List.empty[Int])) - } - } - - class `A collection.BufferedIterator[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3).iterator.buffered).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[BufferedIterator[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[BufferedIterator[Int]]("[]").toList.must(be(List.empty[Int])) - } - } - - class `A collection.Iterable[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3).toIterable).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Iterable[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Iterable[Int]]("[]").toList.must(be(List.empty[Int])) - } - } - - class `A collection.Set[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Set(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Set[Int]]("[1,2,3]").must(be(Set(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Set[Int]]("[]").must(be(Set.empty[Int])) - } - } - - class `A collection.Map[String, Int]` { - @Test def `generates a JSON object with int field values` = { - generate(Map("one" -> 1, "two" -> 2)).must(be("""{"one":1,"two":2}""")) - } - - @Test def `is parsable from a JSON object with int field values` = { - parse[Map[String, Int]]("""{"one":1,"two":2}""").must(be(Map("one" -> 1, "two" -> 2))) - } - - @Test def `is parsable from an empty JSON object` = { - parse[Map[String, Int]]("{}").must(be(Map.empty[String, Int])) - } - } - - class `A collection.IndexedSeq[Int]` { - @Test def `generates a JSON array of ints` = { - generate(IndexedSeq(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[IndexedSeq[Int]]("[1,2,3]").must(be(IndexedSeq(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[IndexedSeq[Int]]("[]").must(be(IndexedSeq.empty)) - } - } - - class `A collection.Seq[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Seq[Int]]("[1,2,3]").must(be(Seq(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Seq[Int]]("[]").must(be(Seq.empty[Int])) - } - } - - class `A collection.SortedMap[String, Int]` { - @Test def `generates a JSON object with int field values` = { - generate(SortedMap("one" -> 1, "two" -> 2)).must(be("""{"one":1,"two":2}""")) - } - - // TODO: 6/1/11 -- figure out how to deserialize SortedMap instances - - /** - * I think all this would take is a mapping from Class[_] to Ordering, which - * would need to have hard-coded the various primitive types, and then add - * support for Ordered and Comparable classes. Once we have the Ordering, - * we can pass it in manually to a builder. - */ - - @Ignore @Test def `is parsable from a JSON object with int field values` = { - parse[SortedMap[String, Int]]("""{"one":1,"two":2}""").must(be(SortedMap("one" -> 1, "two" -> 2))) - } - - @Ignore @Test def `is parsable from an empty JSON object` = { - parse[SortedMap[String, Int]]("{}").must(be(SortedMap.empty[String, Int])) - } - } - - class `A collection.SortedSet[Int]` { - @Test def `generates a JSON array of ints` = { - generate(SortedSet(1, 2, 3)).must(be("[1,2,3]")) - } - - // TODO: 6/1/11 -- figure out how to deserialize SortedMap instances - - /** - * I think all this would take is a mapping from Class[_] to Ordering, which - * would need to have hard-coded the various primitive types, and then add - * support for Ordered and Comparable classes. Once we have the Ordering, - * we can pass it in manually to a builder. - */ - - @Ignore @Test def `is parsable from a JSON array of ints` = { - parse[SortedSet[Int]]("[1,2,3]").must(be(SortedSet(1, 2, 3))) - - } - - @Ignore @Test def `is parsable from an empty JSON array` = { - parse[SortedSet[Int]]("[]").must(be(SortedSet.empty[Int])) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/DefaultCollectionSupportSpec.scala b/src/test/scala/com/codahale/jerkson/tests/DefaultCollectionSupportSpec.scala deleted file mode 100644 index 3085295..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/DefaultCollectionSupportSpec.scala +++ /dev/null @@ -1,247 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.jerkson.Json._ -import com.codahale.simplespec.Spec -import com.codahale.jerkson.ParsingException -import org.junit.{Ignore, Test} - -class DefaultCollectionSupportSpec extends Spec { - class `A Range` { - @Test def `generates a JSON object` = { - generate(Range.inclusive(1, 4, 3)).must(be("""{"start":1,"end":4,"step":3,"inclusive":true}""")) - } - - @Test def `generates a JSON object without the inclusive field if it's exclusive` = { - generate(Range(1, 4, 3)).must(be("""{"start":1,"end":4,"step":3}""")) - } - - @Test def `generates a JSON object without the step field if it's 1` = { - generate(Range(1, 4)).must(be("""{"start":1,"end":4}""")) - } - - @Test def `is parsable from a JSON object` = { - parse[Range]("""{"start":1,"end":4,"step":3,"inclusive":true}""").must(be(Range.inclusive(1, 4, 3))) - } - - @Test def `is parsable from a JSON object without the inclusive field` = { - parse[Range]("""{"start":1,"end":4,"step":3}""").must(be(Range(1, 4, 3))) - } - - @Test def `is parsable from a JSON object without the step field` = { - parse[Range]("""{"start":1,"end":4}""").must(be(Range(1, 4))) - } - - @Test def `is not parsable from a JSON object without the required fields` = { - evaluating { - parse[Range]("""{"start":1}""") - }.must(throwA[ParsingException]("""Invalid JSON. Needed [start, end, , ], but found [start].""")) - } - - } - - class `A Pair[Int]` { - @Ignore @Test def `generates a two-element JSON array of ints` = { - // TODO: 5/31/11 -- fix Pair serialization - generate(Pair(1, 2)).must(be("[1,2]")) - } - - @Ignore @Test def `is parsable from a two-element JSON array of ints` = { - // TODO: 5/31/11 -- fix Pair deserialization - parse[Pair[Int, Int]]("[1,2]").must(be(Pair(1, 2))) - } - } - - class `A Triple[Int]` { - @Ignore @Test def `generates a three-element JSON array of ints` = { - // TODO: 5/31/11 -- fix Triple serialization - generate(Triple(1, 2, 3)).must(be("[1,2,3]")) - } - - @Ignore @Test def `is parsable from a three-element JSON array of ints` = { - // TODO: 5/31/11 -- fix Triple deserialization - parse[Triple[Int, Int, Int]]("[1,2,3]").must(be(Triple(1, 2, 3))) - } - } - - class `A four-tuple` { - @Ignore @Test def `generates a four-element JSON array` = { - // TODO: 5/31/11 -- fix Tuple4 serialization - generate((1, "2", 3, "4")).must(be("[1,\"2\",3,\"4\"]")) - } - - @Ignore @Test def `is parsable from a three-element JSON array of ints` = { - // TODO: 5/31/11 -- fix Tuple4 deserialization - parse[(Int, String, Int, String)]("[1,\"2\",3,\"4\"]").must(be((1, "2", 3, "4"))) - } - } - - // TODO: 6/1/11 -- add support for all Tuple1->TupleBillionty types - - class `A Seq[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Seq[Int]]("[1,2,3]").must(be(Seq(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Seq[Int]]("[]").must(be(Seq.empty[Int])) - } - } - - class `A List[Int]` { - @Test def `generates a JSON array of ints` = { - generate(List(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[List[Int]]("[1,2,3]").must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[List[Int]]("[]").must(be(List.empty[Int])) - } - } - - class `An IndexedSeq[Int]` { - @Test def `generates a JSON array of ints` = { - generate(IndexedSeq(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[IndexedSeq[Int]]("[1,2,3]").must(be(IndexedSeq(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[IndexedSeq[Int]]("[]").must(be(IndexedSeq.empty[Int])) - } - } - - class `A Vector[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Vector(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Vector[Int]]("[1,2,3]").must(be(Vector(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Vector[Int]]("[]").must(be(Vector.empty[Int])) - } - } - - class `A Set[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Set(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Set[Int]]("[1,2,3]").must(be(Set(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Set[Int]]("[]").must(be(Set.empty[Int])) - } - } - - class `A Map[String, Int]` { - @Test def `generates a JSON object with int field values` = { - generate(Map("one" -> 1, "two" -> 2)).must(be("""{"one":1,"two":2}""")) - } - - @Test def `is parsable from a JSON object with int field values` = { - parse[Map[String, Int]]("""{"one":1,"two":2}""").must(be(Map("one" -> 1, "two" -> 2))) - } - - @Test def `is parsable from an empty JSON object` = { - parse[Map[String, Int]]("{}").must(be(Map.empty[String, Int])) - } - } - - class `A Map[String, Any]` { - @Test def `generates a JSON object with mixed field values` = { - generate(Map("one" -> 1, "two" -> "2")).must(be("""{"one":1,"two":"2"}""")) - } - - @Test def `is parsable from a JSON object with mixed field values` = { - parse[Map[String, Any]]("""{"one":1,"two":"2"}""").must(be(Map[String, Any]("one" -> 1, "two" -> "2"))) - } - - @Test def `is parsable from an empty JSON object` = { - parse[Map[String, Any]]("{}").must(be(Map.empty[String, Any])) - } - } - - class `A Stream[Int]` { - @Test def `generates a JSON array` = { - generate(Stream(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Stream[Int]]("[1,2,3]").must(be(Stream(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Stream[Int]]("[]").must(be(Stream.empty[Int])) - } - } - - class `An Iterator[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3).iterator).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Iterator[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Iterator[Int]]("[]").toList.must(be(List.empty[Int])) - } - } - - class `A Traversable[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3).toTraversable).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Traversable[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Traversable[Int]]("[]").toList.must(be(List.empty[Int])) - } - } - - class `A BufferedIterator[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3).iterator.buffered).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[BufferedIterator[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[BufferedIterator[Int]]("[]").toList.must(be(List.empty[Int])) - } - } - - class `An Iterable[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3).toIterable).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Iterable[Int]]("[1,2,3]").toList.must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Iterable[Int]]("[]").toList.must(be(List.empty[Int])) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/EdgeCaseSpec.scala b/src/test/scala/com/codahale/jerkson/tests/EdgeCaseSpec.scala deleted file mode 100644 index 4fdcb1c..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/EdgeCaseSpec.scala +++ /dev/null @@ -1,69 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.jerkson.Json._ -import com.codahale.simplespec.Spec -import com.codahale.jerkson.ParsingException -import java.io.ByteArrayInputStream -import org.junit.Test - -class EdgeCaseSpec extends Spec { - class `Deserializing lists` { - @Test def `doesn't cache Seq builders` = { - parse[List[Int]]("[1,2,3,4]").must(be(List(1, 2, 3, 4))) - parse[List[Int]]("[1,2,3,4]").must(be(List(1, 2, 3, 4))) - } - } - - class `Parsing a JSON array of ints with nulls` { - @Test def `should be readable as a List[Option[Int]]` = { - parse[List[Option[Int]]]("[1,2,null,4]").must(be(List(Some(1), Some(2), None, Some(4)))) - } - } - - class `Deserializing maps` { - @Test def `doesn't cache Map builders` = { - parse[Map[String, Int]](""" {"one":1, "two": 2} """).must(be(Map("one" -> 1, "two" -> 2))) - parse[Map[String, Int]](""" {"one":1, "two": 2} """).must(be(Map("one" -> 1, "two" -> 2))) - } - } - - class `Parsing malformed JSON` { - @Test def `should throw a ParsingException with an informative message` = { - evaluating { - parse[Boolean]("jjf8;09") - }.must(throwA[ParsingException]( - "Malformed JSON. Unexpected character ('j' (code 106)): expected a " + - "valid value (number, String, array, object, 'true', 'false' " + - "or 'null') at character offset 0.")) - - evaluating { - parse[CaseClass]("{\"ye\":1") - }.must(throwA[ParsingException]( - "Malformed JSON. Unexpected end-of-input: expected close marker for " + - "OBJECT at character offset 20.")) - } - } - - class `Parsing invalid JSON` { - @Test def `should throw a ParsingException with an informative message` = { - evaluating { - parse[CaseClass]("900") - }.must(throwA[ParsingException]( - ("""Can not deserialize instance of com.codahale.jerkson.tests.CaseClass out of VALUE_NUMBER_INT token\n""" + - """ at \[Source: java.io.StringReader@[0-9a-f]+; line: 1, column: 1\]""").r)) - - evaluating { - parse[CaseClass]("{\"woo\": 1}") - }.must(throwA[ParsingException]("Invalid JSON. Needed [id, name], but found [woo].")) - } - } - - class `Parsing an empty document` { - @Test def `should throw a ParsingException with an informative message` = { - val input = new ByteArrayInputStream(Array.empty) - evaluating { - parse[CaseClass](input) - }.must(throwA[ParsingException]("JSON document ended unexpectedly.")) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/ExampleCaseClasses.scala b/src/test/scala/com/codahale/jerkson/tests/ExampleCaseClasses.scala deleted file mode 100644 index c3b666f..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/ExampleCaseClasses.scala +++ /dev/null @@ -1,74 +0,0 @@ -package com.codahale.jerkson.tests - -import org.codehaus.jackson.JsonNode -import org.codehaus.jackson.annotate.{JsonIgnoreProperties, JsonIgnore} -import com.codahale.jerkson.JsonSnakeCase - -case class CaseClass(id: Long, name: String) - -case class CaseClassWithLazyVal(id: Long) { - lazy val woo = "yeah" -} - -case class CaseClassWithIgnoredField(id: Long) { - @JsonIgnore - val uncomfortable = "Bad Touch" -} - -@JsonIgnoreProperties(Array("uncomfortable", "unpleasant")) -case class CaseClassWithIgnoredFields(id: Long) { - val uncomfortable = "Bad Touch" - val unpleasant = "The Creeps" -} - -case class CaseClassWithTransientField(id: Long) { - @transient - val lol = "I'm sure it's just a phase." -} - -case class CaseClassWithOverloadedField(id: Long) { - def id(prefix: String): String = prefix + id -} - -case class CaseClassWithOption(value: Option[String]) - -case class CaseClassWithJsonNode(value: JsonNode) - -case class CaseClassWithAllTypes(map: Map[String, String], - set: Set[Int], - string: String, - list: List[Int], - seq: Seq[Int], - indexedSeq: IndexedSeq[Int], - vector: Vector[Int], - bigDecimal: BigDecimal, - bigInt: BigInt, - int: Int, - long: Long, - char: Char, - bool: Boolean, - short: Short, - byte: Byte, - float: Float, - double: Double, - any: Any, - anyRef: AnyRef, - intMap: Map[Int, Int], - longMap: Map[Long, Long]) - -object OuterObject { - case class NestedCaseClass(id: Long) - - object InnerObject { - case class SuperNestedCaseClass(id: Long) - } -} - -case class CaseClassWithTwoConstructors(id: Long, name: String) { - def this(id: Long) = this(id, "New User") -} - -@JsonSnakeCase -case class CaseClassWithSnakeCase(oneThing: String, twoThing: String) - -case class CaseClassWithArrays(one: String, two: Array[String], three: Array[Int]) diff --git a/src/test/scala/com/codahale/jerkson/tests/FancyTypeSupportSpec.scala b/src/test/scala/com/codahale/jerkson/tests/FancyTypeSupportSpec.scala deleted file mode 100644 index 9d94e74..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/FancyTypeSupportSpec.scala +++ /dev/null @@ -1,31 +0,0 @@ -package com.codahale.jerkson.tests - -import java.net.URI -import com.codahale.simplespec.Spec -import org.junit.Test -import com.codahale.jerkson.Json._ -import java.util.UUID - -class FancyTypeSupportSpec extends Spec { - class `A URI` { - @Test def `generates a JSON string` = { - generate(new URI("http://example.com/resource?query=yes")).must(be("\"http://example.com/resource?query=yes\"")) - } - - @Test def `is parsable from a JSON string` = { - parse[URI]("\"http://example.com/resource?query=yes\"").must(be(new URI("http://example.com/resource?query=yes"))) - } - } - - class `A UUID` { - val uuid = UUID.fromString("a62047e4-bfb5-4d71-aad7-1a6b338eee63") - - @Test def `generates a JSON string` = { - generate(uuid).must(be("\"a62047e4-bfb5-4d71-aad7-1a6b338eee63\"")) - } - - @Test def `is parsable from a JSON string` = { - parse[UUID]("\"a62047e4-bfb5-4d71-aad7-1a6b338eee63\"").must(be(uuid)) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/ImmutableCollectionSupportSpec.scala b/src/test/scala/com/codahale/jerkson/tests/ImmutableCollectionSupportSpec.scala deleted file mode 100644 index 23e1db8..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/ImmutableCollectionSupportSpec.scala +++ /dev/null @@ -1,285 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.simplespec.Spec -import com.codahale.jerkson.Json._ -import scala.collection.immutable._ -import com.codahale.jerkson.ParsingException -import org.junit.{Ignore, Test} - -class ImmutableCollectionSupportSpec extends Spec { - class `An immutable.Seq[Int]` { - @Test def `generates a JSON array of ints` = { - generate(Seq(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Seq[Int]]("[1,2,3]").must(be(Seq(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Seq[Int]]("[]").must(be(Seq.empty[Int])) - } - } - - class `An immutable.List[Int]` { - @Test def `generates a JSON array of ints` = { - generate(List(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[List[Int]]("[1,2,3]").must(be(List(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[List[Int]]("[]").must(be(List.empty[Int])) - } - } - - class `An immutable.IndexedSeq[Int]` { - @Test def `generates a JSON array of ints` = { - generate(IndexedSeq(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[IndexedSeq[Int]]("[1,2,3]").must(be(IndexedSeq(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[IndexedSeq[Int]]("[]").must(be(IndexedSeq.empty[Int])) - } - } - - class `An immutable.TreeSet[Int]` { - @Test def `generates a JSON array` = { - generate(TreeSet(1)).must(be("[1]")) - } - - // TODO: 6/1/11 -- figure out how to deserialize TreeSet instances - - /** - * I think all this would take is a mapping from Class[_] to Ordering, which - * would need to have hard-coded the various primitive types, and then add - * support for Ordered and Comparable classes. Once we have the Ordering, - * we can pass it in manually to a builder. - */ - - @Ignore @Test def `is parsable from a JSON array of ints` = { - parse[TreeSet[Int]]("[1,2,3]").must(be(TreeSet(1, 2, 3))) - } - - @Ignore @Test def `is parsable from an empty JSON array` = { - parse[TreeSet[Int]]("[]").must(be(TreeSet.empty[Int])) - } - } - - class `An immutable.HashSet[Int]` { - @Test def `generates a JSON array` = { - generate(HashSet(1)).must(be("[1]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[HashSet[Int]]("[1,2,3]").must(be(HashSet(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[HashSet[Int]]("[]").must(be(HashSet.empty[Int])) - } - } - - class `An immutable.BitSet` { - @Test def `generates a JSON array` = { - generate(BitSet(1)).must(be("[1]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[BitSet]("[1,2,3]").must(be(BitSet(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[BitSet]("[]").must(be(BitSet.empty)) - } - } - - class `An immutable.TreeMap[String, Int]` { - @Test def `generates a JSON object` = { - generate(TreeMap("one" -> 1)).must(be("""{"one":1}""")) - } - - // TODO: 6/1/11 -- figure out how to deserialize TreeMap instances - - /** - * I think all this would take is a mapping from Class[_] to Ordering, which - * would need to have hard-coded the various primitive types, and then add - * support for Ordered and Comparable classes. Once we have the Ordering, - * we can pass it in manually to a builder. - */ - - @Ignore @Test def `is parsable from a JSON object with int field values` = { - parse[TreeMap[String, Int]]("""{"one":1}""").must(be(TreeMap("one" -> 1))) - } - - @Ignore @Test def `is parsable from an empty JSON object` = { - parse[TreeMap[String, Int]]("{}").must(be(TreeMap.empty[String, Int])) - } - } - - class `An immutable.HashMap[String, Int]` { - @Test def `generates a JSON object` = { - generate(HashMap("one" -> 1)).must(be("""{"one":1}""")) - } - - @Test def `is parsable from a JSON object with int field values` = { - parse[HashMap[String, Int]]("""{"one":1}""").must(be(HashMap("one" -> 1))) - } - - @Test def `is parsable from an empty JSON object` = { - parse[HashMap[String, Int]]("{}").must(be(HashMap.empty[String, Int])) - } - } - - class `An immutable.HashMap[String, Any]` { - @Test def `generates a JSON object` = { - generate(HashMap[String, Any]("one" -> 1)).must(be("""{"one":1}""")) - } - - @Test def `is parsable from a JSON object with int field values` = { - parse[HashMap[String, Any]]("""{"one":1}""").must(be(HashMap("one" -> 1))) - } - - @Test def `is parsable from an empty JSON object` = { - parse[HashMap[String, Any]]("{}").must(be(HashMap.empty[String, Any])) - } - - @Test def `is not parsable from an empty JSON object in a JSON array` = { - evaluating { - parse[HashMap[String, Any]]("[{}]") - }.must(throwA[ParsingException]) - } - } - - class `An immutable.Map[Int, String]` { - @Test def `generates a JSON object` = { - generate(Map(1 -> "one")).must(be("""{"1":"one"}""")) - } - - @Test def `is parsable from a JSON object with decimal field names and string field values` = { - parse[Map[Int, String]]("""{"1":"one"}""").must(be(Map(1 -> "one"))) - } - - @Test def `is not parsable from a JSON object with non-decimal field names` = { - evaluating { - parse[Map[Int, String]]("""{"one":"one"}""") - }.must(throwA[ParsingException]) - } - - @Test def `is parsable from an empty JSON object` = { - parse[Map[Int, String]]("{}").must(be(Map.empty[Int, String])) - } - } - - class `An immutable.Map[Int, Any]` { - @Test def `is not parsable from an empty JSON object in a JSON array` = { - evaluating { - parse[Map[Int, Any]]("[{}]") - }.must(throwA[ParsingException]) - } - } - - class `An immutable.IntMap[Any]` { - @Test def `is not parsable from an empty JSON object in a JSON array` = { - evaluating { - parse[IntMap[Any]]("[{}]") - }.must(throwA[ParsingException]) - } - } - - class `An immutable.LongMap[Any]` { - @Test def `is not parsable from an empty JSON object in a JSON array` = { - evaluating { - parse[LongMap[Any]]("[{}]") - }.must(throwA[ParsingException]) - } - } - - class `An immutable.Map[Long, Any]` { - @Test def `is not parsable from an empty JSON object in a JSON array` = { - evaluating { - parse[Map[Long, Any]]("[{}]") - }.must(throwA[ParsingException]) - } - } - - class `An immutable.Map[Long, String]` { - @Test def `generates a JSON object` = { - generate(Map(1L -> "one")).must(be("""{"1":"one"}""")) - } - - @Test def `is parsable from a JSON object with decimal field names and string field values` = { - parse[Map[Long, String]]("""{"1":"one"}""").must(be(Map(1L -> "one"))) - } - - @Test def `is not parsable from a JSON object with non-decimal field names` = { - evaluating { - parse[Map[Long, String]]("""{"one":"one"}""") - }.must(throwA[ParsingException]) - } - - @Test def `is parsable from an empty JSON object` = { - parse[Map[Long, String]]("{}").must(be(Map.empty[Long, String])) - } - } - - class `An immutable.IntMap[String]` { - @Test def `generates a JSON object` = { - generate(IntMap(1 -> "one")).must(be("""{"1":"one"}""")) - } - - @Test def `is parsable from a JSON object with decimal field names and string field values` = { - parse[IntMap[String]]("""{"1":"one"}""").must(be(IntMap(1 -> "one"))) - } - - @Test def `is not parsable from a JSON object with non-decimal field names` = { - evaluating { - parse[IntMap[String]]("""{"one":"one"}""") - }.must(throwA[ParsingException]) - } - - @Test def `is parsable from an empty JSON object` = { - parse[IntMap[String]]("{}").must(be(IntMap.empty[String])) - } - } - - class `An immutable.LongMap[String]` { - @Test def `generates a JSON object` = { - generate(LongMap(1L -> "one")).must(be("""{"1":"one"}""")) - } - - @Test def `is parsable from a JSON object with int field names and string field values` = { - parse[LongMap[String]]("""{"1":"one"}""").must(be(LongMap(1L -> "one"))) - } - - @Test def `is not parsable from a JSON object with non-decimal field names` = { - evaluating { - parse[LongMap[String]]("""{"one":"one"}""") - }.must(throwA[ParsingException]) - } - - @Test def `is parsable from an empty JSON object` = { - parse[LongMap[String]]("{}").must(be(LongMap.empty)) - } - } - - class `An immutable.Queue[Int]` { - @Test def `generates a JSON array` = { - generate(Queue(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Queue[Int]]("[1,2,3]").must(be(Queue(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Queue[Int]]("[]").must(be(Queue.empty)) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/JValueSpec.scala b/src/test/scala/com/codahale/jerkson/tests/JValueSpec.scala deleted file mode 100644 index 6759a33..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/JValueSpec.scala +++ /dev/null @@ -1,54 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.jerkson.Json._ -import com.codahale.jerkson.AST._ -import com.codahale.simplespec.Spec -import org.junit.Test - -class JValueSpec extends Spec { - class `Selecting single nodes` { - @Test def `returns None with primitives` = { - (parse[JValue]("8") \ "blah").must(be(JNull)) - } - - @Test def `returns None on nonexistent fields` = { - (parse[JValue]("{\"one\": \"1\"}") \ "two").must(be(JNull)) - } - - @Test def `returns a JValue with an existing field` = { - (parse[JValue]("{\"one\": \"1\"}") \ "one").must(be(JString("1"))) - } - } - - class `Selecting array members` { - @Test def `returns None with primitives` = { - (parse[JValue]("\"derp\"").apply(0)).must(be(JNull)) - } - - @Test def `returns None on out of bounds` = { - (parse[JValue]("[0, 1, 2, 3]").apply(4)).must(be(JNull)) - } - - @Test def `returns a JValue` = { - (parse[JValue]("[0, 1, 2, 3]").apply(2)).must(be(JInt(2))) - } - } - - class `Deep selecting` { - @Test def `returns Nil with primitives` = { - (parse[JValue]("0.234") \\ "herp").must(be(empty)) - } - - @Test def `returns Nil on nothing found` = { - (parse[JValue]("{\"one\": {\"two\" : \"three\"}}") \\ "four").must(be(empty)) - } - - @Test def `returns single leaf nodes` = { - (parse[JValue]("{\"one\": {\"two\" : \"three\"}}") \\ "two").must(be(Seq(JString("three")))) - } - - @Test def `should return multiple leaf nodes` = { - (parse[JValue]("{\"one\": {\"two\" : \"three\"}, \"four\": {\"two\" : \"five\"}}") \\ "two").must(be(Seq(JString("three"),JString("five")))) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/MutableCollectionSupportSpec.scala b/src/test/scala/com/codahale/jerkson/tests/MutableCollectionSupportSpec.scala deleted file mode 100644 index f68cb06..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/MutableCollectionSupportSpec.scala +++ /dev/null @@ -1,189 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.simplespec.Spec -import com.codahale.jerkson.Json._ -import scala.collection.mutable._ -import com.codahale.jerkson.ParsingException -import org.junit.Test - -class MutableCollectionSupportSpec extends Spec { - class `A mutable.ResizableArray[Int]` { - @Test def `generates a JSON array of ints` = { - generate(ResizableArray(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[ResizableArray[Int]]("[1,2,3]").must(be(ResizableArray(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[ResizableArray[Int]]("[]").must(be(ResizableArray.empty[Int])) - } - } - - class `A mutable.ArraySeq[Int]` { - @Test def `generates a JSON array of ints` = { - generate(ArraySeq(1, 2, 3)).must(be("[1,2,3]")) - } - - - @Test def `is parsable from a JSON array of ints` = { - parse[ArraySeq[Int]]("[1,2,3]").must(be(ArraySeq(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[ArraySeq[Int]]("[]").must(be(ArraySeq.empty[Int])) - } - } - - class `A mutable.MutableList[Int]` { - private val xs = new MutableList[Int] - xs ++= List(1, 2, 3) - - @Test def `generates a JSON array` = { - generate(xs).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[MutableList[Int]]("[1,2,3]").must(be(xs)) - } - - @Test def `is parsable from an empty JSON array` = { - parse[MutableList[Int]]("[]").must(be(new MutableList[Int]())) - } - } - - class `A mutable.Queue[Int]` { - @Test def `generates a JSON array` = { - generate(Queue(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[Queue[Int]]("[1,2,3]").must(be(Queue(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[Queue[Int]]("[]").must(be(new Queue[Int]())) - } - } - - class `A mutable.ListBuffer[Int]` { - @Test def `generates a JSON array` = { - generate(ListBuffer(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[ListBuffer[Int]]("[1,2,3]").must(be(ListBuffer(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[ListBuffer[Int]]("[]").must(be(ListBuffer.empty[Int])) - } - } - - class `A mutable.ArrayBuffer[Int]` { - @Test def `generates a JSON array` = { - generate(ArrayBuffer(1, 2, 3)).must(be("[1,2,3]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[ArrayBuffer[Int]]("[1,2,3]").must(be(ArrayBuffer(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[ArrayBuffer[Int]]("[]").must(be(ArrayBuffer.empty[Int])) - } - } - - class `A mutable.BitSet` { - @Test def `generates a JSON array` = { - generate(BitSet(1)).must(be("[1]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[BitSet]("[1,2,3]").must(be(BitSet(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[BitSet]("[]").must(be(BitSet.empty)) - } - } - - class `A mutable.HashSet[Int]` { - @Test def `generates a JSON array` = { - generate(HashSet(1)).must(be("[1]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[HashSet[Int]]("[1,2,3]").must(be(HashSet(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[HashSet[Int]]("[]").must(be(HashSet.empty[Int])) - } - } - - class `A mutable.LinkedHashSet[Int]` { - @Test def `generates a JSON array` = { - generate(LinkedHashSet(1)).must(be("[1]")) - } - - @Test def `is parsable from a JSON array of ints` = { - parse[LinkedHashSet[Int]]("[1,2,3]").must(be(LinkedHashSet(1, 2, 3))) - } - - @Test def `is parsable from an empty JSON array` = { - parse[LinkedHashSet[Int]]("[]").must(be(LinkedHashSet.empty[Int])) - } - } - - class `A mutable.Map[String, Int]` { - @Test def `generates a JSON object` = { - generate(Map("one" -> 1)).must(be("""{"one":1}""")) - } - - @Test def `is parsable from a JSON object with int field values` = { - parse[Map[String, Int]]("""{"one":1}""").must(be(Map("one" -> 1))) - } - - @Test def `is parsable from an empty JSON object` = { - parse[Map[String, Int]]("{}").must(be(Map.empty[String, Int])) - } - } - - class `A mutable.Map[String, Any]` { - @Test def `is not parsable from an empty JSON object in a JSON array` = { - evaluating { - parse[Map[String, Any]]("[{}]") - }.must(throwA[ParsingException]) - } - } - - class `A mutable.HashMap[String, Int]` { - @Test def `generates a JSON object` = { - generate(HashMap("one" -> 1)).must(be("""{"one":1}""")) - } - - @Test def `is parsable from a JSON object with int field values` = { - parse[HashMap[String, Int]]("""{"one":1}""").must(be(HashMap("one" -> 1))) - } - - @Test def `is parsable from an empty JSON object` = { - parse[HashMap[String, Int]]("{}").must(be(HashMap.empty[String, Int])) - } - } - - class `A mutable.LinkedHashMap[String, Int]` { - @Test def `generates a JSON object` = { - generate(LinkedHashMap("one" -> 1)).must(be("""{"one":1}""")) - } - - @Test def `is parsable from a JSON object with int field values` = { - parse[LinkedHashMap[String, Int]]("""{"one":1}""").must(be(LinkedHashMap("one" -> 1))) - } - - @Test def `is parsable from an empty JSON object` = { - parse[LinkedHashMap[String, Int]]("{}").must(be(LinkedHashMap.empty[String, Int])) - } - } -} diff --git a/src/test/scala/com/codahale/jerkson/tests/StreamingSpec.scala b/src/test/scala/com/codahale/jerkson/tests/StreamingSpec.scala deleted file mode 100644 index 1eb1b73..0000000 --- a/src/test/scala/com/codahale/jerkson/tests/StreamingSpec.scala +++ /dev/null @@ -1,23 +0,0 @@ -package com.codahale.jerkson.tests - -import com.codahale.jerkson.Json._ -import java.io.ByteArrayInputStream -import com.codahale.simplespec.Spec -import org.junit.Test - -class StreamingSpec extends Spec { - class `Parsing a stream of objects` { - val json = """[ - {"id":1, "name": "Coda"}, - {"id":2, "name": "Niki"}, - {"id":3, "name": "Biscuit"}, - {"id":4, "name": "Louie"} - ]""" - - @Test def `returns an iterator of stream elements` = { - stream[CaseClass](new ByteArrayInputStream(json.getBytes)).toList - .must(be(CaseClass(1, "Coda") :: CaseClass(2, "Niki") :: - CaseClass(3, "Biscuit") :: CaseClass(4, "Louie") :: Nil)) - } - } -} From 54a3d881bb69c0174cb2179e26294611d865e1d1 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 20:14:30 -0700 Subject: [PATCH 13/18] make readme for fork --- README.md | 123 ++++++++++++------------------------------------------ 1 file changed, 27 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index 4886ffc..8f935d6 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,30 @@ -Jerkson -------- - -*Because I think you should use JSON.* - -Jerkson is a Scala wrapper for [Jackson](http://jackson.codehaus.org/) which -brings Scala's ease-of-use to Jackson's features. - - -Requirements ------------- - -* Scala 2.8.2 or 2.9.1 -* Jackson 1.9.x - - -Setting Up Your Project ------------------------ - -Go ahead and add Jerkson as a dependency: - -```xml - - - repo.codahale.com - http://repo.codahale.com - - - - +# Jerkson for Scala 2.10 # + +[Jerkson](https://github.com/codahale/jerkson) has only been published for +Scala versions as high as 2.9.1. + +## Differences from upstream Jerkson ## +- This repo uses sbt not Maven. +- Tests have been deleted, since sbt cannot run + [simplespec](https://github.com/SimpleFinance/simplespec) tests. +- Minor tweaks to get compilation in 2.10. + +## Install ## +- This version of Jerkson is hosted on +[Maven Central](http://central.maven.org/maven2/com/cloudphysics/). +- From sbt: + ```scala + libraryDependencies += "com.cloudphysics" %% "jerkson" % "0.5.1" + ``` +- From Maven: + ```xml - com.codahale - jerkson_${scala.version} - 0.5.0 + com.cloudphysics + jerkson_2.10 + 0.5.1 - -``` - - -Parsing JSON ------------- - -```scala -import com.codahale.jerkson.Json._ - -// Parse JSON arrays -parse[List[Int]]("[1,2,3]") //=> List(1,2,3) - -// Parse JSON objects -parse[Map[String, Int]]("""{"one":1,"two":2}""") //=> Map("one"->1,"two"->2) - -// Parse JSON objects as case classes -// (Parsing case classes isn't supported in the REPL.) -case class Person(id: Long, name: String) -parse[Person]("""{"id":1,"name":"Coda"}""") //=> Person(1,"Coda") - -// Parse streaming arrays of things -for (person <- stream[Person](inputStream)) { - println("New person: " + person) -} -``` - -For more examples, check out the [specs](https://github.com/codahale/jerkson/blob/master/src/test/scala/com/codahale/jerkson/tests/). - - -Generating JSON ---------------- - -```scala -// Generate JSON arrays -generate(List(1, 2, 3)) //=> [1,2,3] - -// Generate JSON objects -generate(Map("one"->1, "two"->"dos")) //=> {"one":1,"two":"dos"} -``` - -For more examples, check out the [specs](https://github.com/codahale/jerkson/blob/master/src/test/scala/com/codahale/jerkson/tests/). - - -Handling `snake_case` Field Names -================================= - -```scala -case class Person(firstName: String, lastName: String) - -@JsonSnakeCase -case class Snake(firstName: String, lastName: String) - -generate(Person("Coda", "Hale")) //=> {"firstName": "Coda","lastName":"Hale"} -generate(Snake("Windey", "Mover")) //=> {"first_name": "Windey","last_name":"Mover"} -``` - - -License -------- - -Copyright (c) 2010-2011 Coda Hale + ``` -Published under The MIT License, see LICENSE +## Contact ## +Repo maintained by [Yuvi Masory](http://yuvimasory.com). +[ymasory@gmail.com](ymasory@gmail.com) From e81f5a90bc54c631c978bb2154aadda8934ba729 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 20:17:02 -0700 Subject: [PATCH 14/18] change title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f935d6..b50e3ee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Jerkson for Scala 2.10 # +# Jerkson + Scala 2.10 + Streaming Iteration # [Jerkson](https://github.com/codahale/jerkson) has only been published for Scala versions as high as 2.9.1. From b0d2808e9d3ddacd295d065bcf6295eb204d572f Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 20:18:40 -0700 Subject: [PATCH 15/18] fix notes --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b50e3ee..1072d00 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Jerkson + Scala 2.10 + Streaming Iteration # [Jerkson](https://github.com/codahale/jerkson) has only been published for -Scala versions as high as 2.9.1. +Scala versions as high as 2.9.1 and does not support streaming iteration. ## Differences from upstream Jerkson ## -- This repo uses sbt not Maven. +- Streaming iteration is supported. +- sbt instead of Maven. - Tests have been deleted, since sbt cannot run [simplespec](https://github.com/SimpleFinance/simplespec) tests. - Minor tweaks to get compilation in 2.10. From 718863fed5d1a1593cc4b98bb8fdd5f4e750e81b Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 22:21:19 -0700 Subject: [PATCH 16/18] doc compile and publish --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 1072d00..da537af 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Scala versions as high as 2.9.1 and does not support streaming iteration. ## Differences from upstream Jerkson ## + - Streaming iteration is supported. - sbt instead of Maven. - Tests have been deleted, since sbt cannot run @@ -11,6 +12,7 @@ Scala versions as high as 2.9.1 and does not support streaming iteration. - Minor tweaks to get compilation in 2.10. ## Install ## + - This version of Jerkson is hosted on [Maven Central](http://central.maven.org/maven2/com/cloudphysics/). - From sbt: @@ -26,6 +28,19 @@ Scala versions as high as 2.9.1 and does not support streaming iteration. ``` +## Build ## + +- Just compile: + ```sh + $ cd jerkson + $ ./sbt compile + ``` +- Publish: + ```sh + $ ./sbt publish + ``` + ## Contact ## + Repo maintained by [Yuvi Masory](http://yuvimasory.com). [ymasory@gmail.com](ymasory@gmail.com) From 6289dcb7b3e126a3c9ef38917c57faa33c168e17 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 22:21:57 -0700 Subject: [PATCH 17/18] remove cross compilation and deprecation flag --- build.sbt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 22944be..0c62a17 100644 --- a/build.sbt +++ b/build.sbt @@ -20,16 +20,12 @@ scmInfo := Some( /* scala versions and options */ scalaVersion := "2.10.1" -crossScalaVersions ++= Seq( - "2.10.0" -) - // These options will be used for *all* versions. scalacOptions ++= Seq( - "-deprecation", + // "-deprecation", "-unchecked", "-encoding", "UTF-8", - "-optimise" // this option will slow your build + "-optimise" ) scalacOptions ++= Seq( @@ -37,6 +33,11 @@ scalacOptions ++= Seq( "-Yinline" ) +// javaOptions ++= Seq( +// "-Dscalac.patmat.analysisBudget=512" +// ) + + // These language flags will be used only for 2.10.x. // Uncomment those you need, or if you hate SIP-18, all of them. scalacOptions <++= scalaVersion map { sv => From 0670758767ff986d38be24b0a7047b81269f5d09 Mon Sep 17 00:00:00 2001 From: Yuvi Masory Date: Wed, 27 Mar 2013 22:30:21 -0700 Subject: [PATCH 18/18] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da537af..e21060c 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,12 @@ Scala versions as high as 2.9.1 and does not support streaming iteration. - This version of Jerkson is hosted on [Maven Central](http://central.maven.org/maven2/com/cloudphysics/). - From sbt: + ```scala - libraryDependencies += "com.cloudphysics" %% "jerkson" % "0.5.1" + libraryDependencies += "com.cloudphysics" % "jerkson_2.10" % "0.5.1" ``` - From Maven: + ```xml com.cloudphysics