[
  {
    "path": ".gitignore",
    "content": "project/boot\ntarget\n.ensime\n.ensime_lucene\nTAGS\n\\#*#\n*~\n.#*\n.lib\n.history\n.*.swp\n.idea\n.idea/*\n.idea_modules\n.DS_Store\n.cache\n.settings\n.classpath\n.project\n\n"
  },
  {
    "path": ".jvmopts",
    "content": "# see https://weblogs.java.net/blog/kcpeppe/archive/2013/12/11/case-study-jvm-hotspot-flags\n-Dfile.encoding=UTF8\n-Xms2G\n-Xmx4G\n-Xss6M\n-XX:MaxPermSize=512M\n-XX:ReservedCodeCacheSize=250M\n-XX:+TieredCompilation\n-XX:-UseGCOverheadLimit\n# effectively adds GC to Perm space\n-XX:+CMSClassUnloadingEnabled\n# must be enabled for CMSClassUnloadingEnabled to work\n-XX:+UseConcMarkSweepGC\n"
  },
  {
    "path": ".scalafmt",
    "content": "--maxColumn 120"
  },
  {
    "path": ".travis.yml",
    "content": "language: scala\nservices:\n  - docker\nsudo: required\ngit:\n  depth: 50\nscala:\n- 2.10.6\n- 2.11.8\n- 2.12.1\n\njdk:\n- oraclejdk8\nscript:\n- if [[ \"$TRAVIS_PULL_REQUEST\" == \"false\" && \"$TRAVIS_BRANCH\" == \"dev\" && $(cat version.sbt) =~ \"-SNAPSHOT\" ]] ; then sbt ++$TRAVIS_SCALA_VERSION test publish gitSnapshots publish ; else sbt ++$TRAVIS_SCALA_VERSION test ; fi\nnotifications:\n  webhooks:\n    urls:\n    - https://webhooks.gitter.im/e/NX9T51sqZ7a2U3zE8Thm\n    - https://webhooks.gitter.im/e/42e709a53fb8e39472d3\n    on_success: always\n    on_failure: always\n    on_start: true\nenv:\n  global:\n  - secure: DyrwS40Re2KfnuEMXNDkrWHDLeXzBsM1pCUBWy8ApexKEwI2SuO4at2th6yC8QvvLMmOkvDkheRVg1yENYTtUjerx4HATEoQcQ6RFjAfw4RmQLuUYWZFomGJ/q0KQ2EZmCCljbXM1q9vnhETuCgOcAMS5IRYOJf0EPYPFNArt8A=\n  - secure: c5OZn0AALmuPiZz8VYDqUNfJzxoUJ6dO/i1J3QQ/b9DQd2gWkdpAvpgqLX7SdyL26IssWPMJ4Zc6utMd8ONLrCdoPaFJr1arflwpSuP+tadxJEl2H0EBjSL2WFsce8j7HbhwGtoVwee2bKJ5gAMilInQXSoMqm9b5EBIN0JA2Ks=\n\n\ncache:\n  directories:\n  - $HOME/.sbt/0.13/dependency\n  - $HOME/.sbt/boot/\n  - $HOME/.sbt/launchers\n  - $HOME/.ivy2/cache\n\nbefore_cache:\n  - du -h -d 1 $HOME/.ivy2/cache\n  - du -h -d 2 $HOME/.sbt/\n  - find $HOME/.sbt -name \"*.lock\" -type f -delete\n  - find $HOME/.ivy2/cache -name \"ivydata-*.properties\" -type f -delete"
  },
  {
    "path": "README.md",
    "content": "# Rapture\n\n[![Build Status](https://travis-ci.org/propensive/rapture.png?branch=dev)](https://travis-ci.org/propensive/rapture)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.propensive/rapture-core_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.propensive/rapture-core_2.11)\n[![License](http://img.shields.io/:license-Apache%202-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)\n[![Gitter](https://img.shields.io/badge/gitter-join%20chat-green.svg)](https://gitter.im/propensive/rapture)\n[![Javadocs](https://javadoc.io/badge/com.propensive/rapture_2.12.svg)](https://javadoc.io/doc/com.propensive/rapture-core_2.12)\n\nRapture is an evolving collection of *useful* libraries for solving common,\neveryday programming tasks, using advanced features of Scala to offer better\ntype-safety through powerful APIs that all Scala developers, beginners and\nadvanced users, should find intuitive.\n\nRapture consists of a number of modules, the most notable of which are:\n\n - Core (`core`) — a library of common utilities for other projects, notably\n   *modes* and the `Result` type\n - [JSON](doc/json.md) (`json`) — comprehensive support for working with JSON\n   data\n - XML (`xml`) — comprehensive, but experimental, support for working with XML\n   data\n - I/O (`io`) — I/O (network, filesystem) functionality and infrastructure\n - I18n (`i18n`) — simple, typesafe representation of internationalized strings\n - CLI (`cli`) — support for working with command-line applications and shell\n   interaction\n\n# Themes in Rapture\n\nThe Rapture modules share a common philosophy that has evolved over time and\nexperience. Here are a few of the philosophical themes crosscutting all of the\nRapture modules.\n\n - A primary goal of intuitive, readable APIs and minimal code repetition\n - Extreme type-safety, with a goal to reduce the surface area of code exposed\n   to runtime exceptions\n - Thoroughly typeclass-driven design, for extensibility\n - Fearless exploitation of all Scala features, where (but only where) it is\n   appropriate\n - Agnostic support for multiple, alternative implementations of many\n   operations with pluggable backends\n - Extensive, but principled, usage of implicits to configure and constrain\n   operations\n - Support for modes in most APIs; the ability to change how failures are\n   handled through return types\n\n## Availability\n\nSnapshots of Rapture are available for Scala 2.10 and 2.11 under the *Apache\n2.0 License* in the [Sonatype Snapshots\nrepository](https://oss.sonatype.org/content/repositories/snapshots/com/propensive/),\nwith group ID `com.propensive` and artifact ID `rapture-[module]`, where module\nis the name of the module, as taken from the list above.\n\nDevelopment work to get most Rapture modules working on\n[Scala.JS](htp://www.scala-js.org/) is ongoing.\n\nYou can build and run Rapture locally by cloning this repository and running\n`sbt publishLocal`.\n\n## Contributing\n\nRapture openly welcomes contributions! We would love to receive pull requests\nof bugfixes and enhancements from other developers. To avoid potential wasted\neffort, bugs should first be reported on the Github issue tracker, and it's\nnormally a good idea to talk about enhancements on the [Gitter\nchannel](https://gitter.im/propensive/rapture) before embarking on any\ndevelopment.\n\nAlternatively, just send Jon Pretty\n([@propensive](https://twitter.com/propensive/)) a tweet to start a\nconversation.\n\nCurrent contributors include:\n\n - Jon Pretty\n - Raúl Raja Martínez\n - Alistair Johnson\n\n## Documentation\n\nRapture's documentation is currently sparse, though we are working to improve\nthis.\n\n"
  },
  {
    "path": "base/shared/src/main/scala/Dummy.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n"
  },
  {
    "path": "base/shared/src/main/scala_2.10/compat.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.base\n\nimport scala.reflect._\nimport macros._\n\nobject `package` {\n  type BlackboxContext = Context\n  type WhiteboxContext = Context\n\n  lazy val compatibility = new Compat210()\n}\n\nclass Compat210() {\n  def termName(c: Context, s: String) = c.universe.newTermName(s)\n  def typeName(c: Context, s: String) = c.universe.newTypeName(s)\n  def constructor(c: Context) = c.universe.nme.CONSTRUCTOR\n  def wildcard(c: Context) = c.universe.nme.WILDCARD\n  def typeIntersection(c: Context)(xs: List[c.universe.Type]) = c.universe.intersectionType(xs)\n  def paramLists(c: Context)(t: c.universe.MethodSymbol) = t.paramss\n  def normalize(c: Context)(t: c.universe.Type) = t.normalize\n  def declarations(c: Context)(t: c.universe.Type) = t.declarations\n  def declaration(c: Context)(t: c.universe.Type, n: c.universe.Name) = t.declaration(n)\n  def readLine(): String = Console.readLine()\n  def typecheck(c: Context)(s: c.Tree) = c.typeCheck(s)\n  def freshName(c: Context)(s: String) = c.fresh(s)\n  def companion(c: Context)(x: c.universe.Symbol) = x.companionSymbol\n \n  def samePosition(c: Context)(p1: c.universe.Position, p2: c.universe.Position) = p1.isDefined && p1.point == p2.point\n  \n  def enclosingDef(c: Context)(pos: c.universe.Position): Option[c.universe.Name] = {\n    import c.universe._\n    c.enclosingClass.collect { case DefDef(_, name, _, _, _, rhs) if samePosition(c)(rhs.pos, pos) => name }.headOption\n  }\n\n  def enclosingVals(c: Context)(pos: c.universe.Position, count: Int): Option[c.universe.Name] = {\n    import c.universe._\n    c.enclosingClass.collect { case ValDef(_, name, _, rhs) if samePosition(c)(rhs.pos, pos) => name }.drop(count).headOption\n  }\n}\n"
  },
  {
    "path": "base/shared/src/main/scala_2.11/compat.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.base\n\nimport scala.reflect._\nimport macros._\n\nobject `package` {\n  type BlackboxContext = blackbox.Context\n  type WhiteboxContext = whitebox.Context\n\n  lazy val compatibility = new Compat211()\n}\n\nclass Compat211() {\n  def termName[C <: blackbox.Context](c: C, s: String) = c.universe.TermName(s)\n  def typeName[C <: blackbox.Context](c: C, s: String) = c.universe.TypeName(s)\n  def constructor[C <: blackbox.Context](c: C) = c.universe.termNames.CONSTRUCTOR\n  def wildcard[C <: blackbox.Context](c: C) = c.universe.termNames.WILDCARD\n  def typeIntersection[C <: blackbox.Context](c: C)(xs: List[c.universe.Type]) =\n    c.universe.internal.intersectionType(xs)\n  def paramLists[C <: blackbox.Context](c: C)(t: c.universe.MethodSymbol) = t.paramLists\n  def normalize[C <: blackbox.Context](c: C)(t: c.universe.Type) = t.dealias\n  def declarations[C <: blackbox.Context](c: C)(t: c.universe.Type) = t.decls\n  def declaration[C <: blackbox.Context](c: C)(t: c.universe.Type, d: c.universe.Name) = t.decl(d)\n  def readLine(): String = scala.io.StdIn.readLine\n  def typecheck[C <: blackbox.Context](c: C)(t: c.Tree) = c.typecheck(t)\n  def freshName[C <: blackbox.Context](c: C)(s: String) = c.freshName(s)\n  def companion[C <: blackbox.Context](c: C)(s: c.universe.Symbol) = s.companion\n  \n  def samePosition[C <: blackbox.Context](c: C)(p1: c.universe.Position, p2: c.universe.Position) = {\n    import c.universe._\n    p1 != NoPosition && p2 != NoPosition && p1.start == p2.start\n  }\n  \n  def enclosingDef[C <: blackbox.Context](c: C)(pos: c.universe.Position): Option[c.universe.Name] =\n    Some(c.internal.enclosingOwner.asTerm.name)\n\n  def enclosingVals[C <: blackbox.Context](c: C)(pos: c.universe.Position, count: Int): Option[c.universe.Name] =\n    Some(c.internal.enclosingOwner.asTerm.name)\n}\n"
  },
  {
    "path": "base/shared/src/main/scala_2.12/compat.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.base\n\nimport scala.reflect._\nimport macros._\n\nobject `package` {\n  type BlackboxContext = blackbox.Context\n  type WhiteboxContext = whitebox.Context\n\n  lazy val compatibility = new Compat212()\n}\n\nclass Compat212() {\n  def termName[C <: blackbox.Context](c: C, s: String) = c.universe.TermName(s)\n  def typeName[C <: blackbox.Context](c: C, s: String) = c.universe.TypeName(s)\n  def constructor[C <: blackbox.Context](c: C) = c.universe.termNames.CONSTRUCTOR\n  def wildcard[C <: blackbox.Context](c: C) = c.universe.termNames.WILDCARD\n  def typeIntersection[C <: blackbox.Context](c: C)(xs: List[c.universe.Type]) =\n    c.universe.internal.intersectionType(xs)\n  def paramLists[C <: blackbox.Context](c: C)(t: c.universe.MethodSymbol) = t.paramLists\n  def normalize[C <: blackbox.Context](c: C)(t: c.universe.Type) = t.dealias\n  def declarations[C <: blackbox.Context](c: C)(t: c.universe.Type) = t.decls\n  def declaration[C <: blackbox.Context](c: C)(t: c.universe.Type, d: c.universe.Name) = t.decl(d)\n  def readLine(): String = scala.io.StdIn.readLine\n  def typecheck[C <: blackbox.Context](c: C)(t: c.Tree) = c.typecheck(t)\n  def freshName[C <: blackbox.Context](c: C)(s: String) = c.freshName(s)\n  def companion[C <: blackbox.Context](c: C)(s: c.universe.Symbol) = s.companion\n\n  def samePosition[C <: blackbox.Context](c: C)(p1: c.universe.Position, p2: c.universe.Position) = {\n    import c.universe._\n    p1 != NoPosition && p2 != NoPosition && p1.start == p2.start\n  }\n\n  def enclosingDef[C <: blackbox.Context](c: C)(pos: c.universe.Position): Option[c.universe.Name] =\n    Some(c.internal.enclosingOwner.asTerm.name)\n\n  def enclosingVals[C <: blackbox.Context](c: C)(pos: c.universe.Position, count: Int): Option[c.universe.Name] =\n    Some(c.internal.enclosingOwner.asTerm.name)\n}\n"
  },
  {
    "path": "build.sbt",
    "content": "import com.typesafe.sbt.pgp.PgpKeys.publishSigned\nimport ReleaseTransformations._\n\nenablePlugins(GitBranchPrompt)\n\nlazy val buildSettings = Seq(\n  organization := \"com.propensive\",\n  scalaVersion := \"2.12.1\",\n  crossScalaVersions := Seq(\"2.12.2\", \"2.11.8\", \"2.10.6\")\n)\n\nlazy val commonSettings = Seq(\n//  scalafmtConfig in ThisBuild := Some(file(\".scalafmt\")),\n  scalacOptions ++= Seq(\n    \"-deprecation\",\n    \"-encoding\", \"UTF-8\",\n    \"-feature\",\n    \"-unchecked\",\n    \"-Xfatal-warnings\",\n    \"-Xlint\",\n    \"-language:existentials\"\n  /*  \"-language:higherKinds\",\n    \"-language:implicitConversions\",\n    \"-language:experimental.macros\",\n    \"-Yinline-warnings\",\n    \"-Yno-adapted-args\",\n    \"-Ywarn-numeric-widen\",\n    \"-Ywarn-value-discard\",\n    \"-Xfuture\" */\n  ) ++ (CrossVersion.partialVersion(scalaVersion.value) match {\n    case Some((2, majorVersion)) if majorVersion >= 11 => Seq(\"-Ywarn-unused-import\")\n    case _             => Seq.empty\n  }),\n  scalacOptions in (Compile, console) ~= (_ filterNot (_ == \"-Ywarn-unused-import\")),\n  scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,\n  scalaJSStage in Test := FastOptStage,\n  concurrentRestrictions in Global ++= Seq(Tags.limitSum(2, Tags.CPU, Tags.Untagged), Tags.limit(Tags.Test, 1)),\n  scmInfo := Some(ScmInfo(url(\"https://github.com/propensive/rapture\"),\n    \"scm:git:git@github.com:propensive/rapture.git\"))\n) ++ scalaMacroDependencies\n\nlazy val raptureSettings = buildSettings ++ commonSettings ++ publishSettings\n\nlazy val rapture = project.in(file(\".\"))\n  .settings(moduleName := \"root\")\n  .settings(raptureSettings)\n  .settings(noPublishSettings)\n  .settings(noSourceSettings)\n  .aggregate(raptureJVM, raptureJS, raptureExtrasJVM, raptureExtrasJS)\n  .dependsOn(raptureJVM, raptureJS, raptureExtrasJVM, raptureExtrasJS)\n\nlazy val raptureJVM = project.in(file(\".raptureJVM\"))\n  .settings(moduleName := \"rapture\")\n  .settings(raptureSettings)\n  .aggregate(baseJVM, coreJVM, timeJVM, uriJVM, codecJVM, cryptoJVM, csvJVM, ioJVM, fsJVM, netJVM, httpJVM, mimeJVM, cliJVM, mailJVM, logJVM, i18nJVM, googleTranslateJVM, textJVM, latexJVM, testJVM, dataJVM, xmlJVM, jsJVM, cssJVM, currencyJVM, jsonJVM, htmlJVM, domJVM, coreScalazJVM, httpJsonJVM, java8SupportJVM, unixsocketJVM)\n  .dependsOn(baseJVM, coreJVM, timeJVM, uriJVM, codecJVM, cryptoJVM, csvJVM, ioJVM, fsJVM, netJVM, httpJVM, mimeJVM, cliJVM, mailJVM, logJVM, i18nJVM, googleTranslateJVM, textJVM, latexJVM, testJVM, dataJVM, xmlJVM, jsJVM, cssJVM, currencyJVM, jsonJVM, htmlJVM, domJVM, coreScalazJVM, httpJsonJVM, java8SupportJVMi, unixsocketJVM)\n  \nlazy val raptureJS = project.in(file(\".raptureJS\"))\n  .settings(moduleName := \"rapture\")\n  .settings(raptureSettings)\n  .aggregate(baseJS, coreJS, timeJS, uriJS, codecJS, cryptoJS, csvJS, ioJS, fsJS, netJS, httpJS, mimeJS, cliJS, mailJS, logJS, i18nJS, googleTranslateJS, textJS, latexJS, testJS, dataJS, jsonJS, htmlJS, domJS, coreScalazJS, httpJsonJS, xmlJS, jsJS, cssJS, currencyJS, java8SupportJS)\n  .dependsOn(baseJS, coreJS, timeJS, uriJS, codecJS, cryptoJS, csvJS, ioJS, fsJS, netJS, httpJS, mimeJS, cliJS, mailJS, logJS, i18nJS, googleTranslateJS, textJS, latexJS, testJS, dataJS, jsonJS, htmlJS, domJS, coreScalazJS, httpJsonJS, xmlJS, jsJS, cssJS, currencyJS, java8SupportJS)\n  .enablePlugins(ScalaJSPlugin)\n\nlazy val raptureExtras = crossProject\n  .aggregate(`core-test`, `http-jetty`, `json-circe`, `xml-stdlib`, `json-jawn`, `json-play`, `json-json4s`, `json-spray`, `json-argonaut`, `json-jackson`, `json-test`, `xml-test`, `json-lift`, `net-test`, `java8-support`)\n  .dependsOn(`core-test`, `http-jetty`, `json-circe`, `xml-stdlib`, `json-jawn`, `json-play`, `json-json4s`, `json-spray`, `json-argonaut`, `json-jackson`, `json-test`, `xml-test`, `json-lift`, `net-test`, `java8-support`)\n  .settings(moduleName := \"rapture-extras\")\n  .settings(raptureSettings:_*)\n  .settings(crossVersionSharedSources():_*)\n\nlazy val raptureExtrasJVM = raptureExtras.jvm\nlazy val raptureExtrasJS = raptureExtras.js\n\n// rapture-base\nlazy val base = crossProject\n  .settings(moduleName := \"rapture-base\")\n  .settings(raptureSettings:_*)\n  .settings(crossVersionSharedSources():_*)\n\nlazy val baseJVM = base.jvm\nlazy val baseJS = base.js\n\n// rapture-core\nlazy val core = crossProject.dependsOn(base)\n  .settings(moduleName := \"rapture-core\")\n  .settings(raptureSettings:_*)\n\nlazy val coreJVM = core.jvm\nlazy val coreJS = core.js\n\n// rapture-core-test\nlazy val `core-test` = crossProject.dependsOn(test, `core-scalaz`)\n  .settings(moduleName := \"rapture-core-test\")\n  .settings(raptureSettings:_*)\n\nlazy val coreTestJVM = `core-test`.jvm\nlazy val coreTestJS = `core-test`.js\n\n// rapture-uri\nlazy val uri = crossProject.dependsOn(core)\n  .settings(moduleName := \"rapture-uri\")\n  .settings(raptureSettings:_*)\n\nlazy val uriJVM = uri.jvm\nlazy val uriJS = uri.js\n\n// rapture-codec\nlazy val codec = crossProject.dependsOn(core)\n  .settings(moduleName := \"rapture-codec\")\n  .settings(raptureSettings:_*)\n\nlazy val codecJVM = codec.jvm\nlazy val codecJS = codec.js\n\n// rapture-crypto\nlazy val crypto = crossProject.dependsOn(core, codec)\n  .settings(moduleName := \"rapture-crypto\")\n  .settings(raptureSettings:_*)\n\nlazy val cryptoJVM = crypto.jvm\nlazy val cryptoJS = crypto.js\n\n// rapture-io\nlazy val io = crossProject.dependsOn(codec, mime, uri)\n  .settings(moduleName := \"rapture-io\")\n  .settings(raptureSettings:_*)\n\nlazy val ioJVM = io.jvm\nlazy val ioJS = io.js\n\n// rapture-mime\nlazy val mime = crossProject.dependsOn()\n  .settings(moduleName := \"rapture-mime\")\n  .settings(raptureSettings:_*)\n\nlazy val mimeJVM = mime.jvm\nlazy val mimeJS = mime.js\n\n// rapture-net\nlazy val net = crossProject.dependsOn(io)\n  .settings(moduleName := \"rapture-net\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"commons-net\" % \"commons-net\" % \"2.0\")\n\nlazy val netJVM = net.jvm\nlazy val netJS = net.js\n\n// rapture-net-test\nlazy val `net-test` = crossProject.dependsOn(net, test, json, `json-circe`)\n  .settings(moduleName := \"rapture-net-test\")\n  .settings(raptureSettings: _*)\n  .settings(\n    libraryDependencies ++= Seq(\n      \"com.spotify\" % \"docker-client\" % \"5.0.2\",\n      \"org.scalatest\" %% \"scalatest\" % \"2.2.6\"\n    )\n  )\n\nlazy val netTestJVM = `net-test`.jvm\nlazy val netTestJS = `net-test`.js\n\n// rapture-unixsocket\n// this is not a scala-js project - it may only be used on the jvm and on linux\nlazy val unixsocketJVM = (project in file(\"unixsocket/jvm\")).dependsOn(io.jvm, core.jvm, net.jvm, uri.jvm)\n  .settings(moduleName := \"rapture-unixsocket\")\n  .settings(raptureSettings: _*)\n  .settings(libraryDependencies ++= Seq(\n    \"com.kohlschutter.junixsocket\"  %   \"junixsocket-native\"        % \"2.0.4\",\n    \"com.kohlschutter.junixsocket\"  %   \"junixsocket-native-common\" % \"2.0.4\",\n    \"com.kohlschutter.junixsocket\"  %   \"junixsocket-common\"        % \"2.0.4\",\n    \"org.apache.httpcomponents\"     %   \"httpclient\"                % \"4.5.2\"\n  ))\n\n// rapture-time\nlazy val time = crossProject.dependsOn(core)\n  .settings(moduleName := \"rapture-time\")\n  .settings(raptureSettings:_*)\n\nlazy val timeJVM = time.jvm\nlazy val timeJS = time.js\n\n// rapture-http\nlazy val http = crossProject.dependsOn(net, uri, json, html, fs, log, time)\n  .settings(moduleName := \"rapture-http\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"javax.servlet\" % \"servlet-api\" % \"2.5\")\n  .settings(libraryDependencies += \"org.w3c.css\" % \"sac\" % \"1.3\")\n  .settings(libraryDependencies += \"net.sourceforge.cssparser\" % \"cssparser\" % \"0.9.20\")\n\nlazy val httpJVM = http.jvm\nlazy val httpJS = http.js\n\n// rapture-http-json\nlazy val `http-json` = crossProject.dependsOn(http, json)\n  .settings(moduleName := \"rapture-http-json\")\n  .settings(raptureSettings:_*)\n\nlazy val httpJsonJVM = `http-json`.jvm\nlazy val httpJsonJS = `http-json`.js\n\n// rapture-http-jetty\nlazy val `http-jetty` = crossProject.dependsOn(http)\n  .settings(moduleName := \"rapture-http-jetty\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"org.eclipse.jetty\" % \"jetty-servlet\" % \"7.6.10.v20130312\")\n\nlazy val httpJettyJVM = `http-jetty`.jvm\nlazy val httpJettyJS = `http-jetty`.js\n\n// rapture-fs\nlazy val fs = crossProject.dependsOn(io)\n  .settings(moduleName := \"rapture-fs\")\n  .settings(raptureSettings:_*)\n\nlazy val fsJVM = fs.jvm\nlazy val fsJS = fs.js\n\n// rapture-csv\nlazy val csv = crossProject.dependsOn(fs)\n  .settings(moduleName := \"rapture-csv\")\n  .settings(raptureSettings:_*)\n\nlazy val csvJVM = csv.jvm\nlazy val csvJS = csv.js\n\n// rapture-cli\nlazy val cli = crossProject.dependsOn(log, fs)\n  .settings(moduleName := \"rapture-cli\")\n  .settings(raptureSettings:_*)\n\nlazy val cliJVM = cli.jvm\nlazy val cliJS = cli.js\n\n// rapture-mail\nlazy val mail = crossProject.dependsOn(io, html, net)\n  .settings(moduleName := \"rapture-mail\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"javax.mail\" % \"mail\" % \"1.4\")\n\nlazy val mailJVM = mail.jvm\nlazy val mailJS = mail.js\n\n// rapture-log\nlazy val log = crossProject.dependsOn(io)\n  .settings(moduleName := \"rapture-log\")\n  .settings(raptureSettings:_*)\n\nlazy val logJVM = log.jvm\nlazy val logJS = log.js\n\n// rapture-i18n\nlazy val i18n = crossProject.dependsOn(core, test)\n  .settings(moduleName := \"rapture-i18n\")\n  .settings(raptureSettings:_*)\n\nlazy val i18nJVM = i18n.jvm\nlazy val i18nJS = i18n.js\n\n// rapture-google-translate\nlazy val `google-translate` = crossProject.dependsOn(core, net, `json-jawn`, i18n)\n  .settings(moduleName := \"rapture-google-translate\")\n  .settings(raptureSettings:_*)\n\nlazy val googleTranslateJVM = `google-translate`.jvm\nlazy val googleTranslateJS = `google-translate`.js\n\n// rapture-text\nlazy val text = crossProject.dependsOn(core)\n  .settings(moduleName := \"rapture-text\")\n  .settings(raptureSettings:_*)\n\nlazy val textJVM = text.jvm\nlazy val textJS = text.js\n\n// rapture-latex\nlazy val latex = crossProject.dependsOn(text, cli)\n  .settings(moduleName := \"rapture-latex\")\n  .settings(raptureSettings:_*)\n\nlazy val latexJVM = latex.jvm\nlazy val latexJS = latex.js\n\n// rapture-test\nlazy val test = crossProject.dependsOn(cli, fs, text)\n  .settings(moduleName := \"rapture-test\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"org.scalatest\" %% \"scalatest\" % \"3.0.1\")\nlazy val testJVM = test.jvm\nlazy val testJS = test.js\n\n// rapture-dom\nlazy val dom = crossProject.dependsOn(core)\n  .settings(moduleName := \"rapture-dom\")\n  .settings(raptureSettings:_*)\n\nlazy val domJVM = dom.jvm\nlazy val domJS = dom.js\n\n// rapture-html\nlazy val html = crossProject.dependsOn(net, mime, dom, test, js, css)\n  .settings(moduleName := \"rapture-html\")\n  .settings(raptureSettings:_*)\n\nlazy val htmlJVM = html.jvm\nlazy val htmlJS = html.js\n\n// rapture-data\nlazy val data = crossProject.dependsOn(core)\n  .settings(moduleName := \"rapture-data\")\n  .settings(raptureSettings:_*)\n\nlazy val dataJVM = data.jvm\nlazy val dataJS = data.js\n\n// rapture-xml\nlazy val xml = crossProject.dependsOn(data)\n  .settings(moduleName := \"rapture-xml\")\n  .settings(raptureSettings:_*)\n\nlazy val xmlJVM = xml.jvm\nlazy val xmlJS = xml.js\n\n// rapture-js\nlazy val js = crossProject.dependsOn(data)\n  .settings(moduleName := \"rapture-js\")\n  .settings(raptureSettings:_*)\n\nlazy val jsJVM = js.jvm\nlazy val jsJS = js.js\n\n// rapture-css\nlazy val css = crossProject.dependsOn(data, dom)\n  .settings(moduleName := \"rapture-css\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"net.sourceforge.cssparser\" % \"cssparser\" % \"0.9.20\")\n\nlazy val cssJVM = css.jvm\nlazy val cssJS = css.js\n\n// rapture-currency\nlazy val currency = crossProject.dependsOn(data)\n  .settings(moduleName := \"rapture-currency\")\n  .settings(raptureSettings:_*)\n\nlazy val currencyJVM = currency.jvm\nlazy val currencyJS = currency.js\n\n// rapture-json\nlazy val json = crossProject.dependsOn(data)\n  .settings(moduleName := \"rapture-json\")\n  .settings(raptureSettings:_*)\n\nlazy val jsonJVM = json.jvm\nlazy val jsonJS = json.js\n\n// rapture-java8-support\nlazy val `java8-support` = crossProject.dependsOn(core)\n  .settings(moduleName := \"rapture-java8-support\")\n  .settings(raptureSettings:_*)\n\nlazy val java8SupportJVM = `java8-support`.jvm\nlazy val java8SupportJS = `java8-support`.js\n\n// rapture-json-circe\nlazy val `json-circe` = crossProject.dependsOn(json)\n  .settings(moduleName := \"rapture-json-circe\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"io.circe\" %% \"circe-core\" % \"0.7.0\")\n  .settings(libraryDependencies += \"io.circe\" %% \"circe-jawn\" % \"0.7.0\")\n\nlazy val jsonCirceJVM = `json-circe`.jvm\nlazy val jsonCirceJS = `json-circe`.js\n\n// rapture-xml-stdlib\nlazy val `xml-stdlib` = crossProject.dependsOn(xml)\n  .settings(moduleName := \"rapture-xml-stdlib\")\n  .settings(raptureSettings:_*)\n\nlazy val xmlStdlibJVM = `xml-stdlib`.jvm\nlazy val xmlStdlibJS = `xml-stdlib`.js\n\n// rapture-json-jawn\nlazy val `json-jawn` = crossProject.dependsOn(json)\n  .settings(moduleName := \"rapture-json-jawn\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"org.spire-math\" %% \"jawn-parser\" % \"0.10.4\")\n  .settings(libraryDependencies += \"org.spire-math\" %% \"jawn-ast\" % \"0.10.4\")\n\nlazy val jsonJawnJVM = `json-jawn`.jvm\nlazy val jsonJawnJS = `json-jawn`.js\n\n\nlazy val playJsonDependencies: Seq[Setting[_]] = Seq(\n  libraryDependencies += (CrossVersion.partialVersion(scalaVersion.value) match {\n    case Some((2, 10)) => \"com.typesafe.play\" %% \"play-json\" % \"2.4.6\"\n    case Some((2, 11)) => \"com.typesafe.play\" %% \"play-json\" % \"2.5.3\"\n    case Some((2, 12)) => \"com.typesafe.play\" %% \"play-json\" % \"2.6.0-M1\"\n  })\n)\n\n// rapture-json-play\nlazy val `json-play` = crossProject.dependsOn(json)\n  .settings(moduleName := \"rapture-json-play\")\n  .settings(raptureSettings: _*)\n  .settings(playJsonDependencies: _*)\n\nlazy val jsonPlayJVM = `json-play`.jvm\nlazy val jsonPlayJS = `json-play`.js\n\n// rapture-json-json4s\nlazy val `json-json4s` = crossProject.dependsOn(json)\n  .settings(moduleName := \"rapture-json-json4s\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"org.json4s\" %% \"json4s-native\" % \"3.5.0\")\n\nlazy val jsonJson4sJVM = `json-json4s`.jvm\nlazy val jsonJson4sJS = `json-json4s`.js\n\n// rapture-json-spray\nlazy val `json-spray` = crossProject.dependsOn(json)\n  .settings(moduleName := \"rapture-json-spray\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"io.spray\" %% \"spray-json\" % \"1.3.3\")\n\nlazy val jsonSprayJVM = `json-spray`.jvm\nlazy val jsonSprayJS = `json-spray`.js\n\n// rapture-json-argonaut\nlazy val `json-argonaut` = crossProject.dependsOn(json)\n  .settings(moduleName := \"rapture-json-argonaut\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"io.argonaut\" %% \"argonaut\" % \"6.2-RC1\")\n\nlazy val jsonArgonautJVM = `json-argonaut`.jvm\nlazy val jsonArgonautJS = `json-argonaut`.js\n\n// rapture-json-jackson\nlazy val `json-jackson` = crossProject.dependsOn(json)\n  .settings(moduleName := \"rapture-json-jackson\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"com.fasterxml.jackson.core\" % \"jackson-databind\" % \"2.7.2\")\n\nlazy val jsonJacksonJVM = `json-jackson`.jvm\nlazy val jsonJacksonJS = `json-jackson`.js\n\n// rapture-core-scalaz\nlazy val `core-scalaz` = crossProject.dependsOn(core)\n  .settings(moduleName := \"rapture-core-scalaz\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += \"org.scalaz\" %% \"scalaz-core\" % \"7.2.8\")\n  .settings(libraryDependencies += \"org.scalaz\" %% \"scalaz-concurrent\" % \"7.2.8\")\n\nlazy val coreScalazJVM = `core-scalaz`.jvm\nlazy val coreScalazJS = `core-scalaz`.js\n\n// rapture-json-test\nlazy val `json-test` = crossProject\n  .dependsOn(`json-jawn`, `json-lift`, `json-spray`, `json-argonaut`, `json-jackson`, `json-play`, `json-json4s`, `json-circe`, `java8-support`, test)\n  .settings(moduleName := \"rapture-json-test\")\n  .settings(raptureSettings:_*)\n \nlazy val jsonTestJVM = `json-test`.jvm\nlazy val jsonTestJS = `json-test`.js\n\n// rapture-css-test\nlazy val `css-test` = crossProject.dependsOn(css, html, test)\n  .settings(moduleName := \"rapture-css-test\")\n  .settings(raptureSettings:_*)\n \nlazy val cssTestJVM = `css-test`.jvm\nlazy val cssTestJS = `css-test`.js\n\n// rapture-xml-test\nlazy val `xml-test` = crossProject.dependsOn(`xml-stdlib`, `java8-support`, test)\n  .settings(moduleName := \"rapture-xml-test\")\n  .settings(raptureSettings:_*)\n \nlazy val xmlTestJVM = `xml-test`.jvm\nlazy val xmlTestJS = `xml-test`.js\n\n// rapture-json-lift\nlazy val `json-lift` = crossProject.dependsOn(json)\n  .settings(moduleName := \"rapture-json-lift\")\n  .settings(raptureSettings:_*)\n  .settings(libraryDependencies += (CrossVersion.partialVersion(scalaVersion.value) match {\n    case Some((2, 10)) => \"net.liftweb\" %% \"lift-json\" % \"2.6.3\"\n    case Some((2, scalaMajor)) if scalaMajor >= 11 => \"net.liftweb\" %% \"lift-json\" % \"3.0.1\"\n  }))\n\nlazy val jsonLiftJVM = `json-lift`.jvm\nlazy val jsonLiftJS = `json-lift`.js\n\nlazy val publishSettings = Seq(\n  homepage := Some(url(\"http://rapture.io/\")),\n  licenses := Seq(\"Apache-2.0\" -> url(\"http://www.apache.org/licenses/LICENSE-2.0.txt\")),\n  autoAPIMappings := true,\n  publishMavenStyle := true,\n  publishArtifact in Test := false,\n  pomIncludeRepository := { _ => false },\n  publishTo := {\n    val nexus = \"https://oss.sonatype.org/\"\n    if (isSnapshot.value)\n      Some(\"snapshots\" at nexus + \"content/repositories/snapshots\")\n    else\n      Some(\"releases\"  at nexus + \"service/local/staging/deploy/maven2\")\n  },\n  pomExtra := (\n    <developers>\n      <developer>\n        <id>propensive</id>\n        <name>Jon Petty</name>\n        <url>http://github.com/propensive/rapture</url>\n      </developer>\n    </developers>\n  ),\n  releaseProcess := Seq[ReleaseStep](\n    checkSnapshotDependencies,\n    inquireVersions,\n    runTest,\n    setReleaseVersion,\n    commitReleaseVersion,\n    tagRelease,\n    publishArtifacts,\n    setNextVersion,\n    commitNextVersion,\n    ReleaseStep(action = Command.process(\"sonatypeReleaseAll\", _)),\n    pushChanges\n  ),\n  releaseCrossBuild := true,\n  releasePublishArtifactsAction := PgpKeys.publishSigned.value\n)\n\nlazy val noPublishSettings = Seq(\n  publish := (),\n  publishLocal := (),\n  publishArtifact := false\n)\n\nlazy val noSourceSettings = Seq(\n  sources in Compile := Seq(),\n  sources in Test := Seq()\n)\n\n\nimport java.io.File\n\ndef crossVersionSharedSources()  = Seq( \n (unmanagedSourceDirectories in Compile) ++= { (unmanagedSourceDirectories in Compile ).value.map {\n     dir:File => new File(dir.getPath + \"_\" + scalaBinaryVersion.value)}}\n)\n\nlazy val scalaMacroDependencies: Seq[Setting[_]] = Seq(\n  libraryDependencies += \"org.scala-lang\" % \"scala-reflect\" % scalaVersion.value,\n  libraryDependencies += \"org.scala-lang\" % \"scala-compiler\" % scalaVersion.value,\n  libraryDependencies ++= {\n    CrossVersion.partialVersion(scalaVersion.value) match {\n      // if scala 2.11+ is used, quasiquotes are merged into scala-reflect\n      case Some((2, scalaMajor)) if scalaMajor >= 11 => Seq()\n      // in Scala 2.10, quasiquotes are provided by macro paradise\n      case Some((2, 10)) =>\n        Seq(\n          compilerPlugin(\"org.scalamacros\" % \"paradise\" % \"2.1.0\" cross CrossVersion.full),\n              \"org.scalamacros\" %% \"quasiquotes\" % \"2.1.0\" cross CrossVersion.binary\n        )\n    }\n  }\n)\n\naddCommandAlias(\"gitSnapshots\", \";set version in ThisBuild := git.gitDescribedVersion.value.get + \\\"-SNAPSHOT\\\"\")\n\n// For Travis CI - see http://www.cakesolutions.net/teamblogs/publishing-artefacts-to-oss-sonatype-nexus-using-sbt-and-travis-ci\ncredentials ++= (for {\n  username <- Option(System.getenv().get(\"SONATYPE_USERNAME\"))\n  password <- Option(System.getenv().get(\"SONATYPE_PASSWORD\"))\n} yield Credentials(\"Sonatype Nexus Repository Manager\", \"oss.sonatype.org\", username, password)).toSeq\n"
  },
  {
    "path": "cli/shared/src/main/scala/rapture/cli/cli.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.cli\n\nimport rapture.io._\nimport rapture.codec._\nimport rapture.fs._\nimport rapture.core._\nimport rapture.uri._\nimport rapture.log._\nimport encodings.system._\nimport logLevels.trace._\n\nimport language.{higherKinds, implicitConversions}\nimport language.experimental.macros\nimport scala.concurrent._\nimport scala.concurrent.ExecutionContext.Implicits.global\n\nobject DebugModeConfig {\n  implicit val defaultDebugMode: DebugModeConfig = DebugModeConfig(false)\n}\n\nobject debugMode {\n  def apply(): DebugModeConfig = implicitDebugMode\n  implicit val implicitDebugMode: DebugModeConfig = DebugModeConfig(true)\n}\n\ncase class DebugModeConfig(on: Boolean)\n\nobject ShParam {\n  implicit def stringableToShParam[T: StringSerializer](t: T): ShParam =\n    ShParam(Vector(?[StringSerializer[T]].serialize(t)))\n\n  implicit def genSeqSerializer[T: StringSerializer, Coll[E] <: TraversableOnce[E]](ts: Coll[T]): ShParam =\n    ShParam(ts.map(?[StringSerializer[T]].serialize(_)).to[Vector])\n\n  implicit def processToShParam(process: Process): ShParam = ShParam(process.params)\n\n  implicit def fsUrlToShParam(fsUrl: FsUrl): ShParam = ShParam(Vector(fsUrl.elements.mkString(\"/\", \"/\", \"\")))\n}\n\ncase class ShParam(elems: Vector[String]) {\n  def asString = elems.mkString(\" \")\n}\n\nobject `package` {\n  implicit class ProcessStringContext(sc: StringContext) {\n    def sh(content: ShParam*): Process = macro CliMacros.shImplementation\n  }\n\n  object cliLogging {\n    import rapture.log.parts._\n\n    implicit val logger = Logger(uri\"file:///tmp/rapture-cli/access.log\")\n\n    implicit def implicitSpec(implicit severity: Severity, date: Date, time: Time, thread: Thread): Spec =\n      log\"\"\"$date $time $severity ${sourceFile(width = 12, Right)}:${lineNo(4)} ${thread(14)}\"\"\"\n  }\n}\n\nsealed class CliException(msg: String) extends Exception(msg)\n\ncase class ParamGetException(name: String) extends CliException(s\"Missing parameter $name\")\n\nabstract class BackgroundCliApp(implicit debugMode: DebugModeConfig) extends CliApp with Completions[Zsh with Bash] {\n\n  val shellCompleter = new Bash with Zsh {}\n\n  private var lastExitStatus = 0\n\n  override def doExit(code: Int) = lastExitStatus = code\n\n  def shutdown(): Unit = ()\n\n  override def main(args: Array[String]) = {\n    import cliLogging._\n    val appName = args(0)\n    val fifo = File.parse(s\"file:///tmp/rapture-cli/${appName}.sock\")\n    var continue = true\n    var invocation = 0\n    while (continue) {\n      val msg = fifo.slurp[Char].trim\n      msg.split(\",\").to[List].map(_.urlDecode) match {\n        case \"shutdown\" :: Nil =>\n          log.info(\"Received shutdown command\")\n          shutdown()\n          fifo.delete()\n          sys.exit(0)\n        case \"sigint\" :: file :: Nil =>\n          log.info(\"Received SIGINT for file \" + file)\n        case \"winch\" :: file :: lines :: cols :: Nil =>\n          log.info(s\"Received SIGWINCH for file $file $lines x $cols\")\n        case \"exec\" :: file :: pwd :: rest =>\n          log.info(s\"Using pwd = $pwd\")\n          val ps = new java.io.PrintStream(new java.io.FileOutputStream(new java.io.File(file)))\n          invocation += 1\n          Future {\n            try {\n              System.setOut(ps)\n              try super.run(File.parse(s\"file://$pwd\"), rest.to[Array])\n              catch {\n                case e: Throwable => if (debugMode.on) e.printStackTrace()\n              }\n            } catch {\n              case e: Throwable =>\n                if (debugMode.on) e.printStackTrace()\n            } finally ps.close()\n            val ps2 = new java.io.PrintStream(new java.io.FileOutputStream(new java.io.File(s\"$file.exit\")))\n            try {\n              ps2.println(lastExitStatus.toString)\n              ps2.flush()\n              ps2.close()\n              System.setOut(sysOut)\n            } finally ps2.close()\n          }\n        case _ =>\n      }\n    }\n  }\n}\n\ncase class ReturnEarly() extends Exception()\n\nabstract class CliApp(implicit debugMode: DebugModeConfig) {\n  private val NoOutput = new java.io.PrintStream(new java.io.OutputStream() {\n    def write(x: Int) = ()\n  })\n\n  def exit(code: Int): Unit = throw Exit(code)\n  def exec(block: => Unit): Exec = Exec((out: java.io.PrintStream) => block)\n  def exec(block: java.io.PrintStream => Unit): Exec = Exec(block)\n  val sysOut = System.out\n\n  def doExit(code: Int): Unit = sys.exit(code)\n\n  def main(args: Array[String]): Unit = run(File.parse(s\"file://${System.getenv(\"PWD\")}\"), args)\n\n  def run(pwd: FsUrl, args: Array[String]): Unit = {\n\n    val exitStatus: Exit = try {\n      Console.withOut(NoOutput) {\n        try {\n          val cmdLine: CmdLine = makeCmdLine(pwd, args.to[Vector])\n          val execution = handle(cmdLine)\n\n          if (cmdLine.completer.isEmpty) {\n            execution.exec(System.out)\n            Exit(0)\n          } else Exit(0)\n        } catch {\n          case ReturnEarly() =>\n            Exit(0)\n          case err: Throwable =>\n            Console.withOut(sysOut) {\n              println(\"Unexpected error\")\n              if (debugMode.on) err.printStackTrace()\n            }\n            throw Exit(1)\n        }\n      }\n    } catch { case err @ Exit(_) => err }\n\n    doExit(exitStatus.code)\n  }\n\n  def makeCmdLine(pwd: FsUrl, args: Vector[String]) =\n    CmdLine(pwd, args map { s =>\n      Arg(s, None, false)\n    }, None)\n\n  def handle(cmdLine: CmdLine): Exec\n}\n\ntrait Shell {\n  def makeCmdLine(pwd: FsUrl, cmdLine: Vector[String]): CmdLine =\n    CmdLine(pwd, cmdLine.map(Arg(_, None, false)), None)\n}\n\ntrait Zsh extends Shell {\n  override def makeCmdLine(pwd: FsUrl, cmdLine: Vector[String]): CmdLine = cmdLine match {\n    case \"---rapture-zsh\" +: prefix +: cursor +: cols +: \"--\" +: rest =>\n      val colWidth = cols.substring(10).toInt\n      val cur = cursor.substring(9).toInt\n      val words = if (cur >= rest.length) rest.tail :+ \"\" else rest.tail\n      val completer = Completer(prefix.substring(9).urlDecode, zshCompleter(_, colWidth))\n      CmdLine(pwd, words.zipWithIndex map {\n        case (s, idx) =>\n          Arg(s, Some(completer), cur - 2 == idx)\n      }, Some(completer))\n    case _ =>\n      super.makeCmdLine(pwd, cmdLine)\n  }\n\n  def zshCompleter(suggestions: Suggestions, colWidth: Int): Nothing = {\n    suggestions.groups.foreach { g =>\n      val cmds = Compadd(g.title, g.suggestions.keys.to[Vector], true, v => g.suggestions(v), colWidth, g.hidden)\n      cmds foreach System.out.println\n    }\n    throw ReturnEarly()\n  }\n}\n\ntrait Bash extends Shell {\n  override def makeCmdLine(pwd: FsUrl, cmdLine: Vector[String]): CmdLine = cmdLine match {\n    case \"---rapture-bash\" +: prefix +: cursor +: cols +: \"--\" +: rest =>\n      val colWidth = cols.substring(10).toInt\n      val words = if (cursor.toInt - 1 >= rest.length) rest.tail :+ \"\" else rest.tail\n      val completer = new Completer(prefix.urlDecode, bashCompleter)\n      CmdLine(pwd, words.zipWithIndex map {\n        case (s, idx) =>\n          Arg(s, Some(completer), cursor.toInt - 2 == idx)\n      }, Some(completer))\n    case _ =>\n      super.makeCmdLine(pwd, cmdLine)\n  }\n\n  def bashCompleter(suggestions: Suggestions): Nothing = {\n    System.out.println(\"Using bash\")\n    throw ReturnEarly()\n  }\n}\n\ncase class Exit(code: Int) extends Exception\ncase class Exec(exec: java.io.PrintStream => Unit)\n"
  },
  {
    "path": "cli/shared/src/main/scala/rapture/cli/glob.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.cli\n\nimport java.util.regex._\n\nobject globInterpreters {\n  /* This in an incomplete implementation as it does not support character classes enclosed\n   * by `[` and `]`.\n   */\n  object unix {\n    def apply(): GlobInterpreter = implicitGlobInterpreter\n    implicit val implicitGlobInterpreter: GlobInterpreter = new GlobInterpreter {\n      def interpret(glob: String): Pattern = {\n        val sb = new StringBuilder\n        var start = true\n        glob foreach { c =>\n          start = false\n          sb.append(c match {\n            case '*' => if (start) \"[^./][^/]*\" else \"[^/]*\"\n            case '?' => if (start) \"[^./][^/]*\" else \"[^/]*\"\n            case '/' => start = true; \"/\"\n            case esc @ ('.' | '[' | '{' | '(' | '+' | '^' | '$' | '|') => \"\\\\\" + esc\n            case other => other.toString\n          })\n        }\n        Pattern.compile(sb.toString)\n      }\n    }\n  }\n}\n\ntrait GlobInterpreter { def interpret(glob: String): Pattern }\n\ncase class Glob(globString: String)(implicit globInterpreter: GlobInterpreter) {\n  lazy val pattern: Pattern = globInterpreter.interpret(globString)\n  def matches(s: String) = pattern.matcher(s).matches\n}\n"
  },
  {
    "path": "cli/shared/src/main/scala/rapture/cli/macros.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.cli\n\nimport rapture.base._\nimport rapture.core._\n\nprivate[cli] object CliMacros {\n\n  def shImplementation(c: BlackboxContext)(content: c.Expr[ShParam]*): c.Expr[Process] = {\n    import c.universe._\n\n    val params = c.prefix.tree match {\n      case Apply(_, List(Apply(_, rawParts))) =>\n        val parts = rawParts.to[Vector].zip(content.map(_.tree).to[Vector]).flatMap {\n          case (x, y) => Vector(x, y)\n        } :+ rawParts.last\n\n        var params: Vector[c.Tree] = Vector()\n        var param: Vector[Either[String, c.Tree]] = Vector()\n        var inline: Boolean = false\n        var singleQuoted: Boolean = false\n        var doubleQuoted: Boolean = false\n        var escaped: Boolean = false\n\n        def add(chr: Char) = {\n          param =\n            if (param.isEmpty) Vector(Left(chr.toString))\n            else\n              param.last match {\n                case Right(_) =>\n                  param :+ Left(chr.toString)\n                case Left(str) =>\n                  param.init :+ Left(str + chr)\n              }\n          escaped = false\n        }\n\n        def nextParam() = if (!param.isEmpty) {\n\n          val next: c.Tree = if (inline) {\n            val strings = param.map {\n              case Left(str) =>\n                q\"$str\"\n              case Right(tr) =>\n                q\"\"\"$tr.elems.mkString(\" \")\"\"\"\n            }\n            q\"_root_.scala.Vector(_root_.scala.Vector(_root_.scala.Vector(..$strings).mkString))\"\n          } else {\n            val values = param.map {\n              case Left(str) =>\n                q\"_root_.scala.Vector($str)\"\n              case Right(tr) =>\n                q\"$tr.elems\"\n            }\n            q\"_root_.scala.Vector(..$values)\"\n          }\n\n          params = params :+ next\n          param = Vector()\n          inline = false\n        }\n\n        parts.foreach {\n          case Literal(Constant(str: String)) =>\n            str.foreach {\n              case chr if escaped =>\n                add(chr)\n              case ' ' =>\n                if (singleQuoted || doubleQuoted) add(' ') else nextParam()\n              case '\\\\' =>\n                escaped = true\n              case '\\'' if !doubleQuoted =>\n                singleQuoted = !singleQuoted\n              case '\"' if !singleQuoted =>\n                doubleQuoted = !doubleQuoted\n              case chr =>\n                add(chr)\n            }\n          case tr =>\n            inline = inline || singleQuoted || doubleQuoted\n            param = param :+ Right(tr.asInstanceOf[c.Tree])\n        }\n\n        nextParam()\n\n        if (singleQuoted || doubleQuoted) c.abort(c.enclosingPosition, \"unclosed quoted parameter\")\n        if (params.isEmpty) c.abort(c.enclosingPosition, \"no command specified\")\n\n        q\"_root_.scala.Vector(..$params).flatten.flatten\"\n    }\n\n    c.Expr(q\"\"\"new _root_.rapture.cli.Process($params)\"\"\")\n  }\n}\n"
  },
  {
    "path": "cli/shared/src/main/scala/rapture/cli/params.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.cli\n\nimport rapture.fs._\nimport rapture.core._\n\nimport annotation.tailrec\n\nimport scala.collection.immutable.ListMap\n\nimport language.higherKinds\n\nobject Optable {\n  implicit val stringOptable = new Optable[String] {\n    def name(t: String) = t\n    def description(t: String) = Vector()\n    def hidden(t: String): Boolean = false\n  }\n\n  implicit val OptOptable = new Optable[Opt] {\n    def name(t: Opt) = t.name\n    def description(t: Opt) = Vector(s\"-- ${t.description}\")\n    def hidden(t: Opt): Boolean = t.hidden\n  }\n\n  implicit val stringPairOptable = new Optable[(String, String)] {\n    def name(t: (String, String)) = t._1\n    def description(t: (String, String)) = Vector(t._2)\n    def hidden(t: (String, String)): Boolean = t._2 == \"\"\n  }\n}\n\ntrait Optable[-T] {\n  def name(t: T): String\n  def description(t: T): Vector[String]\n  def hidden(t: T): Boolean\n}\n\ncase class Opt(name: String, description: String, hidden: Boolean = false)(opts: => Opts[Opt]) {\n  def unapply(arg: Arg): Boolean = opts.unapply(arg) == Some(this)\n}\n\ncase class Opts[T: Optable](options: T*) {\n\n  private val optable = implicitly[Optable[T]]\n\n  def unapply(arg: Arg): Option[T] = {\n    val p = arg(suggester)\n    options.to[List].find(optable.name(_) == p)\n  }\n\n  def suggester: Suggester = new Suggester {\n    override def suggest(prefix: String): Suggestions =\n      Suggestions(\n          SuggestionGroup(None,\n                          options\n                            .to[Vector]\n                            .map { opt =>\n                          (optable.name(opt), optable.description(opt))\n                        }\n                            .filter(_._1 startsWith prefix)\n                            .toMap,\n                          false))\n  }\n}\n\nobject NoSuggestions extends Suggester\n\ncase class Param[+T: ParamParser](longName: String = null,\n                                  shortName: String = null,\n                                  description: String = null,\n                                  suggester: Suggester = NoSuggestions,\n                                  repeatable: Boolean = false) {\n  def parse(s: List[String]): Option[T] = implicitly[ParamParser[T]].parse(s)\n}\n\ntrait ParamParser_1 {\n  implicit val intParamParser: ParamParser[Int] = new ParamParser[Int] {\n    def parse(s: List[String]) = s.headOption.map(_.toInt)\n  }\n\n  implicit val booleanParamParser: ParamParser[Boolean] = new ParamParser[Boolean] {\n    def parse(s: List[String]): Option[Boolean] = Some(true)\n  }\n}\n\nobject ParamParser extends ParamParser_1 {\n  implicit val defaultParamParser: ParamParser[String] = new ParamParser[String] {\n    def parse(s: List[String]) = s.headOption\n  }\n\n  def of[T: ParamParser]: ParamParser[T] = implicitly[ParamParser[T]]\n}\n\ntrait ParamParser[+T] { paramParser =>\n  def parse(s: List[String]): Option[T]\n  def map[S](fn: T => S): ParamParser[S] = new ParamParser[S] {\n    def parse(s: List[String]): Option[S] = paramParser.parse(s).map(fn)\n  }\n}\n\nobject Paramable {\n  implicit def paramParamable[T]: Paramable[T, Param] = new Paramable[T, Param] {\n    def longName(p: Param[T]): String = Option(p.longName).map(\"--\" + _).getOrElse(\"\")\n    def shortName(p: Param[T]): String = Option(p.shortName).map(\"-\" + _).getOrElse(\"\")\n    def description(p: Param[T]): Vector[String] = Option(p.description).to[Vector]\n    def hidden(p: Param[T]): Boolean = false\n    def suggester(p: Param[T]): Suggester = p.suggester\n    def repeatable(p: Param[T]): Boolean = p.repeatable\n    def parse(p: Param[T], s: List[String]): Option[T] = p.parse(s)\n  }\n}\n\ntrait Paramable[T, P[_]] {\n  def longName(t: P[T]): String\n  def shortName(t: P[T]): String\n  def description(t: P[T]): Vector[String]\n  def hidden(t: P[T]): Boolean\n  def suggester(t: P[T]): Suggester\n  def repeatable(t: P[T]): Boolean\n  def parse(p: P[T], s: List[String]): Option[T]\n}\n\ncase class Params[T, P[_]](options: P[T]*)(implicit paramable: Paramable[T, P]) {\n\n  def suggester(exclusions: Set[String]): Suggester = new Suggester {\n    override def suggest(prefix: String): Suggestions = Suggestions(\n        SuggestionGroup(None, options.filterNot { opt =>\n          exclusions.contains(paramable.longName(opt).drop(2)) ||\n          exclusions.contains(paramable.shortName(opt).drop(1))\n        }.map { opt =>\n          (paramable.longName(opt), paramable.shortName(opt) +: paramable.description(opt))\n        }.filter(_._1 startsWith prefix).toMap, false),\n        SuggestionGroup(None, options.filterNot { opt =>\n          exclusions.contains(paramable.longName(opt).drop(2)) ||\n          exclusions.contains(paramable.shortName(opt).drop(1))\n        }.map { opt =>\n          paramable.shortName(opt) -> Vector()\n        }.filter(_._1 startsWith prefix).toMap, true)\n    )\n  }\n\n  private object LongOpt {\n    def unapply(arg: Arg): Option[String] =\n      if (arg.param.startsWith(\"--\")) Some(arg(suggester(Set())).drop(2)) else None\n  }\n\n  private object ShortOpt {\n    def unapply(arg: Arg): Option[String] =\n      if (arg.param.startsWith(\"-\")) Some(arg(suggester(Set())).slice(1, 2)) else None\n  }\n\n  @tailrec\n  private def organize(xs: Seq[Arg], acc: ListMap[String, List[Arg]] = ListMap()): Map[String, List[Arg]] = xs match {\n    case Seq() =>\n      acc\n    case LongOpt(dashParam) +: tail =>\n      organize(tail, acc + (dashParam -> Nil))\n    case (arg @ ShortOpt(dashParam)) +: tail =>\n      if (arg.param.length == 2) organize(tail, acc + (dashParam -> Nil))\n      else organize(arg.copy(param = \"-\" + arg.param.drop(2)) +: tail, acc + (dashParam.take(2) -> Nil))\n    case v +: tail =>\n      acc.lastOption match {\n        case Some((key, entry)) =>\n          organize(tail, acc + (key -> (entry :+ v)))\n        case None =>\n          val exclusions = acc.keys.to[Set]\n          v(suggester(exclusions))\n          organize(tail, acc)\n      }\n  }\n\n  def unapply(cmdLine: CmdLine): Option[ParamMap] =\n    Some(ParamMap(organize(cmdLine.params), cmdLine.completer))\n}\n\ncase class ParamMap(params: Map[String, List[Arg]], completer: Option[Completer]) {\n\n  def get[T, P[_]](param: P[T], suggesters: Suggester*)(implicit paramable: Paramable[T, P]): Option[T] = {\n    params.find {\n      case (k, v) =>\n        k == implicitly[Paramable[T, P]]\n          .longName(param)\n          .substring(2) || k == implicitly[Paramable[T, P]].shortName(param).substring(1)\n    }.flatMap {\n      case (_, args) =>\n        val values = suggesters padTo (args.length, NoSuggestions) zip args map {\n          case (suggester, arg) => arg(suggester)\n        }\n        paramable.parse(param, values.to[List])\n    }\n  }\n\n  def apply[T, P[_]](param: P[T], suggesters: Suggester*)(implicit paramable: Paramable[T, P]): T =\n    get(param, suggesters: _*).getOrElse {\n      if (completer.isDefined) null.asInstanceOf[T] else throw ParamGetException(paramable.longName(param))\n    }\n}\n\nobject -- {\n  def unapply(cmdLine: CmdLine): Option[(CmdLine, CmdLine)] = {\n    val left = cmdLine.params.takeWhile(_.param != \"--\")\n    Some(\n        if (cmdLine.params.length == left.length) (cmdLine, CmdLine(cmdLine.pwd, Vector(), cmdLine.completer))\n        else\n          (\n              CmdLine(cmdLine.pwd, left, cmdLine.completer),\n              CmdLine(cmdLine.pwd, cmdLine.params.drop(left.length + 1), cmdLine.completer)\n          )\n    )\n  }\n}\n\ncase class Arg(param: String, completer: Option[Completer], current: Boolean) {\n  def apply(suggester: Suggester) = completer match {\n    case Some(c) if current =>\n      c.process(suggester.suggest(c.prefix))\n    case _ => param\n  }\n}\n\ncase class CmdLine(pwd: FsUrl, params: Vector[Arg], completer: Option[Completer])\n    extends collection.SeqLike[Arg, CmdLine] {\n\n  def seq = params\n  def apply(idx: Int) = params(idx)\n  def length = params.length\n  def iterator: Iterator[Arg] = params.iterator\n  def newBuilder: collection.mutable.Builder[Arg, CmdLine] =\n    new collection.mutable.Builder[Arg, CmdLine] {\n      var vect: Vector[Arg] = Vector()\n      def clear(): Unit = vect = Vector()\n      def result(): CmdLine = CmdLine(pwd, vect, completer)\n      def +=(elem: Arg) = {\n        vect = vect :+ elem\n        this\n      }\n    }\n\n  override def toString =\n    params.map {\n      case Arg(p, _, false) => p\n      case Arg(p, _, true) => completer.get.prefix + \"^\" + p.drop(completer.get.prefix.length + 1)\n    }.mkString(\" \")\n}\n\nclass Suggester { def suggest(prefix: String): Suggestions = Suggestions() }\nobject Suggestions {\n  def from[T](it: Iterable[T])(fn: T => String, fns: (T => Any)*) = new Suggester {\n    override def suggest(prefix: String) =\n      Suggestions(SuggestionGroup(None, it.map { e =>\n        fn(e) -> ((if (fns.isEmpty) \"\" else \"--\") +: fns.to[Vector].map(_ (e).toString))\n      }.filter(_._1.startsWith(prefix)).toMap, false))\n  }\n\n  /*def from[T](fromPrefix: String => Iterable[T])(fn: T => String, fns: (T => Any)*) = new Suggester {\n    override def suggest(prefix: String) = Suggestions(SuggestionGroup(None,\n      fromPrefix(prefix).map { e =>\n        fn(e) -> ((if(fns.isEmpty) \"\" else \"--\") +: fns.to[Vector].map(_(e).toString))\n      }.toMap, false))\n  }*/\n}\ncase class Suggestions(groups: SuggestionGroup*)\ncase class SuggestionGroup(title: Option[String], suggestions: Map[String, Vector[String]], hidden: Boolean)\n\ncase class Completer(prefix: String, shellCompleter: Suggestions => Nothing) {\n  def process(suggestions: Suggestions): Nothing = shellCompleter(suggestions)\n}\n\ntrait Completions[ShellTypes <: Shell] {\n  this: CliApp =>\n\n  override def makeCmdLine(pwd: FsUrl, args: Vector[String]): CmdLine =\n    shellCompleter().makeCmdLine(pwd, args)\n\n  def shellCompleter(): ShellTypes\n}\n"
  },
  {
    "path": "cli/shared/src/main/scala/rapture/cli/params2.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.cli\n\nimport scala.util.Try\nimport scala.annotation.tailrec\n\nimport rapture.core._\n\nobject New {\n  case class ParamUsage(map: ParamMap, used: Set[String]) {\n    def -(key: String): ParamUsage = copy(used = used + key)\n    def --(keys: Set[String]): ParamUsage = copy(used = used ++ keys)\n    def unexpected = map.groups.filterNot { p =>\n      used contains p.key()\n    }\n  }\n\n  case class ParamMap(args: String*) {\n\n    def ++(pm2: ParamMap) = ParamMap(pm2.args ++ args: _*)\n\n    case class Part(no: Int, start: Int, end: Int) {\n      def apply() = args(no).substring(start, end)\n    }\n\n    case class Parameter(key: Part, values: Vector[Part] = Vector()) {\n      override def toString = {\n        val prefix = if (key().length == 1) \"-\" else \"--\"\n        s\"$prefix${key()} ${values.map(_ ()) mkString \" \"}\"\n      }\n    }\n\n    val groups: Set[Parameter] = parseArgs().to[Set]\n\n    @tailrec\n    private def parseArgs(gs: List[Parameter] = Nil, n: Int = 0, off: Int = 0): List[Parameter] = {\n      if (n == args.length) gs\n      else if (args(n) startsWith \"--\") {\n        val idx = args(n).indexOf('=')\n        if (idx < off) parseArgs(Parameter(Part(n, 2, args(n).length)) :: gs, n + 1)\n        else parseArgs(Parameter(Part(n, 2, idx)) :: gs, n, idx + 1)\n      } else if (args(n) startsWith \"-\") {\n        if (off == 0) parseArgs(gs, n, 1)\n        else if (args(n).length == off + 1) parseArgs(Parameter(Part(n, off, off + 1)) :: gs, n + 1)\n        else parseArgs(Parameter(Part(n, off, off + 1)) :: gs, n, off + 1)\n      } else {\n        if (gs.isEmpty) parseArgs(gs, n + 1)\n        else parseArgs(gs.head.copy(values = gs.head.values :+ Part(n, 0, args(n).length)) :: gs.tail, n + 1)\n      }\n    }\n\n    def find(key: String): Option[Parameter] = groups.find(_.key() == key)\n\n    def apply(names: Vector[String]): Option[Parameter] = names match {\n      case Vector() => None\n      case h +: t => find(h) orElse apply(t)\n    }\n\n    def isEmpty = args.isEmpty\n\n    override def toString = groups.mkString\n  }\n\n  trait `Params.parse` extends MethodConstraint\n\n  sealed class ParamException(msg: String) extends Exception(msg)\n\n  case class MissingParam(name: String) extends ParamException(s\"the parameter --$name was missing\")\n\n  case class InvalidValue(value: String, name: String)\n      extends ParamException(s\"the value '$value' is not valid for the parameter --$name\")\n\n  case class UnexpectedParam(param: String) extends ParamException(s\"found unexpected parameter '$param'\")\n\n  @implicitNotFound(\"Can not combine elements of type ${A} and ${B}\")\n  trait Construct[-A <: Params, -B <: Params] { construct =>\n    type And <: Params\n    type Or <: Params\n\n    def and(a: A, b: B): ProductParams[And]\n    def or(a: A, b: B): CoproductParams[Or]\n\n    def swap: Construct[B, A] { type And = construct.And; type Or = construct.Or } =\n      new Construct[B, A] {\n        type And = construct.And\n        type Or = construct.Or\n\n        def and(a: B, b: A): ProductParams[And] = construct.and(b, a)\n        def or(a: B, b: A): CoproductParams[Or] = construct.or(b, a)\n      }\n  }\n\n  trait Construct_1 {\n\n    implicit def general[A <: Params, B <: Params]: Construct[A, B] { type And = A with B; type Or = A with B } = {\n\n      new Construct[A, B] {\n        type And = A with B\n        type Or = A with B\n\n        def and(a: A, b: B) = ProductParams[A with B](Set(a, b))\n        def or(a: A, b: B) = CoproductParams[A with B](Vector(a, b))\n      }\n    }\n  }\n\n  object Construct extends Construct_1 {\n\n    implicit def leftProduct[A <: Params, B <: SimpleParam[_]]: Construct[ProductParams[A], B] {\n      type And = A with B; type Or = ProductParams[A] with B\n    } = {\n\n      new Construct[ProductParams[A], B] {\n        type And = A with B\n        type Or = ProductParams[A] with B\n\n        def and(a: ProductParams[A], b: B) = ProductParams[A with B](a.elements + b)\n\n        def or(a: ProductParams[A], b: B) =\n          CoproductParams[ProductParams[A] with B](Vector(a, b))\n      }\n    }\n\n    implicit def rightProduct[A <: SimpleParam[_], B <: Params]: Construct[A, ProductParams[B]] {\n      type And = B with A; type Or = ProductParams[B] with A\n    } = leftProduct[B, A].swap\n\n    implicit def leftCoproduct[A <: Params, B <: SimpleParam[_]]\n      : Construct[CoproductParams[A], B] { type And = CoproductParams[A] with B; type Or = A with B } = {\n\n      new Construct[CoproductParams[A], B] {\n        type And = CoproductParams[A] with B\n        type Or = A with B\n\n        def and(a: CoproductParams[A], b: B) =\n          ProductParams[CoproductParams[A] with B](Set(a, b))\n\n        def or(a: CoproductParams[A], b: B) = CoproductParams[A with B](a.elements :+ b)\n      }\n    }\n\n    implicit def rightCoproduct[A <: SimpleParam[_], B <: Params]\n      : Construct[A, CoproductParams[B]] { type And = CoproductParams[B] with A; type Or = B with A } =\n      leftCoproduct[B, A].swap\n  }\n\n  case class Suggestions(output: Option[Seq[Vector[String]]]) {\n    def orElse(ss: Suggestions) = Suggestions(output orElse ss.output)\n  }\n\n  object SuggestionOutput {\n    implicit val defaultOutput: SuggestionOutput = new SuggestionOutput {\n      def output(ss: Suggestions) = ()\n    }\n  }\n  trait SuggestionOutput { def output(ss: Suggestions): Unit }\n\n  trait Params { params =>\n    type Result\n\n    def parse(args: ParamMap, tabArg: Int = -1)(implicit suggestOutput: SuggestionOutput,\n                                                mode: Mode[`Params.parse`]): mode.Wrap[Result, ParamException] =\n      mode.wrap {\n\n        val (result, lastArgs, ss) = check(ParamUsage(args, Set()), mode, tabArg, Suggestions(None))\n\n        suggestOutput.output(ss)\n\n        lastArgs.unexpected foreach { p =>\n          mode.exception(UnexpectedParam(p.key()))\n        }\n        result\n      }\n\n    def check(args: ParamUsage, mode: Mode[_], tabArg: Int, ss: Suggestions): (Result, ParamUsage, Suggestions)\n\n    def &[B <: Params](b: B)(implicit con: Construct[params.type, b.type]): ProductParams[con.And] = {\n\n      con.and(this, b)\n    }\n\n    def |[B <: Params](b: B)(implicit con: Construct[params.type, b.type]): CoproductParams[con.Or] = {\n\n      con.or(this, b)\n    }\n\n    def unary_~ : OptionParams[this.type] = OptionParams(this)\n\n    def by[R](fn: Result => R): Param.Handler[this.type, R] =\n      new Param.Handler[this.type, R](this) {\n        type From = Result\n        def handle(v: From): R = fn(v)\n      }\n  }\n\n  case class OptionParams[Ps <: Params](params: Ps) extends Params {\n    type Result = Option[params.Result]\n\n    def check(args: ParamUsage, mode: Mode[_], tabArg: Int, ss: Suggestions): (Result, ParamUsage, Suggestions) =\n      try {\n\n        val (res, newArgs, newSs) = params.check(args, mode, tabArg, ss)\n        (Some(res), newArgs, newSs)\n      } catch { case e: Exception => (None, args, ss) }\n\n    override def toString = s\"[$params]\"\n  }\n\n  case class ProductParams[Ps <: Params](elements: Set[Params]) extends Params {\n    type ProductTypes = Ps\n    type Result = Product[ProductTypes]\n\n    def check(args: ParamUsage, mode: Mode[_], tabArg: Int, ss: Suggestions): (Result, ParamUsage, Suggestions) = {\n\n      val (finalArgs, finalElems, newSs) = elements.foldLeft((args, Set[(Params, Any)](), ss)) {\n        case ((args, es, ss), key) =>\n          val (res, nextArgs, newSs) = key.check(args, mode, tabArg, ss)\n          (nextArgs, es + (key -> res), ss orElse newSs)\n      }\n\n      (new Product[Ps](finalElems.toMap), finalArgs, newSs)\n    }\n\n    override def toString = elements.mkString(\"( \", \" & \", \" )\")\n  }\n\n  case class CoproductParams[Ps <: Params](elements: Vector[Params]) extends Params {\n    type CoproductTypes = Ps\n    type Result = Coproduct[CoproductTypes]\n\n    def check(args: ParamUsage, mode: Mode[_], tabArg: Int, ss: Suggestions): (Result, ParamUsage, Suggestions) = {\n      val elems = elements.to[List].flatMap { k =>\n        Try(Option(k.check(args, mode, tabArg, ss)).get).toOption.map(k -> _)\n      }\n\n      elems match {\n        case (key, (res, args, newSs)) :: Nil => (Coproduct[CoproductTypes](key -> res), args, newSs)\n        case Nil => mode.exception(MissingParam(toString))\n        case _ :: (key, _) :: _ => mode.exception(UnexpectedParam(key.toString))\n      }\n    }\n\n    override def toString = elements.mkString(\"( \", \" | \", \" )\")\n  }\n\n  object ToSuggestion {\n\n    implicit val stringSuggestion: ToSuggestion[String] = new ToSuggestion[String] {\n      def suggestion(value: String): Vector[String] = Vector(value)\n    }\n  }\n  trait ToSuggestion[T] {\n    def suggestion(value: T): Vector[String]\n  }\n\n  case class SimpleParam[T: Param.Extractor](keys: Vector[String]) extends Params { simpleParam =>\n\n    type Result = T\n\n    def toSuggestion(t: T): Vector[String] = Vector()\n    def suggestions(s: String): Seq[T] = Seq()\n    def checkValue: Option[T] = None\n\n    def suggest(suggestions: T*)(implicit sug: ToSuggestion[T]): SimpleParam[T] =\n      suggest { s =>\n        suggestions\n      }\n\n    def suggest(suggestions: String => Seq[T])(implicit sug: ToSuggestion[T]): SimpleParam[T] = {\n      val ss = suggestions\n      new SimpleParam[T](keys) {\n        override def toSuggestion(value: T): Vector[String] = sug.suggestion(value)\n        override def suggestions(s: String) = ss(s)\n        override def checkValue = simpleParam.checkValue\n      }\n    }\n\n    def filter(fn: T => Boolean): SimpleParam[T] = new SimpleParam[T](keys) {\n      override def toSuggestion(value: T): Vector[String] = simpleParam.toSuggestion(value)\n      override def suggestions(str: String) = simpleParam.suggestions(str).filter(fn)\n      override def checkValue = simpleParam.checkValue\n    }\n\n    protected val extractor = ?[Param.Extractor[T]]\n\n    def check(args: ParamUsage, mode: Mode[_], tabArg: Int, ss: Suggestions): (Result, ParamUsage, Suggestions) = {\n\n      val parameter = args.map(keys) getOrElse mode.exception(MissingParam(keys.head))\n\n      val res = extractor.extract(parameter.values.map(_ ())) getOrElse {\n        mode.exception(InvalidValue(parameter.key(), parameter.values.mkString(\" \")))\n      }\n\n      checkValue.foreach { v =>\n        if (v != res) mode.exception(InvalidValue(keys.head, \"invalid\"))\n      }\n\n      val newSs = Suggestions(parameter.values.find(tabArg == _.no).map { p =>\n        suggestions(p()).map(toSuggestion)\n      })\n\n      (res, args -- keys.to[Set], ss orElse newSs)\n    }\n\n    // Also consider `extractor` in `hashCode` and `equals`\n    override def hashCode = keys.hashCode ^ extractor.hashCode\n\n    override def equals(that: Any) = that match {\n      case that: SimpleParam[_] =>\n        keys.to[Set] == that.keys.to[Set] && that.extractor == extractor\n      case _ =>\n        false\n    }\n\n    override def toString =\n      keys.map { k =>\n        if (k.length == 1) s\"-$k\" else s\"--$k\"\n      }.mkString(\"/\")\n\n    def of(v: T): SimpleParam[T] = new SimpleParam[T](keys) {\n      override def toSuggestion(value: T): Vector[String] = simpleParam.toSuggestion(value)\n      override def suggestions(str: String) = simpleParam.suggestions(str)\n      override def checkValue = Some(v)\n    }\n  }\n\n  object Param {\n\n    object Extractor {\n      implicit val stringExtractor: Extractor[String] = new Extractor[String] {\n        // FIXME: Add mode parameter, and capture failure types\n        def extract(values: Vector[String]): Option[String] = Some(values.mkString(\" \"))\n      }\n\n      implicit val intExtractor: Extractor[Int] = new Extractor[Int] {\n        def extract(values: Vector[String]): Option[Int] = values match {\n          case Vector(v) =>\n            try Some(v.toInt)\n            catch { case e: Exception => None }\n          case _ => None\n        }\n      }\n\n      implicit val unitExtractor: Extractor[Unit] = new Extractor[Unit] {\n        def extract(values: Vector[String]): Option[Unit] = Some(())\n      }\n    }\n\n    trait Extractor[T] { def extract(values: Vector[String]): Option[T] }\n\n    abstract class Handler[-K, +H](val params: Params) {\n      type From\n      def handle(v: From): H\n    }\n\n    def apply[T: Extractor](shortName: Char, longName: Symbol): SimpleParam[T] =\n      alloc(Vector(shortName.toString, longName.name))\n\n    def apply[T: Extractor](shortName: Char): SimpleParam[T] =\n      alloc(Vector(shortName.toString))\n\n    def apply[T: Extractor](longName: Symbol): SimpleParam[T] = alloc(Vector(longName.name))\n\n    def flag(shortName: Char, longName: Symbol): SimpleParam[Unit] =\n      alloc(Vector(shortName.toString, longName.name))\n\n    def flag(shortName: Char): SimpleParam[Unit] = alloc(Vector(shortName.toString))\n    def flag(longName: Symbol): SimpleParam[Unit] = alloc(Vector(longName.name))\n  }\n\n  @implicitNotFound(\"product does not contain this value\")\n  trait ProductContainsParam[V, T]\n\n  object ProductContainsParam extends ProductContainsParam_1 {\n    implicit def optional[V <: OptionParams[_ <: Params], P <: Params]: ProductContainsParam[V, P] = null\n  }\n  trait ProductContainsParam_1 {\n    implicit def generic[V, T <: V]: ProductContainsParam[V, T] = null\n  }\n\n  @implicitNotFound(\"coproduct cannot contain this value\")\n  trait CoproductContainsParam[V, T]\n\n  object CoproductContainsParam {\n    implicit def acceptable[V, T <: V]: CoproductContainsParam[V, T] = null\n  }\n\n  case class Product[T <: Params](tmap: Map[Params, Any]) {\n    def apply[V <: Params](value: V)(implicit acc: ProductContainsParam[value.type, T]): value.Result =\n      tmap(value).asInstanceOf[value.Result]\n\n    override def toString = tmap.map { case (k, v) => s\"$k: $v\" }.mkString(\", \")\n  }\n\n  case class Coproduct[T <: Params](value: (Params, Any)) {\n    def handle[K, R](handlers: Param.Handler[K, R]*)(implicit ev: K <:< T): R = {\n      val h = handlers.find(_.params == value._1).get\n      h.handle(value._2.asInstanceOf[h.From])\n    }\n\n    override def toString = s\"${value._1}: ${value._2}\"\n  }\n}\n"
  },
  {
    "path": "cli/shared/src/main/scala/rapture/cli/process.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.cli\n\nimport rapture.io._\nimport rapture.core._\nimport rapture.codec._\nimport java.io.{Reader => _, _}\n\nimport encodings.system._\nimport language.higherKinds\n\ntrait `Process#exec` extends MethodConstraint\n\ncase class Process(params: Vector[String]) {\n  def exec[T: ProcessInterpreter](implicit mode: Mode[`Process#exec`], env: Environment): mode.Wrap[T, CliException] =\n    mode.wrap {\n      val javaProcess = Runtime\n        .getRuntime()\n        .exec(params.to[Array], env().map { case (k, v) => s\"$k=$v\" }\n              .to[Array], new File(env.workDir.getOrElse(System.getenv(\"HOME\"))))\n      val stream = new ByteInput(new BufferedInputStream(javaProcess.getInputStream))\n      val stderr = new ByteInput(new BufferedInputStream(javaProcess.getErrorStream))\n      ?[ProcessInterpreter[T]].interpret(stream, stderr, () => javaProcess.waitFor())\n    }\n\n  override def toString = {\n    val escaped = params.map(_.flatMap {\n      case '\\'' => \"\\\\'\"\n      case '\"' => \"\\\\\\\"\"\n      case '\\\\' => \"\\\\\\\\\"\n      case ' ' => \"\\\\ \"\n      case chr => chr.toString\n    })\n\n    s\"\"\"sh\"${escaped.mkString(\" \")}\"\"\"\"\n  }\n}\n\nobject Environment {\n  implicit val defaultEnvironment = new Environment {\n    def apply(): Map[String, String] = {\n      import scala.collection.JavaConverters._\n      mapAsScalaMapConverter(System.getenv()).asScala.toMap\n    }\n\n    def workDir: Option[String] = Option(System.getProperty(\"user.dir\"))\n  }\n}\ntrait Environment {\n  def apply(): Map[String, String]\n  def workDir: Option[String]\n}\n\npackage environments {\n  object empty {\n    def apply(): Environment = implicitEnvironment\n    implicit val implicitEnvironment: Environment = new Environment {\n      def apply(): Map[String, String] = Map()\n      def workDir = None\n    }\n  }\n\n  object enclosing {\n    def apply(): Environment = implicitEnvironment\n    implicit val implicitEnvironment: Environment = Environment.defaultEnvironment\n  }\n}\n\ntrait ProcessInterpreter_1 {\n  implicit def genSeqInterpreter[Coll[_], T](implicit cbf: collection.generic.CanBuildFrom[Nothing, T, Coll[T]],\n                                             stringParser: StringParser[T]): ProcessInterpreter[Coll[T]] =\n    new ProcessInterpreter[Coll[T]] {\n      def interpret(input: Input[Byte], stderr: Input[Byte], exitStatus: () => Int): Coll[T] = {\n        val out = input.slurp[Char]\n        exitStatus() match {\n          case 0 =>\n            val builder = cbf()\n            // FIXME: Reimplement this using a streaming method\n            out.split(\"\\n\").foreach { s =>\n              builder += stringParser.parse(s, modes.throwExceptions())\n            }\n            builder.result()\n          case n =>\n            throw ShellProcessException(n, out.trim)\n        }\n      }\n    }\n\n}\n\nobject ProcessInterpreter extends ProcessInterpreter_1 {\n\n  implicit def stringProcessInterpreter[T](implicit stringParser: StringParser[T]): ProcessInterpreter[T] =\n    new ProcessInterpreter[T] {\n      def interpret(input: Input[Byte], stderr: Input[Byte], exitStatus: () => Int): T = {\n        val out = input.slurp[Char]\n        val err = stderr.slurp[Char]\n        exitStatus() match {\n          case n =>\n            stringParser.parse(if (out == \"\" || out.last != '\\n') out else out.init, modes.throwExceptions())\n          //case n => throw ShellProcessException(n, out.trim)\n        }\n      }\n    }\n\n  implicit val bytesProcessInterpreter: ProcessInterpreter[Bytes] = new ProcessInterpreter[Bytes] {\n    def interpret(input: Input[Byte], stderr: Input[Byte], exitStatus: () => Int): Bytes = {\n      val out = input.slurp[Byte]\n      exitStatus() match {\n        case 0 => out\n        case n => throw ShellProcessException(n, \"Binary data\")\n      }\n    }\n  }\n\n  implicit val byteInputProcessInterpreter: ProcessInterpreter[Input[Byte]] = new ProcessInterpreter[Input[Byte]] {\n    def interpret(input: Input[Byte], stderr: Input[Byte], exitStatus: () => Int): Input[Byte] = input\n  }\n\n  implicit def inputProcessInterpreter[T](implicit rdr: Reader[Input[Byte], T]): ProcessInterpreter[Input[T]] =\n    new ProcessInterpreter[Input[T]] {\n      def interpret(input: Input[Byte], stderr: Input[Byte], exitStatus: () => Int): Input[T] =\n        input.input[T]\n    }\n\n  implicit val exitStatusProcessInterpreter: ProcessInterpreter[ExitStatus] = new ProcessInterpreter[ExitStatus] {\n    def interpret(input: Input[Byte], stderr: Input[Byte], exitStatus: () => Int): ExitStatus =\n      ExitStatus(exitStatus())\n  }\n}\n\ntrait ProcessInterpreter[T] {\n  def interpret(input: Input[Byte], stderr: Input[Byte], exitStatus: () => Int): T\n}\n\ncase class ShellProcessException(exitStatus: Int, output: String)\n    extends Exception(\"Shell process returned non-zero exit status: \" + exitStatus)\n\ncase class ExitStatus(value: Int)\n"
  },
  {
    "path": "cli/shared/src/main/scala/rapture/cli/tabulate.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.cli\n\nimport language.implicitConversions\nimport language.higherKinds\n\nobject Tabulation {\n  sealed trait Position\n  case object Right extends Position\n  case object Left extends Position\n\n  trait Col_1 {\n    implicit def anyToCol(s: Any): Col = Col(s.toString, Left)\n  }\n  object Col extends Col_1 {\n    implicit def intToCol(s: Int): Col = Col(s.toString, Right)\n    implicit def stringToCol(s: String): Col = Col(s, Left)\n  }\n  case class Col(content: String, position: Position = Left)\n  def tabulate[C[E] <: Seq[E], T](collection: Seq[T], titles: Option[Seq[Col]] = None)(\n      cols: (T => Col)*): Seq[String] = {\n    val contents = collection.map { e =>\n      cols.map(_ (e))\n    }\n\n    val contentsWithTitles = titles.map { ts =>\n      ts +: ts.map { case Col(s, p) => Col(s.map(c => '-'), p) } +: contents\n    }.getOrElse(contents)\n\n    val widths = contentsWithTitles.map { _.map(_.content.length) }.reduce(_ zip _ map { case (a, b) => a max b })\n\n    contentsWithTitles.map(_.zip(widths).map {\n      case (Col(s, Right), w) => \" \" * (w - s.length) + s + \"  \"\n      case (Col(s, Left), w) => s + (\" \" * (w - s.length)) + \"  \"\n    }.mkString)\n  }\n}\n"
  },
  {
    "path": "cli/shared/src/main/scala/rapture/cli/zsh.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.cli\n\nimport rapture.core._\n\nobject Encoder {\n  private val Translations = \"<>#{}|\\\\^~[]`/?:@=&$!*:; \".to[Vector]\n\n  def encode(s: String): String = s flatMap { c =>\n    if (Translations contains c) {\n      \"%\" + (c / 16 + c / 160 * 7 + 48).toChar + (c % 16 + c % 16 / 10 * 7 + 48).toChar\n    } else c.toString\n  }\n}\n\nobject Compadd {\n\n  def maxWidths(lists: Vector[Vector[String]]): Vector[Int] =\n    lists.map(_.map(_.length)).reduce(_ zip _ map (Math.max _).tupled)\n\n  def padRows(lists: Vector[Vector[String]]): Vector[String] = {\n    val widths = maxWidths(lists)\n    lists.map(_.zip(widths).map { case (s, w) => s.padTo(w, ' ') }.mkString(\"  \"))\n  }\n\n  def apply(groupTitle: Option[String] = None,\n            completions: Vector[String] = Vector(),\n            columns: Boolean = true,\n            descriptions: String => Vector[String] = _ => Vector(),\n            colWidth: Int = 1000,\n            hidden: Boolean): Vector[String] = {\n\n    val display: Option[Vector[String]] = {\n      val ds: Vector[Vector[String]] = completions map descriptions\n      if (ds.forall(_.isEmpty)) None\n      else Some(padRows(completions zip ds map { case (c, d) => c +: d }))\n    }\n\n    display.toVector.flatten.map(s => \"let \" + Encoder.encode(s.take(colWidth - 1))) :+ Vector\n      .strap(\n          \"compadd\",\n          groupTitle.to[Vector].flatMap(Seq(\"-J\", _)),\n          if (columns) Some(\"-l\") else None,\n          if (hidden) None else Some(\"-d matches\"),\n          if (hidden) Some(\"-n\") else None,\n          \"--\",\n          completions.map(Encoder.encode)\n      )\n      .mkString(\" \")\n  }\n}\n"
  },
  {
    "path": "cli/shared/src/test/scala/rapture/cli/tests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.cli.test\n\n/*import rapture.core._\nimport rapture.cli._\nimport rapture.test._\n\nimport scala.util\n\nclass TestRun extends Programme {\n  include(CliTests)\n}\n\nobject CliTests extends TestSuite {\n\n  import New._\n\n  implicit object Captured extends SuggestionOutput {\n    private var suggestions: Seq[Vector[String]] = Seq()\n    def output(ss: Suggestions) = ss.output.foreach(suggestions = _)\n    def last() = suggestions\n  }\n\n  val Alpha = Param[String]('a', 'alpha)\n  val Beta = Param[Int]('b', 'beta)\n  val Gamma = Param.flag('c', 'gamma)\n  val Delta = Param[String]('d', 'delta)\n\n  val alpha = ParamMap(\"-a\", \"alpha\")\n  val alphaIsBeta = ParamMap(\"-a\", \"beta\")\n  val alphaIsGamma = ParamMap(\"-a\", \"gamma\")\n  val beta = ParamMap(\"-b\", \"0\")\n  val gamma = ParamMap(\"-c\")\n  val delta = ParamMap(\"-d\", \"delta\")\n  val empty = ParamMap()\n\n  val `Parse short flag` = test {\n    ParamMap(\"-a\").find(\"a\").map(_.values.map(_()))\n  } returns Some(Vector())\n\n  val `Parse short param with value` = test {\n    ParamMap(\"-a\", \"alpha\").find(\"a\").map(_.values.map(_()))\n  } returns Some(Vector(\"alpha\"))\n  \n  val `Parse multiple short params` = test {\n    ParamMap(\"-abc\").find(\"b\").map(_.values.map(_()))\n  } returns Some(Vector())\n  \n  val `Parse multiple short params with value` = test {\n    ParamMap(\"-abc\", \"gamma\").find(\"c\").map(_.values.map(_()))\n  } returns Some(Vector(\"gamma\"))\n  \n  val `Parse long flag` = test {\n    ParamMap(\"--alpha\").find(\"alpha\").map(_.values.map(_()))\n  } returns Some(Vector())\n  \n  val `Parse long param` = test {\n    ParamMap(\"--alpha\", \"value\").find(\"alpha\").map(_.values.map(_()))\n  } returns Some(Vector(\"value\"))\n  \n  val `Parse long param (multiple args)` = test {\n    ParamMap(\"--alpha\", \"one\", \"two\", \"three\").find(\"alpha\").map(_.values.map(_()))\n  } returns Some(Vector(\"one\", \"two\", \"three\"))\n  \n  val `Parse last of multiple long flags` = test {\n    ParamMap(\"--alpha\", \"--beta\", \"--gamma\", \"--delta\").find(\"delta\").map(_.values.map(_()))\n  } returns Some(Vector())\n  \n  val `Parse first of multiple long flags` = test {\n    ParamMap(\"--alpha\", \"--beta\", \"--gamma\", \"--delta\").find(\"alpha\").map(_.values.map(_()))\n  } returns Some(Vector())\n  \n  val `Parse first of multiple long params` = test {\n    ParamMap(\"--alpha\", \"one\", \"--beta\", \"--gamma\",\n        \"--delta\").find(\"alpha\").map(_.values.map(_()))\n\n  } returns Some(Vector(\"one\"))\n  \n  val `Parse last of multiple long params` = test {\n    ParamMap(\"--alpha\", \"one\", \"--beta\", \"--gamma\", \"--delta\", \"a\", \"b\",\n        \"c\").find(\"delta\").map(_.values.map(_()))\n  } returns Some(Vector(\"a\", \"b\", \"c\"))\n  \n  val `Extract simple param` = test {\n    Alpha.parse(ParamMap(\"-a\", \"alpha\"))\n  } returns \"alpha\"\n\n  val `Extract int` = test {\n    Beta.parse(ParamMap(\"-b\", \"1\"))\n  } returns 1\n\n  val `Simple coproduct 1` = test {\n    val parsed = (Alpha | Beta).parse(alpha)\n    parsed.handle(\n      Alpha by identity,\n      Beta by { b => \"beta\" }\n    )\n  } returns \"alpha\"\n\n  val `Simple coproduct 2` = test {\n    val parsed = (Alpha | Beta).parse(beta)\n    parsed.handle(\n      Alpha by identity,\n      Beta by { b => \"beta\" }\n    )\n  } returns \"beta\"\n\n  val `Coproduct handler is total 1` = test {\n    typeMismatch {\n      val parsed = (Alpha | Beta).parse(beta)\n      import deferTypeErrors._\n      parsed.handle(\n        Alpha by identity\n      )\n    }\n  } returns true\n\n  val `Coproduct handler is total 2` = test {\n    typeMismatch {\n      val parsed = (Alpha | Beta).parse(beta)\n      import deferTypeErrors._\n      parsed.handle(\n        Beta by { b => \"beta\" },\n        Alpha by identity\n      )\n    }\n  } returns false\n  \n  val `Can't access invalid field` = test {\n    typeMismatch {\n      val parsed = (Alpha & Beta).parse(beta)\n      import deferTypeErrors._\n      parsed(Gamma)\n    }\n  } returns true\n  \n  //val `Refuse coproduct duplicates` = test {\n  //  import modes.returnOption._\n  //  (Alpha | Beta).parse(alpha ++ beta)\n  //} returns None\n\n  val `Simple product` = test {\n    val parsed = (Alpha & Beta).parse(alpha ++ beta)\n    parsed(Alpha) -> parsed(Beta)\n  } returns (\"alpha\", 0)\n\n  //val `Missing product value fails 1` = test {\n  //  import modes.returnOption._\n  //  (Alpha & Beta).parse(alpha)\n  //} returns None\n  \n  //val `Missing product value fails 2` = test {\n  //  import modes.returnOption._\n  //  (Alpha & Beta).parse(beta)\n  //} returns None\n  \n  //val `Missing product value fails 3` = test {\n  //  import modes.returnOption._\n  //  (Alpha & Beta).parse(empty)\n  //} returns None\n\n  val `Coproduct and product 1` = test {\n    val parsed = (Alpha & Beta | Delta).parse(alpha ++ beta)\n    parsed.handle(\n      Alpha & Beta by { p => p(Alpha) -> p(Beta) },\n      Delta by { d => (\"delta\", -1) }\n    )\n  } returns (\"alpha\", 0)\n  \n  val `Coproduct and product 2` = test {\n    val parsed = (Alpha & Beta | Delta).parse(delta)\n    parsed.handle(\n      Alpha & Beta by { p => p(Alpha) -> p(Beta) },\n      Delta by { d => (\"delta\", -1) }\n    )\n  } returns (\"delta\", -1)\n\n  val `Coproduct and product failure 1` = test {\n    import modes.returnOption._\n    val parsed = (Alpha & Beta | Delta).parse(alpha)\n  } returns None\n  \n  val `Coproduct and product failure 2` = test {\n    import modes.returnOption._\n    val parsed = (Alpha & Beta | Delta).parse(beta)\n  } returns None\n\n  //val `Coproduct and product failure 3` = test {\n  //  import modes.returnOption._\n  //  (Alpha & Beta | Delta).parse(alpha ++ delta)\n  //} returns None\n  \n  //val `Coproduct and product failure 4` = test {\n  //  import modes.returnOption._\n  //  (Alpha & Beta | Delta).parse(beta ++ delta)\n  //} returns None\n\n  val `Optional value 1` = test {\n    (~Alpha).parse(alpha)\n  } returns Some(\"alpha\")\n\n  val `Optional value 2` = test {\n    (~Alpha).parse(empty)\n  } returns None\n  \n  val `Optional Product 1` = test {\n    val parsed = (~Alpha & ~Beta).parse(empty)\n    (parsed(~Alpha), parsed(~Beta))\n  } returns (None, None)\n  \n  val `Optional Product 2` = test {\n    val parsed = (~Alpha & ~Beta).parse(alpha)\n    (parsed(~Alpha), parsed(~Beta))\n  } returns (Some(\"alpha\"), None)\n  \n  val `Optional Product 3` = test {\n    val parsed = (~Alpha & ~Beta).parse(beta)\n    (parsed(~Alpha), parsed(~Beta))\n  } returns (None, Some(0))\n  \n  val `Optional Product 4` = test {\n    val parsed = (~Alpha & ~Beta).parse(beta ++ alpha)\n    (parsed(~Alpha), parsed(~Beta))\n  } returns (Some(\"alpha\"), Some(0))\n\n  val `Complex extraction successes` = test {\n    import modes.returnOption._\n    \n    val pattern = (Alpha & ~Beta | Beta & (Gamma | Delta))\n    \n    val successes = List(alpha, alpha ++ beta, beta ++ gamma, beta ++ delta)\n\n    successes.map(pattern.parse(_)).forall(_.isDefined)\n  } returns true\n\n  val `Complex extraction failures` = test {\n    import modes.returnOption._\n    \n    val pattern = (Alpha & ~Beta | Beta & (Gamma | Delta))\n    \n    val failures = List(beta, gamma, delta, beta ++ gamma ++ delta, alpha ++ gamma, alpha ++\n        delta)\n\n    failures.map(pattern.parse(_)).forall(_ == None)\n  } returns true\n\n  val `Neither or both` = test {\n    import modes.returnOption._\n    \n    val pattern = ~(Alpha & Beta)\n    \n    val successes = List(alpha ++ beta, empty)\n    val failures = List(alpha, beta, gamma)\n\n    successes.map(pattern.parse(_)).forall(_.isDefined) &&\n        failures.map(pattern.parse(_)).forall(_ == None)\n  } returns true\n\n\n  val `Check param value` = test {\n    Alpha.of(\"alpha\").parse(alpha)\n  } returns \"alpha\"\n  \n  val `Check param value 2` = test {\n    val parsed = (Alpha.of(\"beta\") | Alpha.of(\"alpha\")).parse(alpha)\n    parsed.handle(\n      Alpha by identity\n    )\n  } returns \"alpha\"\n  \n  val `Check param value 3` = test {\n    import modes.returnOption._\n    (Alpha.of(\"beta\") | Alpha.of(\"gamma\")).parse(alpha)\n  } returns None\n  \n  val `Check param values combined` = test {\n    import modes.returnOption._\n    val pattern = Alpha.of(\"beta\") & Beta | Alpha.of(\"gamma\") & Gamma\n    \n    val successes = List(alphaIsGamma ++ gamma, alphaIsBeta ++ beta)\n    val failures = List(alpha, beta, gamma, alphaIsGamma ++ beta, alphaIsBeta ++ gamma,\n        alpha ++ beta, alpha ++ gamma)\n\n    successes.map(pattern.parse(_)).forall(_.isDefined) &&\n        failures.map(pattern.parse(_)).forall(_ == None)\n  } returns true\n\n  val `Check suggestions` = test {\n    val Color = Param[String]('c', 'color).suggest(\"red\", \"green\", \"blue\")\n    \n    Color.parse(ParamMap(\"--color\", \"\"), 1)\n    \n    Captured.last()\n  } returns Vector(Vector(\"red\"), Vector(\"green\"), Vector(\"blue\"))\n}\n*/\n"
  },
  {
    "path": "codec/shared/src/main/scala/rapture/codec/base64.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.codec\n\nimport rapture.core._\n\n/** RFC2045 base-64 codec, based on http://migbase64.sourceforge.net/. */\nclass Base64Codec[C <: CodecType](val char62: Char = '+',\n                                  val char63: Char = '/',\n                                  val padChar: Char = '=',\n                                  val lineBreaks: Boolean = false,\n                                  val endPadding: Boolean = false)\n    extends ByteCodec[C] {\n\n  private val alphabet =\n    (\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\" + char62 + char63).toCharArray\n\n  private lazy val decodabet = {\n    val x: Array[Int] = alloc(256)\n    for (i <- 0 until alphabet.length) x(alphabet(i)) = i\n    x\n  }\n\n  /** Non-RFC-compliant encoder. */\n  /** Encoder. The RFC requires that line breaks be added every 76 chars, and\n    * that the data be padded to a multiple of 4 chars, but we do these things\n    * optionally. */\n  def encode(in: Array[Byte]): String = {\n\n    var inLen = in.length\n\n    if (inLen == 0) \"\"\n    else {\n      val evenLen = (inLen / 3) * 3\n      val outDataLen = if (endPadding) ((inLen - 1) / 3 + 1) << 2 else ((inLen << 2) + 2) / 3\n      val outLen = if (lineBreaks) outDataLen + (outDataLen - 1) / 76 << 1 else outDataLen\n      val out: Array[Char] = alloc(outLen)\n\n      var inPos = 0\n      var outPos = 0\n      var blockCount = 0\n\n      while (inPos < evenLen) {\n        val block = (in(inPos) & 0xFF) << 16 | (in(inPos + 1) & 0xFF) << 8 | (in(inPos + 2) &\n                0xFF)\n\n        inPos += 3\n\n        out(outPos) = alphabet((block >>> 18) & 0x3F)\n        out(outPos + 1) = alphabet((block >>> 12) & 0x3F)\n        out(outPos + 2) = alphabet((block >>> 6) & 0x3F)\n        out(outPos + 3) = alphabet(block & 0x3F)\n\n        outPos += 4\n\n        if (lineBreaks) {\n\n          blockCount += 1\n\n          if (blockCount == 19 && outPos < outLen - 2) {\n            out(outPos) = '\\r'\n            out(outPos + 1) = '\\n'\n            outPos += 2\n            blockCount = 0\n          }\n        }\n      }\n\n      val left = inLen - evenLen\n\n      if (left > 0) {\n\n        val block =\n          ((in(evenLen) & 0xFF) << 10) | (if (left == 2) (in(inLen - 1) & 0xFF) << 2 else 0)\n\n        out(outPos) = alphabet(block >>> 12)\n        out(outPos + 1) = alphabet((block >>> 6) & 0x3F)\n\n        if (left == 2) out(outPos + 2) = alphabet(block & 0x3F)\n        else if (endPadding) out(outPos + 2) = padChar\n\n        if (endPadding) out(outPos + 3) = padChar\n      }\n\n      alloc(out)\n    }\n  }\n\n  /** Decoder. Supports all the variants produced by the encoder above, but\n    * does not tolerate any other illegal characters, including line breaks at\n    * positions other than 76-char boundaries, in which case the result will\n    * be garbage. */\n  def decode(data: String): Either[Int, Array[Byte]] = {\n    val in = data.toCharArray()\n\n    val inLen = in.length\n\n    if (inLen == 0) Right(alloc(0))\n    else {\n\n      val padding = if (in(inLen - 1) == padChar) (if (in(inLen - 2) == padChar) 2 else 1) else 0\n\n      // FIXME: This doesn't seem to accommodate different kinds of linebreak\n      val lineBreaks = if (inLen > 76) (if (in(76) == '\\r') inLen / 78 else 0) << 1 else 0\n      val outLen = ((inLen - lineBreaks) * 6 >> 3) - padding\n      val out: Array[Byte] = alloc(outLen)\n\n      var inPos = 0\n      var outPos = 0\n      var blockCount = 0\n\n      val evenLen = (outLen / 3) * 3\n\n      while (outPos < evenLen) {\n\n        val block = decodabet(in(inPos)) << 18 | decodabet(in(inPos + 1)) << 12 |\n            decodabet(in(inPos + 2)) << 6 | decodabet(in(inPos + 3))\n\n        inPos += 4\n\n        out(outPos) = (block >> 16).toByte\n        out(outPos + 1) = (block >> 8).toByte\n        out(outPos + 2) = block.toByte\n        outPos += 3\n\n        if (lineBreaks > 0) {\n\n          blockCount += 1\n\n          if (blockCount == 19) {\n            inPos += 2\n            blockCount = 0\n          }\n        }\n      }\n\n      if (outPos < outLen) {\n        val block = decodabet(in(inPos)) << 18 | decodabet(in(inPos + 1)) << 12 |\n            (if (inPos + 2 < inLen - padding) decodabet(in(inPos + 2)) << 6 else 0)\n\n        out(outPos) = (block >> 16).toByte\n\n        if (outPos + 1 < outLen) out(outPos + 1) = (block >> 8).toByte\n      }\n\n      Right(out)\n    }\n  }\n}\n"
  },
  {
    "path": "codec/shared/src/main/scala/rapture/codec/bytes.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.codec\n\nimport rapture.core._\n\nimport scala.collection.generic.CanBuildFrom\n\nimport language.higherKinds\n\nobject `package` {\n  implicit def bytesParser(implicit enc: Encoding): StringParser[Bytes] { type Throws = Nothing } =\n    new StringParser[Bytes] {\n      type Throws = Nothing // We would like to throw an EncodingException if we try to decode an invalid byte\n      def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Bytes, Nothing] = mode.wrap {\n        Bytes(s.getBytes(\"UTF-8\"))\n      }\n    }\n}\n\ntrait FromBytes[T] { def build(bytes: Array[Byte]): T }\n\nobject FromBytes {\n  implicit def stringFromBytes(implicit enc: Encoding): FromBytes[String] = new FromBytes[String] {\n    def build(bytes: Array[Byte]): String = new String(bytes, enc.name)\n  }\n\n  implicit def bytesFromBytes = new FromBytes[Array[Byte]] {\n    def build(bytes: Array[Byte]): Array[Byte] = bytes\n  }\n}\n\ntrait `decode.apply` extends MethodConstraint\ncase class DecodeException(position: Option[Int]) extends Exception\n\ntrait CodecType\ntrait Hex extends CodecType\ntrait Base64 extends CodecType\ntrait Base64Url extends CodecType\ntrait Base32 extends CodecType\ntrait Binary extends CodecType\n\nobject decode {\n  def apply[C <: CodecType: ByteCodec](s: String)(\n      implicit mode: Mode[`decode.apply`]): mode.Wrap[Bytes, DecodeException] =\n    mode wrap {\n      try {\n        implicitly[ByteCodec[C]].decode(s) match {\n          case Left(pos) => mode.exception(DecodeException(Some(pos)))\n          case Right(res) => Bytes(res)\n        }\n      } catch { case e: Exception => mode.exception(DecodeException(None)) }\n    }\n}\n\nobject ByteCodec {\n  implicit val base64Url: ByteCodec[Base64Url] = new Base64Codec('-', '_', '=', false, false)\n  implicit val base64: ByteCodec[Base64] = new Base64Codec('+', '/', '=', false, false)\n\n  implicit val hex: ByteCodec[Hex] = new ByteCodec[Hex] {\n    def encode(array: Array[Byte]): String =\n      alloc(array flatMap { n =>\n        Array((n & 255) >> 4 & 15, n & 15)\n      } map { _ + 48 } map { i =>\n        (if (i > 57) i + 39 else i).toChar\n      })\n\n    def decode(s: String): Either[Int, Array[Byte]] =\n      Right((if (s.length % 2 == 0) s else \"0\" + s).to[Array].grouped(2).to[Array] map {\n        case Array(l, r) =>\n          (((l - 48) % 39 << 4) + (r - 48) % 39).toByte\n      })\n  }\n\n  implicit val binary: ByteCodec[Binary] = new ByteCodec[Binary] {\n    def encode(array: Array[Byte]): String =\n      alloc(Array.range(0, array.length * 8) map { i =>\n        if ((array(i / 8) & (1 << (7 - i % 8))) > 0) 49.toByte else 48.toByte\n      })\n\n    def decode(s: String): Either[Int, Array[Byte]] = {\n      null\n    }\n  }\n}\n\ntrait ByteCodec[Codec <: CodecType] {\n  def encode(bytes: Array[Byte]): String\n  def decode(string: String): Either[Int, Array[Byte]]\n}\n\nobject Bytes {\n  implicit def arrayBytes(bytes: Array[Byte]): Bytes = Bytes(bytes)\n}\n\ncase class Bytes(bytes: Array[Byte]) {\n  def encode[Codec <: CodecType: ByteCodec]: String =\n    implicitly[ByteCodec[Codec]].encode(bytes)\n\n  override def toString = encode[Hex]\n\n  def ++(that: Bytes): Bytes = Bytes(bytes ++ that.bytes)\n\n  override def equals(that: Any) = that match {\n    case Bytes(bs) =>\n      bs.length == bytes.length && (bs zip bytes forall { case (a, b) => a == b })\n    case _ =>\n      false\n  }\n\n  override def hashCode = bytes.foldLeft(bytes.length)(_ * 131 + _)\n\n  /** Sets all values in the underlying byte array to zeroes. This is useful if the `Bytes`\n    * instance was storing sensitive data, such as a private key. */\n  def zero() = bytes.indices foreach { bytes(_) = 0 }\n\n  def as[T: FromBytes](implicit mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, DecodeException] = mode.wrap {\n    try ?[FromBytes[T]].build(bytes)\n    catch {\n      case e: Exception => mode.exception[T, DecodeException](DecodeException(None))\n    }\n  }\n\n  def apply(index: Int): Byte = bytes(index)\n\n  def slice(start: Int, end: Int) = Bytes(bytes.slice(start, end))\n\n  def length: Int = bytes.length\n\n  def to[Coll[_]](implicit cbf: CanBuildFrom[Nothing, Byte, Coll[Byte]]): Coll[Byte] =\n    bytes.to[Coll]\n}\n"
  },
  {
    "path": "codec/shared/src/main/scala/rapture/codec/encodings.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.codec\n\nimport rapture.core._\n\n@implicitNotFound(\n    \"Character encoding has not been provided. Please specify an implicit \" +\n      \"Encoding value, e.g. import encodings.system._ or import encodings.`UTF-8`._.\")\ncase class Encoding(name: String) { def index = name }\n\ncase class EncodingImplicit(name: String) {\n  implicit val implicitEncoding: Encoding = Encoding(name)\n  def apply() = implicitEncoding\n}\n\n/** Provides references to standard character encodings provided by Java. Encodings are\n  * represented by instances of the Encoding case class, which is a simple wrapper over a String\n  * of the encoding's name. Several standard encodings are provided and identified by the\n  * encoding's canonical name for the avoidance of ambiguity. These instances will typically\n  * require escaping with backticks in order to be referenced, however type safety will be\n  * ensured. */\nobject encodings {\n\n  implicit val `US-ASCII` = EncodingImplicit(\"US-ASCII\")\n  implicit val `windows-1250` = EncodingImplicit(\"windows-1250\")\n  implicit val `windows-1251` = EncodingImplicit(\"windows-1251\")\n  implicit val `windows-1252` = EncodingImplicit(\"windows-1252\")\n  implicit val `windows-1253` = EncodingImplicit(\"windows-1253\")\n  implicit val `windows-1254` = EncodingImplicit(\"windows-1254\")\n  implicit val `windows-1257` = EncodingImplicit(\"windows-1257\")\n  implicit val `ISO-8859-1` = EncodingImplicit(\"ISO-8859-1\")\n  implicit val `ISO-8859-2` = EncodingImplicit(\"ISO-8859-2\")\n  implicit val `ISO-8859-4` = EncodingImplicit(\"ISO-8859-4\")\n  implicit val `ISO-8859-5` = EncodingImplicit(\"ISO-8859-5\")\n  implicit val `ISO-8859-7` = EncodingImplicit(\"ISO-8859-7\")\n  implicit val `ISO-8859-9` = EncodingImplicit(\"ISO-8859-9\")\n  implicit val `ISO-8859-13` = EncodingImplicit(\"ISO-8859-13\")\n  implicit val `ISO-8859-15` = EncodingImplicit(\"ISO-8859-15\")\n  implicit val `KOI8-R` = EncodingImplicit(\"KOI8-R\")\n  implicit val `UTF-8` = EncodingImplicit(\"UTF-8\")\n  implicit val `UTF-16` = EncodingImplicit(\"UTF-16\")\n  implicit val `UTF-16BE` = EncodingImplicit(\"UTF-16BE\")\n  implicit val `UTF-16LE` = EncodingImplicit(\"UTF-16LE\")\n\n  /** The default file system encoding for this system */\n  implicit lazy val system = EncodingImplicit(System.getProperty(\"file.encoding\"))\n\n  private val allEncodings: Map[String, Encoding] = Map(\n      (\"US-ASCII\", `US-ASCII`()),\n      (\"windows-1250\", `windows-1250`()),\n      (\"windows-1251\", `windows-1251`()),\n      (\"windows-1252\", `windows-1252`()),\n      (\"windows-1253\", `windows-1253`()),\n      (\"windows-1254\", `windows-1254`()),\n      (\"windows-1257\", `windows-1257`()),\n      (\"ISO-8859-1\", `ISO-8859-1`()),\n      (\"ISO-8859-2\", `ISO-8859-2`()),\n      (\"ISO-8859-4\", `ISO-8859-4`()),\n      (\"ISO-8859-5\", `ISO-8859-5`()),\n      (\"ISO-8859-7\", `ISO-8859-7`()),\n      (\"ISO-8859-9\", `ISO-8859-9`()),\n      (\"ISO-8859-13\", `ISO-8859-13`()),\n      (\"ISO-8859-15\", `ISO-8859-15`()),\n      (\"KOI8-R\", `KOI8-R`()),\n      (\"UTF-8\", `UTF-8`()),\n      (\"UTF-16\", `UTF-16`()),\n      (\"UTF-16BE\", `UTF-16BE`()),\n      (\"UTF-16LE\", `UTF-16LE`())\n  )\n\n  def lookup(enc: String): Encoding = allEncodings(enc)\n\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/actor.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport scala.concurrent._\nimport scala.util._\n\nsealed trait ActorResponse[+T, +S]\n\ncase class Reply[+T](reply: T) extends ActorResponse[T, Nothing] {\n  def andUpdate[S](state: S) = Update[T, S](reply, state)\n}\ncase class Update[+T, +S](reply: T, state: S) extends ActorResponse[T, S]\ncase object Ignore extends ActorResponse[Nothing, Nothing]\n\nobject Actor {\n  class ActorOf[Msg] {\n    def apply[Res, State](init: State)(fn: Transition[Msg, State] => ActorResponse[Res, State])(\n        implicit ec: ExecutionContext): Actor[Msg, Res, State] =\n      new Actor[Msg, Res, State](init) {\n        def handle(trans: Transition[Msg, State]): ActorResponse[Res, State] = fn(trans)\n      }\n  }\n\n  def of[Msg] = new ActorOf[Msg]\n}\n\ncase class IgnoredException() extends Exception(\"Message was ignored\")\n\nabstract class Actor[Msg, Res, State](init: State)(implicit executionContext: ExecutionContext) {\n\n  private var future: Future[Res] = Future.successful(null.asInstanceOf[Res])\n  private var stateVar: State = init\n\n  protected def enqueue(fn: => ActorResponse[Res, State]): Future[Res] = future.synchronized {\n    val promise = Promise[Res]\n    future = future.andThen {\n      case _ =>\n        val result = Try(fn) match {\n          case Success(Ignore) =>\n            promise.failure(IgnoredException())\n          case Success(Update(r, s)) =>\n            promise.success(r)\n            stateVar = s\n          case Success(Reply(r)) =>\n            promise.success(r)\n          case Failure(err) =>\n            promise.failure(err)\n        }\n    }\n    promise.future\n  }\n\n  def state: State = stateVar\n\n  def cue(msg: Msg): Future[Res] = enqueue { handle(Transition(msg, stateVar)) }\n\n  def handle(trans: Transition[Msg, State]): ActorResponse[Res, State]\n}\n\ncase class Transition[Msg, State](msg: Msg, state: State)\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/alloc.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport language.experimental.macros\nimport scala.reflect._\n\nimport annotation.unchecked._\n\nclass AllocApply[T](val unit: Int) extends AnyVal {\n  def apply()(implicit inst: Alloc0.Invariant[T]): T = inst.instantiate()\n  def apply[P1](p1: P1)(implicit inst: Alloc1.Invariant[T, P1]): T = inst.instantiate(p1)\n  def apply[P1, P2](p1: P1, p2: P2)(implicit inst: Alloc2.Invariant[T, P1, P2]): T = inst.instantiate(p1, p2)\n  def apply[P1, P2, P3](p1: P1, p2: P2, p3: P3)(implicit inst: Alloc3.Invariant[T, P1, P2, P3]): T =\n    inst.instantiate(p1, p2, p3)\n  def apply[P1, P2, P3, P4](p1: P1, p2: P2, p3: P3, p4: P4)(implicit inst: Alloc4.Invariant[T, P1, P2, P3, P4]): T =\n    inst.instantiate(p1, p2, p3, p4)\n}\n\nobject Alloc0 {\n  implicit def alloc0[T]: Alloc0[T] = macro CoreMacros.allocMacro[T]\n  type Invariant[+T] = Alloc0[T @uncheckedVariance]\n}\n\nobject Alloc1 {\n  implicit def alloc1[T, P1]: Alloc1[T, P1] = macro CoreMacros.allocMacro1[T, P1]\n  type Invariant[+T, P1] = Alloc1[T @uncheckedVariance, P1]\n}\n\nobject Alloc2 {\n  implicit def alloc2[T, P1, P2]: Alloc2[T, P1, P2] = macro CoreMacros.allocMacro2[T, P1, P2]\n  type Invariant[+T, P1, P2] = Alloc2[T @uncheckedVariance, P1, P2]\n}\n\nobject Alloc3 {\n  implicit def alloc3[T, P1, P2, P3]: Alloc3[T, P1, P2, P3] = macro CoreMacros.allocMacro3[T, P1, P2, P3]\n  type Invariant[+T, P1, P2, P3] = Alloc3[T @uncheckedVariance, P1, P2, P3]\n}\n\nobject Alloc4 {\n  implicit def alloc4[T, P1, P2, P3, P4]: Alloc4[T, P1, P2, P3, P4] = macro CoreMacros.allocMacro4[T, P1, P2, P3, P4]\n  type Invariant[+T, P1, P2, P3, P4] = Alloc4[T @uncheckedVariance, P1, P2, P3, P4]\n}\n\n@implicitNotFound(\"No constructor exists for instantiating an object of this type\")\ntrait Alloc0[T] { def instantiate(): T }\n\n@implicitNotFound(\"No constructor exists for instantiating an object of this type\")\ntrait Alloc1[T, P1] { def instantiate(p1: P1): T }\n\n@implicitNotFound(\"No constructor exists for instantiating an object of this type\")\ntrait Alloc2[T, P1, P2] { def instantiate(p1: P1, p2: P2): T }\n\n@implicitNotFound(\"No constructor exists for instantiating an object of this type\")\ntrait Alloc3[T, P1, P2, P3] { def instantiate(p1: P1, p2: P2, p3: P3): T }\n\n@implicitNotFound(\"No constructor exists for instantiating an object of this type\")\ntrait Alloc4[T, P1, P2, P3, P4] { def instantiate(p1: P1, p2: P2, p3: P3, p4: P4): T }\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/app.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nobject Main extends App {\n  Console.println(\"Running this JAR file does nothing. To use it, please include it on your classpath.\")\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/core.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport language.experimental.macros\nimport language.higherKinds\n\nobject AssignedName {\n  implicit def assignedNameImplicit: AssignedName = macro CoreMacros.assignedNameMacro\n}\ncase class AssignedName(name: String) extends AnyVal {\n  override def toString = s\"`$name`\"\n}\n\nobject MethodName {\n  implicit def assignedMethodNameImplicit: MethodName = macro CoreMacros.assignedMethodNameMacro\n}\nclass MethodName(val name: String) extends AnyVal\n\ntrait Cell[T] {\n  def apply(): T\n  def update(t: T): Unit\n}\n\nobject Cell {\n  def apply[T](get: => T)(set: T => Unit): Cell[T] = new Cell[T] {\n    def apply() = get\n    def update(t: T) = set(t)\n  }\n}\n\nobject Var {\n  def apply[T](t: T) = new Cell[T] {\n    private var value = t\n    def apply(): T = value\n    def update(t: T) = value = t\n  }\n}\n\n\nobject OptionalParameter {\n  implicit def autoWrapSpecifiedParameter[T](value: T): OptionalParameter[T] = SpecifiedParameter[T](value)\n}\n\nsealed trait OptionalParameter[+T] { def apply(): Option[T] }\n\n\nobject SeqParameter {\n  implicit def listToSeqParameter[T](seq: Seq[T]): SeqParameter[T] =\n    SeqParameter(seq: _*)\n  \n  implicit def optionToSeqParameter[T](opt: Option[T]): SeqParameter[T] =\n    SeqParameter(opt.to[Seq]: _*)\n  \n  implicit def anyToSeqParameter[T](value: T): SeqParameter[T] = SeqParameter(value)\n}\n\ncase class SeqParameter[T](elements: T*)\n\n\n\ncase class SpecifiedParameter[+T] (value: T) extends OptionalParameter[T] {\n  def apply(): Option[T] = Some(value)\n}\n\ncase object UnspecifiedParameter extends OptionalParameter[Nothing] {\n  def apply(): Option[Nothing] = None\n}\n\n\nobject Annex {\n  implicit def annexValueWithTypeclass[V, Tc[_]](v: V)(implicit tc: Tc[V]): Annex[Tc] =\n    new Annex[Tc] {\n      type Value = V\n      def value: Value = v\n      def typeclass: Tc[Value] = tc\n    }\n}\n\nabstract class Annex[Typeclass[_]] {\n  type Value\n  def value: Value\n  def typeclass: Typeclass[Value]\n  def apply[Return](fn: Typeclass[Value] => Value => Return): Return = fn(typeclass)(value)\n}\n\n\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/default.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nprivate[core] trait DefaultsTo_1 {\n  implicit def fallbackDefaultsTo[T, S]: DefaultsTo[T, S] = null.asInstanceOf[DefaultsTo[T, S]]\n}\n\nobject DefaultsTo extends DefaultsTo_1 {\n  implicit def defaultDefaultsTo[T]: DefaultsTo[T, T] = null.asInstanceOf[DefaultsTo[T, T]]\n}\n\ntrait DefaultsTo[T, S]\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/functor.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport scala.reflect.ClassTag\nimport language.higherKinds\n\ntrait Functor[+F[x] <: Functor[F, x], A] { functor =>\n  type Throws <: Exception\n\n  protected def rawMap[B](fn: (A, Mode[_ <: MethodConstraint]) => B): F[B]\n\n  def map[B](fn: A => B): F[B] { type Throws = functor.Throws with Exception } =\n    emap[Exception](fn)\n\n  def emap[E <: Exception]: Emap[E] = new Emap[E]()\n\n  def smap[B](fn: A => B): F[B] { type Throws = functor.Throws } =\n    emap[Nothing](fn).asInstanceOf[F[B] { type Throws = functor.Throws }]\n\n  // FIXME: Make this a value class\n  class Emap[E <: Exception]() {\n    def apply[B](fn: A => B)(implicit tt: ClassTag[E]): F[B] { type Throws = functor.Throws with E } =\n      functor.rawMap {\n        case (a, m) =>\n          try fn(a)\n          catch { case e: Exception => m.exception[B, E](e.asInstanceOf[E]) }\n      }.asInstanceOf[F[B] { type Throws = functor.Throws with E }]\n  }\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/macros.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport rapture.base._\nimport scala.reflect._\n\nprivate[core] object CoreMacros {\n  def enumerateMacro[Cls: c.WeakTypeTag, T: c.WeakTypeTag](c: BlackboxContext)(value: c.Expr[Cls]): c.Expr[List[T]] = {\n\n    import c.universe._\n    import compatibility._\n\n    val cls = weakTypeOf[Cls]\n    val allMethods = weakTypeOf[Cls].members.to[List].filter(_.isMethod).map(_.asMethod)\n    val matchingMethods = allMethods filter { m =>\n      paramLists(c)(m).isEmpty && m.returnType.weak_<:<(weakTypeOf[T])\n    }\n    val methodNames = matchingMethods map { m =>\n      Select(value.tree, termName(c, m.name.toString))\n    }\n    val listApply = Select(reify(List).tree, termName(c, \"apply\"))\n\n    c.Expr[List[T]](Apply(listApply, methodNames))\n  }\n\n  def assignedMethodNameMacro(c: BlackboxContext): c.Expr[MethodName] = {\n    import c.universe._\n    import compatibility._\n\n    val name = enclosingDef(c)(c.macroApplication.pos).map { name =>\n      c.Expr[MethodName](q\"new _root_.rapture.core.MethodName(${name.decodedName.toString.trim})\")\n    }\n    \n    name getOrElse c.abort(c.enclosingPosition, \"this method invocation must be assigned to a named identifier.\")\n  }\n\n  object AssignedNameMacroState {\n    var lastPoint: Option[api.Position] = None\n    var assignmentCount: Int = 0\n  }\n\n  def assignedNameMacro(c: BlackboxContext): c.Expr[AssignedName] = {\n    import c.universe._\n    import AssignedNameMacroState._\n    import compatibility._\n\n    val currentPoint = c.macroApplication.pos\n\n    if(Some(currentPoint) != lastPoint) assignmentCount = 0\n\n    val name = enclosingVals(c)(currentPoint, assignmentCount).map { name =>\n      c.Expr[AssignedName](q\"_root_.rapture.core.AssignedName(${name.decodedName.toString.trim})\")\n    }\n\n    lastPoint = Some(currentPoint)\n    assignmentCount += 1\n\n    name getOrElse c.abort(c.enclosingPosition, \"this method invocation must be assigned to a named identifier.\")\n  }\n\n  def allocMacro[T: c.WeakTypeTag](c: BlackboxContext): c.Expr[Alloc0[T]] = {\n    import c.universe._\n    import compatibility._\n\n    val construction = c.Expr[T](Apply(Select(New(TypeTree(weakTypeOf[T])), constructor(c)), List()))\n    reify { new Alloc0[T] { def instantiate(): T = construction.splice } }\n  }\n\n  def allocMacro1[T: c.WeakTypeTag, P1: c.WeakTypeTag](c: BlackboxContext): c.Expr[Alloc1[T, P1]] = {\n    import c.universe._\n    import compatibility._\n\n    val construction =\n      c.Expr[T](Apply(Select(New(TypeTree(weakTypeOf[T])), constructor(c)), List(Ident(termName(c, \"p1\")))))\n\n    reify { new Alloc1[T, P1] { def instantiate(p1: P1): T = construction.splice } }\n  }\n\n  def allocMacro2[T: c.WeakTypeTag, P1: c.WeakTypeTag, P2: c.WeakTypeTag](\n      c: BlackboxContext): c.Expr[Alloc2[T, P1, P2]] = {\n\n    import c.universe._\n    import compatibility._\n\n    val construction = c.Expr[T](\n        Apply(Select(New(TypeTree(weakTypeOf[T])), constructor(c)),\n              List(Ident(termName(c, \"p1\")), Ident(termName(c, \"p2\")))))\n    reify { new Alloc2[T, P1, P2] { def instantiate(p1: P1, p2: P2): T = construction.splice } }\n  }\n\n  def allocMacro3[T: c.WeakTypeTag, P1: c.WeakTypeTag, P2: c.WeakTypeTag, P3: c.WeakTypeTag](\n      c: WhiteboxContext): c.Expr[Alloc3[T, P1, P2, P3]] = {\n\n    import c.universe._\n    import compatibility._\n\n    val construction = c.Expr[T](\n        Apply(Select(New(TypeTree(weakTypeOf[T])), constructor(c)),\n              List(Ident(termName(c, \"p1\")), Ident(termName(c, \"p2\")), Ident(termName(c, \"p3\")))))\n\n    reify { new Alloc3[T, P1, P2, P3] { def instantiate(p1: P1, p2: P2, p3: P3): T = construction.splice } }\n  }\n\n  def allocMacro4[T: c.WeakTypeTag, P1: c.WeakTypeTag, P2: c.WeakTypeTag, P3: c.WeakTypeTag, P4: c.WeakTypeTag](\n      c: WhiteboxContext): c.Expr[Alloc4[T, P1, P2, P3, P4]] = {\n\n    import c.universe._\n    import compatibility._\n\n    val construction = c.Expr[T](\n        Apply(Select(New(TypeTree(weakTypeOf[T])), constructor(c)),\n              List(Ident(termName(c, \"p1\")),\n                   Ident(termName(c, \"p2\")),\n                   Ident(termName(c, \"p3\")),\n                   Ident(termName(c, \"p4\")))))\n\n    reify {\n      new Alloc4[T, P1, P2, P3, P4] { def instantiate(p1: P1, p2: P2, p3: P3, p4: P4): T = construction.splice }\n    }\n  }\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/med.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nobject MinimumEditDistance {\n  def difference(a: String, b: String): Int = {\n    var d = Vector.fill(a.length + 1)(Vector.fill(b.length + 1)(0))\n    (0 to b.length).foreach { j =>\n      (0 to a.length).foreach { i =>\n        if (i == 0 || j == 0) d = d.updated(i, d(i).updated(j, i + j))\n        else if (a(i - 1) == b(j - 1)) d = d.updated(i, d(i).updated(j, d(i - 1)(j - 1)))\n        else d = d.updated(i, d(i).updated(j, List(d(i - 1)(j), d(i)(j - 1), d(i - 1)(j - 1)).min + 1))\n      }\n    }\n    d(a.length)(b.length)\n  }\n\n  def filterStrings(words: Array[String], word: String, limit: Int): List[String] = {\n    val arr = new Array[Int](256)\n    val results = new collection.mutable.ListBuffer[String]\n\n    for (i <- 0 to 15) {\n      arr(i) = i\n      arr(16 * i) = i\n    }\n\n    def difference(d: Array[Int], a: String): Int = {\n      val amax = math.min(a.length, 15)\n      val t = amax + word.length\n      var i, j, n = 0\n      var min = Int.MaxValue\n      var cont = true\n      while (n <= t && cont) {\n        val r =\n          if (i == 0 || j == 0) i + j\n          else if (a(i - 1) == word(j - 1)) d(16 * (i - 1) + j - 1)\n          else math.min(math.min(d(16 * (i - 1) + j), d(16 * i + j - 1)), d(16 * (i - 1) + j - 1)) + 1\n\n        min = math.min(min, r)\n        d(16 * i + j) = r\n\n        if (j == 0 || i == amax) {\n          n += 1\n          if (n <= word.length) { j = n; i = 0 } else { i = n - word.length; j = word.length }\n          if (min > limit) cont = false\n          min = Int.MaxValue\n        } else {\n          i += 1\n          j -= 1\n        }\n      }\n\n      if (cont) d(16 * amax + word.length) else Int.MaxValue\n    }\n\n    val len = word.length\n\n    words.filter { w =>\n      difference(arr, w.take(len)) <= limit\n    }.to[List]\n  }\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/modes.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport language.{existentials, higherKinds}\nimport scala.reflect._\nimport scala.util._\nimport scala.concurrent._\n\ntrait MethodConstraint\n\nobject Mode extends Mode_1 {\n  abstract class Import[M[G <: MethodConstraint] <: Mode[G]] {\n    def apply[G <: MethodConstraint](): M[G] = modeImplicit[G]\n    implicit def modeImplicit[G <: MethodConstraint]: M[G] = mode[G]\n    protected def mode[G <: MethodConstraint]: M[G]\n  }\n}\n\n@implicitNotFound(\n    msg = \"No implicit mode was available for $\"+\"{Group} methods. \" +\n        \"Please import a member of rapture.core.modes, e.g. modes.throwExceptions.\")\ntrait Mode[+Group <: MethodConstraint] { mode =>\n  type Wrap[+_, _ <: Exception]\n  def wrap[Res, E <: Exception](blk: => Res): Wrap[Res, E]\n\n  def flatWrap[Res, E <: Exception: ClassTag](blk: => Wrap[Res, E]): Wrap[Res, E] =\n    wrap(unwrap(blk))\n\n  var callPath = \"_\"\n\n  def unwrap[Res](value: => Wrap[Res, _ <: Exception]): Res\n  def unwrap[Res](value: => Wrap[Res, _ <: Exception], path: String): Res = {\n    val oldCallPath = callPath\n    callPath += path\n    val res = unwrap[Res](value)\n    callPath = oldCallPath\n    res\n  }\n\n  def generic[C <: MethodConstraint]: Mode[C] { type Wrap[+T, E <: Exception] = mode.Wrap[T, E] } =\n    this.asInstanceOf[Mode[C] { type Wrap[+T, E <: Exception] = mode.Wrap[T, E] }]\n\n  def compose[Group2 <: MethodConstraint](mode2: Mode[Group2]) = new Mode[Group] {\n    type Wrap[+Res, E <: Exception] = mode.Wrap[mode2.Wrap[Res, E], E]\n\n    def wrap[Res, E <: Exception](blk: => Res): Wrap[Res, E] =\n      mode.wrap(mode2.wrap(blk))\n\n    def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return =\n      mode2.unwrap(mode.unwrap(value))\n  }\n\n  def catching[E <: Exception: ClassTag, T](blk: => T) =\n    try blk\n    catch {\n      case e: E => exception(e)\n      case e: Exception => throw e\n    }\n\n  def safe[T](blk: => T): T = {\n    try blk\n    catch { case e: Exception => exception(e) }\n  }\n  def exception[T, E <: Exception: ClassTag](e: E, continue: Boolean = true): T = throw e\n\n  def wrapEither[Res, E <: Exception: ClassTag](blk: => Either[E, Res]): Wrap[Res, E] =\n    wrap {\n      blk match {\n        case Left(e) => throw e\n        case Right(r) => r\n      }\n    }\n\n  def wrapOption[Res](blk: => Option[Res]): Wrap[Res, Exception] = wrap(blk.get)\n\n  def wrapTry[Res, E <: Exception: ClassTag](blk: => Try[Res]): Wrap[Res, E] =\n    wrap(blk.get)\n}\n\nobject repl {\n\n  var showStackTraces: Boolean = false\n  private var lastExceptionValue: Throwable = new SilentException\n\n  def lastException: Nothing = throw lastExceptionValue\n\n  implicit def modeImplicit[Group <: MethodConstraint] = new Repl[Group]\n\n  class SilentException extends Throwable {\n    override def printStackTrace(pw: java.io.PrintWriter) = ()\n  }\n\n  class Repl[+Group <: MethodConstraint] extends Mode[Group] {\n\n    type Wrap[+Return, E <: Exception] = T2 forSome { type T2 <: Return }\n    def wrap[Return, E <: Exception](blk: => Return): Return =\n      try blk\n      catch {\n        case e: Exception =>\n          if (showStackTraces) throw e\n          else {\n            Console.println(\"Execution failed with exception: \" + e.toString)\n            Console.print(\"For the full stacktrace, see repl.lastException.\")\n            lastExceptionValue = e\n            throw new SilentException()\n          }\n      }\n\n    def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = value\n  }\n}\n\npackage modes {\n\n  object throwExceptions extends Mode.Import[ThrowExceptionsMode] {\n    protected def mode[G <: MethodConstraint] = new ThrowExceptionsMode[G]\n  }\n\n  object explicit extends Mode.Import[ExplicitMode] {\n    protected def mode[G <: MethodConstraint] = new ExplicitMode[G]\n  }\n\n  /*object returnEither extends Mode.Import[ReturnEitherMode] {\n    protected def mode[G <: MethodConstraint] = new ReturnEitherMode[G]\n  }*/\n\n  object returnResult extends Mode.Import[ReturnResultMode] {\n    protected def mode[G <: MethodConstraint] = new ReturnResultMode[G]\n  }\n\n  object returnTry extends Mode.Import[ReturnTryMode] {\n    protected def mode[G <: MethodConstraint] = new ReturnTryMode[G]\n  }\n\n  object exponentialBackoff extends Mode.Import[ExponentialBackoffMode] {\n    protected def mode[G <: MethodConstraint] = new ExponentialBackoffMode[G]()\n  }\n\n  object keepCalmAndCarryOn extends Mode.Import[KeepCalmAndCarryOnMode] {\n    protected def mode[G <: MethodConstraint] = new KeepCalmAndCarryOnMode[G]()\n  }\n\n  object returnOption extends Mode.Import[ReturnOptionMode] {\n    protected def mode[G <: MethodConstraint] = new ReturnOptionMode[G]()\n  }\n\n  object returnFuture {\n    implicit def modeImplicit[G <: MethodConstraint](implicit ec: ExecutionContext) =\n      new ReturnFutureMode[G]\n\n    def apply[G <: MethodConstraint](implicit ec: ExecutionContext) = modeImplicit[G]\n  }\n\n  object timeExecution {\n    implicit def modeImplicit[D: TimeSystem.ByDuration, G <: MethodConstraint] =\n      new TimeExecution[D, G]\n\n    def apply[D: TimeSystem.ByDuration, G <: MethodConstraint] = modeImplicit[D, G]\n  }\n\n  class Explicitly[+Res, E <: Exception](blk: => Res) {\n    def get: Res = blk\n    def opt: Option[Res] = returnOption[Nothing].wrap(blk)\n    def getOrElse[Res2 >: Res](t: Res2): Res2 = opt.getOrElse(blk)\n    //def either: Either[E, Res] = returnEither[Nothing].wrap(blk)\n    def attempt: Try[Res] = returnTry[Nothing].wrap(blk)\n    def backoff(maxRetries: Int = 10, initialPause: Long = 1000L, backoffRate: Double = 2.0): Res =\n      new ExponentialBackoffMode(maxRetries, initialPause, backoffRate).wrap(blk)\n    def time[D: TimeSystem.ByDuration] = timeExecution[D, Nothing].wrap(blk)\n    def future(implicit ec: ExecutionContext): Future[Res] = returnFuture[Nothing].wrap(blk)\n\n    override def toString = \"<unevaluated result>\"\n  }\n\n}\n\nprivate[core] trait Mode_1 {\n  implicit def defaultMode: ThrowExceptionsMode[Nothing] = new ThrowExceptionsMode\n}\n\nprivate[core] class ThrowExceptionsMode[+G <: MethodConstraint] extends Mode[G] {\n  type Wrap[+T, E <: Exception] = T2 forSome { type T2 <: T  }\n  def wrap[T, E <: Exception](t: => T): T = t\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = value\n}\n\nprivate[core] class ExplicitMode[+G <: MethodConstraint] extends Mode[G] {\n  type Wrap[+T, E <: Exception] = modes.Explicitly[T, E]\n\n  def wrap[T, E <: Exception](t: => T): modes.Explicitly[T, E] =\n    new modes.Explicitly[T, E](t)\n\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = value.get\n}\n\nprivate[core] class ReturnTryMode[+G <: MethodConstraint] extends Mode[G] {\n  type Wrap[+T, E <: Exception] = Try[T]\n  def wrap[T, E <: Exception](t: => T): Try[T] = Try(t)\n\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = value.get\n\n  override def toString = \"[modes.returnTry]\"\n}\n\nprivate[core] class ExponentialBackoffMode[+G <: MethodConstraint](maxRetries: Int = 10,\n                                                                   initialPause: Long = 1000L,\n                                                                   backoffRate: Double = 2.0)\n    extends Mode[G] {\n  type Wrap[+T, E <: Exception] = T2 forSome { type T2 <: T }\n  def wrap[T, E <: Exception](t: => T): T = {\n    var multiplier = 1.0\n    var count = 1\n    var result: T = null.asInstanceOf[T]\n    var exception: Exception = null.asInstanceOf[Exception]\n    while (result == null && count < maxRetries) try { result = t } catch {\n      case e: Exception =>\n        exception = e\n        import timeSystems.numeric._\n        Thread.sleep((multiplier * initialPause).toLong)\n        multiplier *= backoffRate\n        count += 1\n    }\n    if (result != null) result else throw exception\n  }\n\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = value\n}\n\nprivate[core] class KeepCalmAndCarryOnMode[+G <: MethodConstraint] extends Mode[G] {\n  type Wrap[+T, E <: Exception] = T2 forSome { type T2 <: T }\n  def wrap[T, E <: Exception](t: => T): T =\n    try t\n    catch { case e: Exception => null.asInstanceOf[T] }\n\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = Option[Return](value).get\n\n  override def toString = \"[modes.kcaco]\"\n}\n\nprivate[core] class ReturnOptionMode[+G <: MethodConstraint] extends Mode[G] {\n  type Wrap[+T, E <: Exception] = Option[T]\n  def wrap[T, E <: Exception](t: => T): Option[T] =\n    try Some(t)\n    catch { case e: Exception => None }\n\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = value.get\n\n  override def toString = \"[modes.returnOption]\"\n}\n\nprivate[core] class ReturnFutureMode[+G <: MethodConstraint](implicit ec: ExecutionContext) extends Mode[G] {\n  type Wrap[+T, E <: Exception] = Future[T]\n  def wrap[T, E <: Exception](t: => T): Future[T] = Future { t }\n\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return =\n    Await.result(value, duration.Duration.Inf)\n\n  override def flatWrap[Res, E <: Exception: ClassTag](blk: => Wrap[Res, E]): Wrap[Res, E] = blk\n\n  override def toString = \"[modes.returnFuture]\"\n}\n\nprivate[core] class TimeExecution[D: TimeSystem.ByDuration, +G <: MethodConstraint] extends Mode[G] {\n  val ts = ?[TimeSystem.ByDuration[D]]\n  type Wrap[+T, E <: Exception] = (T, D)\n  def wrap[T, E <: Exception](r: => T): (T, D) = {\n    val t0 = System.currentTimeMillis\n    (r, ts.duration(t0, System.currentTimeMillis))\n  }\n\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = value._1\n\n  override def toString = \"[modes.timeExecution]\"\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport language.higherKinds\nimport language.experimental.macros\nimport reflect.runtime.universe._\nimport reflect.ClassTag\n\nobject `package` {\n\n  type CanBuildFrom[-From, -Elem, +To] = collection.generic.CanBuildFrom[From, Elem, To]\n\n  def alloc[T] = new AllocApply[T](0)\n\n  def each[E <: Exception] = EachUnapplied[E]()\n\n  implicit class EnrichedString(val string: String) extends AnyVal {\n    def as[T](implicit parser: StringParser[T], mode: Mode[`String#as`]): mode.Wrap[T, parser.Throws] =\n      parser.parse(string, mode)\n  }\n\n  def indentTree(s: String): String = {\n    var indent = 0\n    s flatMap {\n      case '(' => indent += 1; s\"(\\n${\"  \" * indent}\"\n      case ')' => indent -= 1; s\"\\n${\"  \" * indent})\"\n      case ',' => s\",\\n${\"  \" * (indent - 1)}\"\n      case ' ' => \"\"\n      case o => o.toString\n    }\n  }\n\n  implicit class EnrichedCollection[Coll[X] <: Seq[X]](val coll: Coll[String]) extends AnyVal {\n    def mapAs[T](implicit parser: StringParser[T],\n                 cbf: CanBuildFrom[Coll[String], T, Coll[T]],\n                 mode: Mode[`Seq#mapAs`]): mode.Wrap[Coll[T], parser.Throws] = mode.wrap[Coll[T], parser.Throws] {\n      val b = cbf(coll)\n      coll foreach { x =>\n        b += mode.unwrap(parser.parse(x, mode))\n      }\n      b.result\n    }\n  }\n\n  private[rapture] type implicitNotFound = annotation.implicitNotFound\n\n  private[rapture] implicit val implicitConversions: languageFeature.implicitConversions = language.implicitConversions\n\n  @inline\n  final def ?[T](implicit t: T) = t\n\n  def modally[G <: MethodConstraint, E <: Exception] = new Modal[G, E]\n\n  def yCombinator[A, B](fn: (A => B) => (A => B)): A => B = fn(yCombinator(fn))(_)\n\n  /** Times how long it takes to perform an operation, returning a pair of the result and the\n    * duration of the operation in milliseconds. */\n  def time[T, D: TimeSystem.ByDuration](blk: => T): (T, D) = {\n    val t = System.currentTimeMillis\n    (blk, ?[TimeSystem.ByDuration[D]].duration(t, System.currentTimeMillis))\n  }\n\n  def enumerateMembers[T] = new Enumerator[T]\n\n  @inline\n  implicit class SeqExtras[A, C[A] <: Seq[A]](val xs: C[A]) {\n\n    /** Inserts an element between each of the elements of the sequence. */\n    def intersperse[B >: A, That](between: B)(implicit bf: CanBuildFrom[C[A], B, That]): That = {\n      val b = bf(xs)\n      xs.init foreach { x =>\n        b += x\n        b += between\n      }\n      b += xs.last\n      b.result\n    }\n\n    /** Inserts an element between each of the elements of the sequence, and additionally\n      * prepends and affixes the sequence with `before` and `after`. */\n    def intersperse[B >: A, That](before: B, between: B, after: B)(implicit bf: CanBuildFrom[C[A], B, That]): That = {\n      val b = bf(xs)\n      b += before\n      xs.init foreach { x =>\n        b += x\n        b += between\n      }\n      b += xs.last\n      b += after\n      b.result\n    }\n\n    /** Convenience method for zipping a sequence with a value derived from each element. */\n    def zipWith[T](fn: A => T)(implicit bf: CanBuildFrom[C[A], (A, T), C[(A, T)]]): C[(A, T)] = {\n      val b = bf(xs)\n      xs.foreach { x =>\n        b += ((x, fn(x)))\n      }\n      b.result\n    }\n  }\n\n  implicit class EnrichedCollectionCompanion[+C[X] <: collection.GenTraversable[X]](\n      val cc: collection.generic.GenericCompanion[C])\n      extends AnyVal {\n    def strap[T](xs: Strapped[T]*): C[T] = {\n      val b = cc.newBuilder[T]\n      xs foreach { b ++= _.elems }\n      b.result()\n    }\n  }\n\n  implicit class EnrichedArrayCompanion(val arr: Array.type) extends AnyVal {\n    def strap[T: ClassTag](xs: Strapped[T]*): Array[T] = {\n      val b = Array.newBuilder[T]\n      xs foreach { b ++= _.elems }\n      b.result()\n    }\n  }\n\n  implicit class EitherExtras[L, R](either: Either[L, R]) {\n    def bimap[T](leftFn: L => T, rightFn: R => T) = either match {\n      case Left(left) => leftFn(left)\n      case Right(right) => rightFn(right)\n    }\n  }\n}\n\ntrait `Seq#mapAs` extends MethodConstraint\ntrait `String#as` extends MethodConstraint\n\nprivate[core] object Strapped {\n  implicit def basicStrapping[T](t: T): Strapped[T] = Strapped(List(t))\n  implicit def iterableStrapping[T](elems: Iterable[T]): Strapped[T] = Strapped(elems)\n  implicit def optionStrapping[T](opt: Option[T]): Strapped[T] = Strapped(opt.toList)\n}\n\nprivate[core] case class Strapped[+T](elems: Iterable[T]) extends AnyVal\n\nprivate[core] class Enumerator[T] {\n  def apply[Cls](value: Cls): List[T] = macro CoreMacros.enumerateMacro[Cls, T]\n}\n\nprivate[core] class Modal[G <: MethodConstraint, E <: Exception] {\n  def apply[T](fn: => T)(implicit mode: Mode[G], typeTag: TypeTag[E]): mode.Wrap[T, E] = mode.wrap(fn)\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/parser.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport scala.util.Try\n\nobject ParseException\ncase class ParseException(bad: String, typ: String) extends Exception(s\"could not parse '$bad' as $typ\")\n\npackage booleanParsing {\n  object strict {\n    def apply() = implicitBooleanParsing\n    implicit def implicitBooleanParsing(implicit br: BooleanRepresentation): BooleanParser =\n      new BooleanParser {\n        def parse(s: String, mode: Mode[_]): mode.Wrap[Boolean, InvalidBoolean] = mode.wrap {\n          if (s == br.trueValue) true\n          else if (s == br.falseValue) false\n          else mode.exception(InvalidBoolean(s))\n        }\n      }\n  }\n\n  object permissive {\n    def apply(): BooleanParser = implicitBooleanParsing\n    private val trueValues = List(\"true\", \"yes\", \"on\", \"1\")\n    private val falseValues = List(\"false\", \"no\", \"off\", \"0\")\n    implicit val implicitBooleanParsing: BooleanParser = new BooleanParser {\n      def parse(b: String, mode: Mode[_]): mode.Wrap[Boolean, InvalidBoolean] = mode.wrap {\n        if (trueValues.contains(b.toLowerCase)) true\n        else if (falseValues.contains(b.toLowerCase)) false\n        else mode.exception(ParseException(b, \"boolean using permissive parser\"))\n      }\n    }\n  }\n}\n\nobject BooleanParser { implicit val implicitBooleanParser: BooleanParser = booleanParsing.permissive() }\ntrait BooleanParser { def parse(s: String, mode: Mode[_]): mode.Wrap[Boolean, InvalidBoolean] }\n\nabstract class StringParser[T] extends Functor[StringParser, T] { strp =>\n  type Throws <: Exception\n  def parse(string: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, Throws]\n\n  def rawMap[T2](fn: (T, Mode[_ <: MethodConstraint]) => T2): StringParser[T2] { type Throws = strp.Throws } =\n    new StringParser[T2] {\n      type Throws = strp.Throws\n      def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[T2, Throws] =\n        mode.wrap(fn(mode.unwrap(strp.parse(s, mode)), mode))\n    }\n}\n\ncase class InvalidBoolean(value: String) extends Exception(s\"\"\"The value \"$value\" is not a valid boolean.\"\"\")\ncase class InvalidNumber(value: String, numberType: String)\n    extends Exception(s\"\"\"The value \"$value\" is not a valid $numberType.\"\"\")\n\ntrait StringParser_1 {\n  implicit def optParser[T: StringParser]: StringParser[Option[T]] { type Throws = Nothing } =\n    new StringParser[Option[T]] {\n      type Throws = Nothing\n      def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Option[T], Nothing] = mode.wrap {\n        try Some(mode.unwrap(?[StringParser[T]].parse(s, mode)))\n        catch {\n          case e: Exception => None\n        }\n      }\n    }\n\n  implicit def tryParser[T: StringParser]: StringParser[Try[T]] { type Throws = Nothing } = new StringParser[Try[T]] {\n    type Throws = Nothing\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Try[T], Nothing] = mode.wrap {\n      ?[StringParser[T]].parse(s, modes.returnTry())\n    }\n  }\n}\n\nobject StringParser extends StringParser_1 {\n  def apply[T](f: String => T): StringParser[T] { type Throws = ParseException } = {\n    new StringParser[T] {\n      type Throws = ParseException\n      def parse(str: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, ParseException] = mode.wrap {\n        try f(str)\n        catch {\n          case e: Exception => mode.exception(ParseException(str, e.getMessage))\n        }\n      }\n    }\n  }\n\n  implicit def booleanParser(implicit bp: BooleanParser): StringParser[Boolean] { type Throws = InvalidBoolean } =\n    new StringParser[Boolean] {\n      type Throws = InvalidBoolean\n      def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Boolean, InvalidBoolean] =\n        bp.parse(s, mode.generic)\n    }\n\n  implicit val byteParser: StringParser[Byte] { type Throws = InvalidNumber } = new StringParser[Byte] {\n    type Throws = InvalidNumber\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Byte, InvalidNumber] = mode.wrap {\n      try java.lang.Byte.parseByte(s)\n      catch {\n        case e: NumberFormatException => mode.exception(InvalidNumber(s, \"byte\"))\n      }\n    }\n  }\n\n  implicit val charParser: StringParser[Char] { type Throws = InvalidNumber } = new StringParser[Char] {\n    type Throws = InvalidNumber\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Char, InvalidNumber] = mode.wrap {\n      if (s.length == 1) s.charAt(0) else mode.exception(InvalidNumber(s, \"character\"))\n    }\n  }\n\n  implicit val shortParser: StringParser[Short] { type Throws = InvalidNumber } = new StringParser[Short] {\n    type Throws = InvalidNumber\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Short, InvalidNumber] = mode.wrap {\n      try java.lang.Short.parseShort(s)\n      catch {\n        case e: NumberFormatException => mode.exception(InvalidNumber(s, \"short\"))\n      }\n    }\n  }\n\n  implicit val intParser: StringParser[Int] { type Throws = InvalidNumber } = new StringParser[Int] {\n    type Throws = InvalidNumber\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Int, InvalidNumber] = mode.wrap {\n      try java.lang.Integer.parseInt(s)\n      catch {\n        case e: NumberFormatException => mode.exception(InvalidNumber(s, \"integer\"))\n      }\n    }\n  }\n\n  implicit val longParser: StringParser[Long] { type Throws = InvalidNumber } = new StringParser[Long] {\n    type Throws = InvalidNumber\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Long, InvalidNumber] = mode.wrap {\n      try java.lang.Long.parseLong(s)\n      catch {\n        case e: NumberFormatException => mode.exception(InvalidNumber(s, \"long\"))\n      }\n    }\n  }\n\n  implicit val stringParser: StringParser[String] { type Throws = Nothing } = new StringParser[String] {\n    type Throws = Nothing\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[String, Nothing] = mode.wrap(s)\n  }\n\n  implicit val doubleParser: StringParser[Double] = new StringParser[Double] {\n    type Throws = InvalidNumber\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Double, InvalidNumber] = mode.wrap {\n      try java.lang.Double.parseDouble(s)\n      catch {\n        case e: NumberFormatException => mode.exception(ParseException(s, \"double\"))\n      }\n    }\n  }\n\n  implicit val floatParser: StringParser[Float] = new StringParser[Float] {\n    type Throws = InvalidNumber\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Float, InvalidNumber] = mode.wrap {\n      try java.lang.Float.parseFloat(s)\n      catch {\n        case e: NumberFormatException => mode.exception(InvalidNumber(s, \"float\"))\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/pool.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport scala.collection.mutable\n\n/** Implements a dynamic pool of some resource, e.g. database connections. */\nabstract class Pool[Resource] {\n\n  /** Implement to make new resources. */\n  protected def make(): Resource\n\n  /** Implement to dispose of surplus resources. */\n  protected def dispose(x: Resource): Unit\n\n  /** Implement to check resource is still usable. */\n  protected def check(x: Resource): Boolean\n\n  /** Number of resource to always keep in reserve, if we have them. */\n  protected def spare = 5\n\n  /** How long to leave surplus resources unused before discarding them. */\n  protected def timeout = 10 * 60000L\n\n  private val pool = new mutable.Queue[Resource]\n  private var poolCount = 0\n  private var lastLow = 0L\n\n  /** Acquire a resource for the duration of the body. */\n  def acquireFor[A](body: Resource => A): A = {\n    val res = acquireDirect()\n    try body(res)\n    finally releaseDirect(res)\n  }\n\n  /** Acquire a resource without any nesting guarantees. Avoid this method. */\n  def acquireDirect(): Resource = pool.synchronized {\n    if (poolCount == 0) make()\n    else {\n      val r = pool.dequeue\n      poolCount = poolCount - 1\n      if (check(r)) r\n      else {\n        dispose(r)\n        make()\n      }\n    }\n  }\n\n  /** Release a directly-acquired resource. */\n  def releaseDirect(r: Resource): Unit = pool.synchronized {\n    val now = System.currentTimeMillis()\n    if (poolCount < spare) lastLow = now\n    if (lastLow > now - timeout) {\n      pool.enqueue(r)\n      poolCount = poolCount + 1\n    } else dispose(r)\n  }\n\n  /** Dispose of all resources not currently in use. */\n  def disposeAll() = pool.synchronized {\n    while (poolCount > 0) {\n      dispose(pool.dequeue)\n      poolCount = poolCount - 1\n    }\n  }\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/result.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport scala.language.higherKinds\nimport scala.reflect.ClassTag\n\nimport scala.annotation.unchecked._\n\nobject Result {\n  private[core] def apply[T, E <: Exception](result: => T, errors: Seq[(ClassTag[_], (String, Exception))]) =\n    try {\n      if (errors.isEmpty) Answer[T, E](result) else Errata[T, E](errors)\n    } catch { case e: Throwable => if (errors.isEmpty) Unforeseen[T, E](e) else Errata[T, E](errors) }\n\n  def apply[T](result: => T): Result[T, Nothing] =\n    try Answer[T, Nothing](result)\n    catch { case e: Throwable => Unforeseen[T, Nothing](e) }\n\n  def catching[E <: Exception]: Catching[E] = new Catching[E]()\n\n  /** Construct an answer. */\n  def answer[T, E <: Exception](a: T): Result[T, E] = Answer[T, E](a)\n\n  /** Construct an errata. */\n  def errata[T, E <: Exception](e: E)(implicit cte: ClassTag[E]) = Errata[T, E](e)\n\n}\n\nclass Catching[E <: Exception]() {\n  def apply[T](blk: => T)(implicit classTag: ClassTag[E]): Result[T, E] =\n    try Answer(blk)\n    catch {\n      case e: E => Errata(Vector((?[ClassTag[E]], (\"\", e))))\n      case e: Throwable => Unforeseen(e)\n    }\n}\n\nsealed abstract class Result[+T, E <: Exception](val answer: T,\n                                                 val errors: Seq[(ClassTag[_], (String, Exception))],\n                                                 val unforeseen: Option[Throwable] = None) {\n\n  def errata[E2 >: E: ClassTag]: Seq[E2] =\n    errors.filter(_._1 == ?[ClassTag[E2]]).map(_._2.asInstanceOf[E2])\n\n  def exceptions: Seq[Exception] = errors.map(_._2._2)\n\n  def get: T = {\n    unforeseen.foreach(throw _)\n    errors.foreach { case (k, (p, e)) => throw e }\n    answer\n  }\n\n  def flatMap[T2, E2 <: Exception](fn: T => Result[T2, E2]): Result[T2, E with E2] =\n    try {\n      val res = fn(answer)\n      val probs = res.errors ++ errors\n      Result[T2, E with E2](res.get, probs)\n    } catch {\n      case e: NullPointerException if errors.nonEmpty => Errata[T2, E with E2](errors)\n      case e: Throwable => Unforeseen[T2, E with E2](e)\n    }\n\n  def map[T2](fn: T => T2) = Result[T2, E](fn(answer), errors)\n\n  def resolve[E2, T2 >: T](handlers: Each[E2, T2]*)(implicit ev: E2 <:< E): Resolved[T2, Nothing] = this match {\n    case Unforeseen(e) =>\n      Unforeseen[T2, Nothing](e)\n    case Answer(a) =>\n      Answer[T2, Nothing](a)\n    case Errata((t, (_, err)) +: _) =>\n      Answer[T2, Nothing](handlers.find { case Each(fn, ct) => ct == t }.get.fn(err.asInstanceOf[E2]))\n  }\n\n  def reconcile[E2, E3 <: Exception](handlers: Each[E2, E3]*) = {\n    val hs = handlers.map { case Each(e, typ) => typ -> e }.toMap[ClassTag[_], E2 => E3]\n    errors.map { case (t, (p, e)) => hs(t)(e.asInstanceOf[E2]) }\n  }\n\n  /** Return `true` if this result contains errors. */\n  def isErrata: Boolean =\n    this match {\n      case Errata(_) => true\n      case _ => false\n    }\n\n  /** Return `true` if this result is an Answer. */\n  def isAnswer: Boolean =\n    this match {\n      case Answer(_) => true\n      case _ => false\n    }\n\n  /** Return `true` if this result is Unforeseen. */\n  def isUnforeseen: Boolean =\n    this match {\n      case Unforeseen(_) => true\n      case _ => false\n    }\n\n  /** Catamorphism. Run the first given function if answer, otherwise, the second given function over the errata. */\n  def fold[X](l: T => X, r: Seq[(ClassTag[_], (String, Exception))] => X): X =\n    this match {\n      case Answer(a) => l(a)\n      case Errata(e) => r(e)\n      case Unforeseen(e) => throw e\n    }\n\n  /** Return `true` if this result is an answer satisfying the given predicate. */\n  def exists(p: T => Boolean): Boolean =\n    this match {\n      case Answer(b) => p(b)\n      case _ => false\n    }\n\n  /** Return `true` if this result is an errata or the answer satisfies the given predicate. */\n  def forall(p: T => Boolean): Boolean =\n    this match {\n      case Answer(b) => p(b)\n      case _ => true\n    }\n\n  /** Return a collection containing -- if the result was successful -- the answer. */\n  def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, T, Col[T @uncheckedVariance]]): Col[T @uncheckedVariance] =\n    this match {\n      case Answer(ans) =>\n        val builder = cbf()\n        builder += ans\n        builder.result\n      case _ =>\n        cbf().result\n    }\n\n  /** Return `None` or a `Some` of the answer. Useful to sweep errors under the carpet. */\n  def toOption: Option[T] =\n    this match {\n      case Answer(b) => Some(b)\n      case _ => None\n    }\n\n  /** Convert to a core `scala.Either` at your own peril. blows up if an unforeseen exception is found */\n  def toEither: Either[Seq[(ClassTag[_], (String, Exception))], T] =\n    this match {\n      case Answer(b) => Right(b)\n      case Errata(a) => Left(a)\n      case Unforeseen(e) => throw e\n    }\n\n  /** Return the answer of this result or the given default if errata. Alias for `|` */\n  def getOrElse[T2 >: T](x: => T2): T2 =\n    this match {\n      case Answer(b) => b\n      case _ => x\n    }\n\n  /** Return the answer value of this result or the given default if errata. Alias for `getOrElse` */\n  def |[T2 >: T](x: => T2): T2 =\n    getOrElse(x)\n\n  /** Return the answer of this result or run the given function on the errata. */\n  def valueOr[T2 >: T](x: Seq[(ClassTag[_], (String, Exception))] => T2): T2 =\n    this match {\n      case Answer(b) => b\n      case Errata(a) => x(a)\n      case Unforeseen(e) => throw e\n    }\n\n  /** Filter on the answer of this result. */\n  def filter(p: T => Boolean): Result[T, E with NotMatchingFilter] =\n    this match {\n      case Answer(b) =>\n        val t = this.get\n        if (p(b))\n          Answer(t)\n        else\n          Errata[T, E with NotMatchingFilter](\n              Seq((implicitly[ClassTag[NotMatchingFilter]], (\"\", NotMatchingFilter(t)))))\n      case Errata(e) => Errata[T, E with NotMatchingFilter](e)\n      case Unforeseen(e) => Unforeseen[T, E with NotMatchingFilter](e)\n    }\n\n  /** Alias for filter */\n  def withFilter(p: T => Boolean): Result[T, E with NotMatchingFilter] = filter(p)\n\n}\n\nobject Resolved {\n  def unapply[T, E <: Exception](res: Result[T, E]): Option[(T, Option[Throwable])] =\n    Some(res.answer -> res.unforeseen)\n\n  def apply[T, E <: Exception](answer: T, unforeseen: Option[E]) =\n    if (unforeseen.isEmpty) Answer(answer) else Unforeseen(unforeseen.get)\n}\nsealed abstract class Resolved[+T, E <: Exception](answer: T, unforeseen: Option[Throwable])\n    extends Result[T, E](answer, Seq(), unforeseen) {\n\n  override def equals(that: Any) = that match {\n    case that: Resolved[_, _] => that.answer == answer && that.unforeseen == unforeseen\n    case _ => false\n  }\n\n  override def hashCode = answer.hashCode ^ unforeseen.hashCode\n\n}\n\ncase class Answer[T, E <: Exception](override val answer: T) extends Resolved[T, E](answer, None)\n\ncase class Errata[T, E <: Exception](override val errors: Seq[(ClassTag[_], (String, Exception))])\n    extends Result[T, E](null.asInstanceOf[T], errors) {\n  override def toString =\n    \"Errata(\\n  \" + errors.map { case (t, (p, e)) => s\"$t: ${e.getMessage} [$p]\" }.mkString(\",\\n  \") + \"\\n)\"\n}\n\nobject Errata {\n\n  def apply[T, E <: Exception](e: => E)(implicit classTag: ClassTag[E]): Result[T, E] =\n    Errata(Vector((?[ClassTag[E]], (\"\", e))))\n}\n\ncase class Unforeseen[T, E <: Exception](e: Throwable) extends Resolved[T, E](null.asInstanceOf[T], Some(e))\n\ncase class AbortException() extends Exception\n\nprivate[core] class ReturnResultMode[+Group <: MethodConstraint] extends Mode[Group] {\n  type Wrap[+R, E <: Exception] = Result[R, E]\n\n  def wrap[R, E <: Exception](blk: => R): Result[R, E] = {\n    try {\n      val res = blk\n      Result[R, E](res, accumulated)\n    } catch {\n      case AbortException() =>\n        Result[R, E](null.asInstanceOf[R], accumulated)\n      case e: Throwable =>\n        if (accumulated.isEmpty) Unforeseen[R, E](e)\n        else Errata(accumulated)\n    }\n  }\n\n  private var accumulated: Vector[(ClassTag[_], (String, Exception))] = Vector()\n  override def exception[T, E <: Exception: ClassTag](e: E, continue: Boolean = true): T = {\n    accumulated :+= ((?[ClassTag[E]], (callPath, e)))\n    if (continue) null.asInstanceOf[T] else throw AbortException()\n  }\n\n  override def catching[E <: Exception: ClassTag, T](blk: => T) =\n    try blk\n    catch {\n      case e: E =>\n        exception(e)\n      case e: Exception =>\n        throw e\n    }\n\n  override def flatWrap[R, E <: Exception: ClassTag](blk: => Wrap[R, E]): Wrap[R, E] = blk\n\n  def unwrap[Return](value: => Wrap[Return, _ <: Exception]): Return = value match {\n    case Answer(a) => a\n    case Errata(xs) => null.asInstanceOf[Return]\n    case Unforeseen(e) => throw e\n    case _ => ???\n  }\n\n  override def toString = \"[modes.returnResult]\"\n}\n\ncase class Each[-E, +T](fn: E => T, classTag: ClassTag[_])\ncase class EachUnapplied[E]() {\n  def apply[R](fn: E => R)(implicit classTag: ClassTag[E]): Each[E, R] = Each(fn, classTag)\n}\n\ncase class NotMatchingFilter(value: Any) extends Exception(s\"value '$value' did not match filter\")\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/serializer.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\npackage decimalFormats {\n  object to0dp {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = DecimalPlaces(0)\n  }\n  object to1dp {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = DecimalPlaces(1)\n  }\n  object to2dp {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = DecimalPlaces(2)\n  }\n  object to3dp {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = DecimalPlaces(3)\n  }\n  object to4dp {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = DecimalPlaces(4)\n  }\n  object to5dp {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = DecimalPlaces(5)\n  }\n  object to6dp {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = DecimalPlaces(6)\n  }\n  object to1sf {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = SignificantFigures(1)\n  }\n  object to2sf {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = SignificantFigures(2)\n  }\n  object to3sf {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = SignificantFigures(3)\n  }\n  object to4sf {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = SignificantFigures(4)\n  }\n  object to5sf {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = SignificantFigures(5)\n  }\n  object to6sf {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = SignificantFigures(6)\n  }\n  object exact {\n    def apply() = implicitDecimalFormat\n    implicit val implicitDecimalFormat: DecimalFormat = ExactDecimal\n  }\n}\n\npackage integerFormats {\n  object exact {\n    def apply() = implicitIntegerFormat\n    implicit val implicitIntegerFormat: IntegerFormat = ExactInteger\n  }\n  object to1sf {\n    def apply() = implicitIntegerFormat\n    implicit val implicitIntegerFormat: IntegerFormat = IntegerSignificantFigures(1)\n  }\n  object to2sf {\n    def apply() = implicitIntegerFormat\n    implicit val implicitIntegerFormat: IntegerFormat = IntegerSignificantFigures(2)\n  }\n  object to3sf {\n    def apply() = implicitIntegerFormat\n    implicit val implicitIntegerFormat: IntegerFormat = IntegerSignificantFigures(3)\n  }\n  object to4sf {\n    def apply() = implicitIntegerFormat\n    implicit val implicitIntegerFormat: IntegerFormat = IntegerSignificantFigures(4)\n  }\n  object to5sf {\n    def apply() = implicitIntegerFormat\n    implicit val implicitIntegerFormat: IntegerFormat = IntegerSignificantFigures(5)\n  }\n  object to6sf {\n    def apply() = implicitIntegerFormat\n    implicit val implicitIntegerFormat: IntegerFormat = IntegerSignificantFigures(6)\n  }\n}\n\npackage booleanRepresentations {\n  object trueFalse {\n    def apply() = implicitBooleanRepresentation\n    implicit val implicitBooleanRepresentation: BooleanRepresentation = BooleanRepresentation(\"true\", \"false\")\n  }\n\n  object digital {\n    def apply() = implicitBooleanRepresentation\n    implicit val implicitBooleanRepresentation: BooleanRepresentation = BooleanRepresentation(\"1\", \"0\")\n  }\n\n  object yesNo {\n    def apply() = implicitBooleanRepresentation\n    implicit val implicitBooleanRepresentation: BooleanRepresentation = BooleanRepresentation(\"yes\", \"no\")\n  }\n\n  object onOff {\n    def apply() = implicitBooleanRepresentation\n    implicit val implicitBooleanRepresentation: BooleanRepresentation = BooleanRepresentation(\"on\", \"off\")\n  }\n}\n\nobject BooleanRepresentation {\n  implicit val defaultBooleanRepresentation: BooleanRepresentation = BooleanRepresentation(\"true\", \"false\")\n}\n\ncase class BooleanRepresentation(trueValue: String, falseValue: String)\n\nobject DecimalFormat { implicit val defaultRounding: DecimalFormat = SignificantFigures(4) }\ntrait DecimalFormat { def format(bigDecimal: BigDecimal): String }\n\ncase class DecimalPlaces(n: Int) extends DecimalFormat {\n  def format(bigDecimal: BigDecimal): String = {\n    val integral = bigDecimal.toBigInt.toString.length\n    bigDecimal.round(new java.math.MathContext(integral + n)).setScale(n).toString\n  }\n}\n\ncase class SignificantFigures(n: Int) extends DecimalFormat {\n  def format(bigDecimal: BigDecimal) = bigDecimal.round(new java.math.MathContext(n)).toString\n}\n\ncase object ExactDecimal extends DecimalFormat {\n  def format(bigDecimal: BigDecimal) = bigDecimal.toString\n}\n\nobject IntegerFormat { implicit val defaultRounding: IntegerFormat = ExactInteger }\ntrait IntegerFormat { def format(bigInt: BigInt): String }\n\ncase object ExactInteger extends IntegerFormat {\n  def format(bigInt: BigInt) = bigInt.toString\n}\ncase class IntegerSignificantFigures(n: Int) extends IntegerFormat {\n  def format(bigInt: BigInt) =\n    BigDecimal(bigInt).round(new java.math.MathContext(n)).toString\n}\n\nobject StringSerializer {\n\n  def apply[T](f: T => String): StringSerializer[T] = new StringSerializer[T]{\n    override def serialize(ser: T): String = f(ser)\n  }\n\n  implicit def booleanSerializer(implicit bs: BooleanRepresentation): StringSerializer[Boolean] =\n    StringSerializer{s => if (s) bs.trueValue else bs.falseValue}\n\n  implicit val charSerializer: StringSerializer[Char] = StringSerializer(_.toString)\n\n  implicit def byteSerializer(implicit df: IntegerFormat): StringSerializer[Byte] =\n    StringSerializer{s => df.format(BigInt(s)) }\n\n  implicit def shortSerializer(implicit df: IntegerFormat): StringSerializer[Short] =\n    StringSerializer{s => df.format(BigInt(s)) }\n\n  implicit def longSerializer(implicit df: IntegerFormat): StringSerializer[Long] =\n    StringSerializer{s => df.format(BigInt(s)) }\n\n  implicit def intSerializer(implicit df: IntegerFormat): StringSerializer[Int] =\n    StringSerializer{s => df.format(BigInt(s)) }\n\n  implicit val stringSerializer: StringSerializer[String] = StringSerializer(identity)\n\n  implicit def doubleSerializer(implicit df: DecimalFormat): StringSerializer[Double] =\n    StringSerializer{s => df.format(BigDecimal(s)) }\n\n  implicit def floatSerializer(implicit df: DecimalFormat): StringSerializer[Float] =\n    StringSerializer{f => df.format(BigDecimal(f.toDouble)) }\n\n  implicit def bigDecimalSerializer(implicit df: DecimalFormat): StringSerializer[BigDecimal] =\n    StringSerializer{s => df.format(s) }\n\n  implicit def bigIntSerializer(implicit df: IntegerFormat): StringSerializer[BigInt] =\n    StringSerializer{s => df.format(s) }\n}\n\n/** A generic string serializer */\n@implicitNotFound(\n    \"It is not possible to serialize a value of type $\"+\"{T} to a String without a\" +\n      \" valid StringSerializer instance in scope.\")\ntrait StringSerializer[-T] { stringSerializer =>\n  def serialize(string: T): String\n  def contramap[S](fn: S => T): StringSerializer[S] = new StringSerializer[S] {\n    def serialize(string: S): String = stringSerializer.serialize(fn(string))\n  }\n}\n\nobject String {\n\n  def apply[T: StringSerializer](t: T): String =\n    ?[StringSerializer[T]].serialize(t)\n\n  // Proxied from java.lang.String\n  def format(str: String, any: AnyRef*) = java.lang.String.format(str, any: _*)\n\n  def format(locale: java.util.Locale, str: String, any: AnyRef*) =\n    java.lang.String.format(locale, str, any: _*)\n\n  def copyValueOf(arr: Array[Char]): String = java.lang.String.copyValueOf(arr)\n\n  def vauleOf(x: Array[Char]): String = java.lang.String.valueOf(x)\n  def vauleOf(x: Boolean): String = java.lang.String.valueOf(x)\n  def vauleOf(x: Double): String = java.lang.String.valueOf(x)\n  def vauleOf(x: Int): String = java.lang.String.valueOf(x)\n  def vauleOf(x: Any): String = java.lang.String.valueOf(x)\n  def vauleOf(x: Array[Char], a: Int, b: Int): String = java.lang.String.valueOf(x, a, b)\n  def vauleOf(x: Char): String = java.lang.String.valueOf(x)\n  def vauleOf(x: Float): String = java.lang.String.valueOf(x)\n  def vauleOf(x: Long): String = java.lang.String.valueOf(x)\n\n  val CASE_INSENSITIVE_ORDER = java.lang.String.CASE_INSENSITIVE_ORDER\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/threads.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nimport java.lang.{ClassLoader => JClassLoader, Thread => JThread}\n\nobject ClasspathUrlItem {\n  implicit def toClasspathUrlItem[T: ClasspathUrlable](t: T): ClasspathUrlItem =\n    ?[ClasspathUrlable[T]].toClasspathUrlItem(t)\n}\n\ncase class ClasspathUrlItem(javaUrl: List[java.net.URL])\n\nobject ClasspathUrlable {\n  implicit def seqUrlable[T](implicit urlable: ClasspathUrlable[T]): ClasspathUrlable[List[T]] =\n    new ClasspathUrlable[List[T]] {\n      def toClasspathUrlItem(xs: List[T]): ClasspathUrlItem =\n        ClasspathUrlItem(xs.flatMap(urlable.toClasspathUrlItem(_).javaUrl))\n    }\n}\ntrait ClasspathUrlable[T] { def toClasspathUrlItem(t: T): ClasspathUrlItem }\n\nobject ClassLoader {\n  implicit def defaultClassLoader: ClassLoader =\n    new ClassLoader(JThread.currentThread.getContextClassLoader)\n\n  def apply(urls: ClasspathUrlItem*): ClassLoader =\n    new ClassLoader(new java.net.URLClassLoader(urls.flatMap(_.javaUrl).to[Array]))\n}\n\nclass ClassLoader(val javaClassLoader: JClassLoader) {\n  def applyTo[T](blk: => T): T = {\n    val cur = java.lang.Thread.currentThread().getContextClassLoader\n    java.lang.Thread.currentThread().setContextClassLoader(javaClassLoader)\n    val result = blk\n    java.lang.Thread.currentThread().setContextClassLoader(cur)\n    result\n  }\n}\n\nobject Thread {\n  def fork(threadName: String, daemon: Boolean = false)(blk: => Unit)(implicit cl: ClassLoader): Thread =\n    ThreadSpec(threadName, daemon)(blk).spawn()\n\n  def sleep[D: TimeSystem.ByDuration](duration: D) =\n    JThread.sleep(?[TimeSystem.ByDuration[D]].fromDuration(duration))\n\n}\n\ncase class ThreadSpec(name: String, daemon: Boolean = false)(blk: => Unit)(implicit cl: ClassLoader) {\n\n  def spawn(): Thread = {\n    val parentThread = JThread.currentThread\n    val javaThread = new JThread(name) {\n      override def run() = {\n        blk\n        parentThread.join()\n      }\n    }\n    javaThread.setDaemon(daemon)\n    javaThread.setContextClassLoader(cl.javaClassLoader)\n    javaThread.start()\n\n    new Thread(this, javaThread) {\n      def parentAlive = javaThread.isAlive\n    }\n  }\n}\n\nabstract class Thread(spec: ThreadSpec, javaThread: JThread) {\n  def daemon: Boolean = spec.daemon\n  def name: String = spec.name\n\n  def alive: Boolean = javaThread.isAlive\n  def interrupt(): Unit = javaThread.interrupt()\n  def join(): Unit = javaThread.join()\n\n  def priority = javaThread.getPriority\n  def priority_=(p: Int) = javaThread.setPriority(p)\n\n  override def toString = s\"[$name]\"\n}\n"
  },
  {
    "path": "core/shared/src/main/scala/rapture/core/time.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core\n\nobject TimeSystem {\n  type ByInstant[T] = TimeSystem[T, _]\n  type ByDuration[T] = TimeSystem[_, T]\n}\n\n@implicitNotFound(\n    \"an implicit TimeSystem is required; please import timeSystems.numeric._ or \" +\n      \"timeSystems.javaUtil._\")\ntrait TimeSystem[Instant, Duration] {\n  def instant(millis: Long): Instant\n  def duration(from: Long, to: Long): Duration\n  def fromInstant(inst: Instant): Long\n  def fromDuration(dur: Duration): Long\n}\n\npackage timeSystems {\n  object numeric {\n    def apply(): TimeSystem[Long, Long] = timeSystemImplicit\n    implicit val timeSystemImplicit: TimeSystem[Long, Long] = new TimeSystem[Long, Long] {\n      def instant(millis: Long): Long = millis\n      def duration(from: Long, to: Long): Long = to - from\n      def fromInstant(inst: Long): Long = inst\n      def fromDuration(dur: Long): Long = dur\n    }\n  }\n\n  object javaUtil {\n    def apply(): TimeSystem[java.util.Date, Long] = timeSystemImplicit\n    implicit val timeSystemImplicit = new TimeSystem[java.util.Date, Long] {\n      import java.util.Date\n      def instant(millis: Long) = new Date(millis)\n      def duration(from: Long, to: Long): Long = to - from\n      def fromInstant(inst: Date): Long = inst.getTime\n      def fromDuration(dur: Long): Long = dur\n    }\n  }\n}\n"
  },
  {
    "path": "core-scalaz/shared/src/main/scala/rapture/core-scalaz/modes.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core.scalazInterop\n\nimport rapture.core._\n\nimport java.util.concurrent.ExecutorService\n\nimport scalaz._\nimport scalaz.concurrent._\n\nclass ReturnTasks[+Group <: MethodConstraint](implicit pool: ExecutorService) extends Mode[Group] {\n  type Wrap[+T, E <: Exception] = Task[T]\n  def wrap[T, E <: Exception](t: => T): Task[T] = Task.delay(t)\n  def unwrap[T](t: => Wrap[T, _ <: Exception]): T = t.unsafePerformSyncAttempt.valueOr { throw _ }\n}\n\nclass ReturnValidation[+Group <: MethodConstraint] extends Mode[Group] {\n  type Wrap[+T, E <: Exception] = Validation[E, T]\n  def wrap[T, E <: Exception](t: => T): Validation[E, T] =\n    try Success(t)\n    catch { case e: Exception => Failure(e.asInstanceOf[E]) }\n  def unwrap[T](t: => Validation[_ <: Exception, T]): T = t.valueOr { throw _ }\n}\n\nclass ReturnDisjunction[+Group <: MethodConstraint] extends Mode[Group] {\n  type Wrap[+T, E <: Exception] = \\/[E, T]\n  def wrap[T, E <: Exception](t: => T): \\/[E, T] =\n    try \\/-(t)\n    catch { case e: Exception => -\\/(e.asInstanceOf[E]) }\n  def unwrap[T](t: => \\/[_ <: Exception, T]): T = t.valueOr { throw _ }\n}\n\nclass ScalazExplicits[+T, E <: Exception](explicit: modes.Explicitly[T, E]) {\n  def task(implicit pool: ExecutorService): Task[T] = returnTasks.wrap(explicit.get)\n  def validation: Validation[E, T] = returnValidations.wrap(explicit.get)\n}\n\nobject `package` {\n\n  implicit def scalazExplicits[T, E <: Exception](explicit: modes.Explicitly[T, E]): ScalazExplicits[T, E] =\n    new ScalazExplicits[T, E](explicit)\n\n  implicit def returnTasks[Group <: MethodConstraint](implicit pool: ExecutorService) = new ReturnTasks[Group]\n  // FIXME: This should be modified to collect multiple failures\n  implicit def returnValidations[Group <: MethodConstraint] = new ReturnValidation[Group]\n\n  implicit def returnDisjunction[Group <: MethodConstraint] = new ReturnDisjunction[Group]\n\n}\n"
  },
  {
    "path": "core-scalaz/shared/src/main/scala/rapture/core-scalaz/transformers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core.scalazInterop\n\nimport rapture.core.{Errata, NotMatchingFilter, Result}\n\nimport scala.reflect.ClassTag\nimport scalaz.{Functor, _}\n\nimport language.higherKinds\n\n/**\n  * ResultT monad transformer\n  *\n  * Represents a computation of type `Result[A,B]`.\n  *\n  * Example:\n  * {{{\n  * val x: Option[Result[String, E]] = Some(Answer(1))\n  * ResultT(x).map(1+).run // Some(Answer(2))\n  * }}}\n  **/\nsealed trait ResultT[F[_], T, E <: Exception] {\n\n  val run: F[Result[T, E]]\n\n  /** Map on the answer of this result. */\n  def map[C](f: T => C)(implicit functor: Functor[F], cte: ClassTag[E]): ResultT[F, C, E] =\n    ResultT(functor.map(run)(_.map(f)))\n\n  /** Bind through the answer of this result accumulating errors in the contents and type signature. */\n  def flatMap[C, E2 <: Exception](f: T => ResultT[F, C, E2])(implicit monad: Monad[F],\n                                                             cte: ClassTag[E2]): ResultT[F, C, E with E2] = {\n    ResultT(monad.bind[Result[T, E], Result[C, E with E2]](run) { result =>\n      result.fold[F[Result[C, E with E2]]]({ a =>\n        monad.map(f(a).run)(r2 => Result[C, E with E2](r2.get, r2.errors ++ result.errors))\n      }, { e =>\n        monad.point(Errata[C, E with E2](e))\n      })\n    })\n  }\n\n  /** Filter on the answer of this result. */\n  def filter(p: T => Boolean)(implicit functor: Functor[F],\n                              cte: ClassTag[E]): ResultT[F, T, E with NotMatchingFilter] =\n    ResultT(functor.map(run)(_.filter(p)))\n\n  /** Alias for `filter` */\n  def withFilter(p: T => Boolean)(implicit functor: Functor[F],\n                                  cte: ClassTag[E]): ResultT[F, T, E with NotMatchingFilter] =\n    filter(p)\n\n}\n\nobject ResultT extends ResultTFunctions {\n\n  /** Construct a result value. */\n  def apply[F[_], T, E <: Exception: ClassTag](a: F[Result[T, E]]): ResultT[F, T, E] =\n    resultT[F, T, E](a)\n\n  /** Construct an answer value. */\n  def answer[F[_], T, E <: Exception: ClassTag](a: F[T])(implicit functor: Functor[F]): ResultT[F, T, E] =\n    apply[F, T, E](functor.map(a)(Result.answer[T, E]))\n\n  /** Construct an errata value. */\n  def errata[F[_], T, E <: Exception: ClassTag](a: F[E])(implicit functor: Functor[F]): ResultT[F, T, E] =\n    apply[F, T, E](functor.map(a)(Result.errata[T, E]))\n\n}\n\nprivate[scalazInterop] trait ResultTFunctions {\n  def resultT[F[_], T, E <: Exception](a: F[Result[T, E]]): ResultT[F, T, E] = new ResultT[F, T, E] {\n    val run = a\n  }\n}\n"
  },
  {
    "path": "core-test/shared/src/test/scala/rapture/core/tests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.core.test\n\nimport rapture.core._\nimport rapture.core.scalazInterop.ResultT\nimport rapture.test._\n\nimport scalaz.Scalaz._\n\nclass TestRun extends Programme {\n  include(CoreTests)\n}\n\nobject CoreTests extends TestSuite {\n\n  case class AlphaException() extends Exception\n  case class BetaException() extends Exception\n  case class MiscException() extends Exception\n\n  def alpha(x: Int)(implicit mode: Mode[_]): mode.Wrap[Int, AlphaException] = mode.wrap {\n    if(x == 0) mode.exception(AlphaException())\n    else if(x == 1) throw MiscException()\n    else 0\n  }\n\n  def beta(x: Int)(implicit mode: Mode[_]): mode.Wrap[Int, BetaException] = mode.wrap {\n    if(x == 0) mode.exception(BetaException())\n    else if(x == 1) throw MiscException()\n    else 0\n  }\n\n  val `Successful Result` = test {\n    import modes.returnResult._\n    alpha(2)\n  } returns Answer(0)\n\n  val `Unforeseen Result` = test {\n    import modes.returnResult._\n    alpha(1)\n  } returns Unforeseen(MiscException())\n\n  val `Expected error Result` = test {\n    import modes.returnResult._\n    alpha(0)\n  } satisfies { case Errata(_) => true case _ => false }\n\n  val `FlatMapped Successful Result` = test {\n    import modes.returnResult._\n    for {\n      a <- alpha(2)\n      b <- beta(2)\n    } yield a + b\n  } returns Answer(0)\n\n  val `FlatMapped first fails` = test {\n    import modes.returnResult._\n    for {\n      a <- alpha(0)\n      b <- beta(2)\n    } yield a + b\n  } satisfies (_.exceptions == Vector(AlphaException()))\n\n  val `FlatMapped second fails` = test {\n    import modes.returnResult._\n    for {\n      a <- alpha(2)\n      b <- beta(0)\n    } yield a + b\n  } satisfies (_.exceptions == Vector(BetaException()))\n\n  val `Resolving errata 1` = test {\n    import modes.returnResult._\n    val result = for(a <- alpha(2); b <- beta(0)) yield a + b\n    result.resolve(\n      each[AlphaException] { e => 10 },\n      each[BetaException] { e => 20 }\n    )\n  } returns Answer(20)\n\n  val `Resolving errata 2` = test {\n    import modes.returnResult._\n    val result = for(a <- alpha(0); b <- beta(2)) yield a + b\n    result.resolve(\n      each[AlphaException] { e => 10 },\n      each[BetaException] { e => 20 }\n    )\n  } returns Answer(10)\n\n  val `Catching success` = test {\n    Result.catching[AlphaException] {\n      \"success\"\n    }\n  } returns Answer(\"success\")\n\n  val `Catching failure` = test {\n    Result.catching[AlphaException] {\n      throw AlphaException()\n    }\n  } satisfies (_.exceptions == Vector(AlphaException()))\n\n  val `Catching unforeseen` = test {\n    Result.catching[AlphaException] {\n      throw BetaException()\n    }\n  } returns Unforeseen(BetaException())\n\n  val `Checking isErrata with errata` = test {\n    Result.errata(AlphaException()).isErrata\n  } returns true\n\n  val `Checking isErrata with answer` = test {\n    Result.answer(1).isErrata\n  } returns false\n\n  val `Checking isAnswer with errata` = test {\n    Result.errata(AlphaException()).isAnswer\n  } returns false\n\n  val `Checking isAnswer with answer` = test {\n    Result.answer(1).isAnswer\n  } returns true\n\n  val `Checking isUnforeseen with answer` = test {\n    Result.answer(1).isUnforeseen\n  } returns false\n\n  val `Checking isUnforeseen with errata` = test {\n    Result.errata(AlphaException()).isUnforeseen\n  } returns false\n\n  val `Checking isUnforeseen with unforeseen` = test {\n    Result.catching[AlphaException] {\n      throw BetaException()\n    }.isUnforeseen\n  } returns true\n\n  val `Fold answer` = test {\n    Result.answer(1).fold(\n      a => a + 1,\n      e => 0\n    )\n  } returns 2\n\n  val `Fold errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).fold(\n      a => a + 1,\n      e => 0\n    )\n  } returns 0\n\n  val `Exists answer` = test {\n    Result.answer(1).exists(_ == 1)\n  } returns true\n\n  val `Exists answer none found` = test {\n    Result.answer(1).exists(_ == 0)\n  } returns false\n\n  val `Exists errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).exists(_ == 1)\n  } returns false\n\n  val `Forall answer` = test {\n    Result.answer(1).forall(_ == 1)\n  } returns true\n\n  val `Forall answer none found` = test {\n    Result.answer(1).forall(_ == 0)\n  } returns false\n\n  val `Forall errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).forall(_ == 1)\n  } returns true\n\n  val `toList answer` = test {\n    Result.answer(1).to[List]\n  } returns List(1)\n\n  val `toList errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).to[List]\n  } returns Nil\n\n  val `toStream answer` = test {\n    Result.answer(1).to[Stream]\n  } returns Stream(1)\n\n  val `toStream errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).to[Stream]\n  } returns Stream.empty[Int]\n\n  val `toOption answer` = test {\n    Result.answer(1).toOption\n  } returns Some(1)\n\n  val `toOption errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).toOption\n  } returns None\n\n  val `toEither answer` = test {\n    Result.answer(1).toEither\n  } returns Right(1)\n\n  val `toEither errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).toEither\n  } satisfies (v => v.isLeft)\n\n  val `getOrElse answer` = test {\n    Result.answer(1).getOrElse(0)\n  } returns 1\n\n  val `getOrElse errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).getOrElse(0)\n  } returns 0\n\n  val `| answer` = test {\n    Result.answer(1) | 0\n  } returns 1\n\n  val `| errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()) | 0\n  } returns 0\n\n  val `valueOr answer` = test {\n    Result.answer(1).valueOr(_ => 0)\n  } returns 1\n\n  val `valueOr errata` = test {\n    Result.errata[Int, AlphaException](AlphaException()).valueOr(_ => 0)\n  } returns 0\n\n  val `filter answer` = test {\n    Result.answer(1) filter (_ == 1)\n  } returns Answer(1)\n\n  /*val `filter answer 2` = test {\n    Result.answer(1) filter (_ == 0)\n  } returns Errata(Nil)*/\n\n  val `filter errata` = test {\n    Errata[String, Nothing](Nil) filter (_.isEmpty)\n  } returns Errata(Nil)\n\n  /*val `withFilter errata monadic` = test {\n    for {\n      x <- Answer(1)\n      if x == 0\n      y = x + 1\n    } yield y\n  } returns Errata(Nil)*/\n\n  val `withFilter answer monadic` = test {\n    for {\n      x <- Answer(1)\n      if x == 1\n      y = x + 1\n    } yield y\n  } returns Answer(2)\n\n  val `ResultT Checking isErrata with errata` = test {\n    ResultT.errata(Option(AlphaException())).run.get.isErrata\n  } returns true\n\n  val `ResultT Checking isErrata with answer` = test {\n    ResultT.answer(Option(1)).run.get.isErrata\n  } returns false\n\n  val `ResultT Checking isAnswer with errata` = test {\n    ResultT.errata(Option(AlphaException())).run.get.isAnswer\n  } returns false\n\n  val `ResultT Checking isAnswer with answer` = test {\n    ResultT.answer(Option(1)).run.get.isAnswer\n  } returns true\n\n  val `ResultT Checking isUnforeseen with answer` = test {\n    ResultT.answer(Option(1)).run.get.isUnforeseen\n  } returns false\n\n  val `ResultT Checking isUnforeseen with errata` = test {\n    ResultT.errata(Option(AlphaException())).run.get.isUnforeseen\n  } returns false\n\n  val `ResultT withFilter accumulating exceptions` = test {\n    val z: ResultT[Option, Int, NumberFormatException with IllegalArgumentException] = for {\n      x <- ResultT(Option(Result.catching[NumberFormatException](\"1\".toInt)))\n      y <- ResultT(Option(Result.catching[IllegalArgumentException](\"1\".toInt)))\n    } yield x + y\n    z.run.get.get\n  } returns 2\n\n\n\n}\n\n"
  },
  {
    "path": "crypto/shared/src/main/scala/rapture/crypto/aes.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.crypto\n\nimport rapture.core._\n\nimport javax.crypto.spec._\nimport java.util._\n\nimport digests._\n\ntrait `AesEncryption#decrypt` extends MethodConstraint\ntrait `Key#decrypt` extends MethodConstraint\n\n/** Provides a simple interface for AES encryption with SHA-256 digest\n  * verification. This class is stateless. */\nabstract class AesEncryption {\n\n  /** Must be 16, 24 or 32 bytes long. */\n  protected def secretKey: Array[Byte]\n\n  private val keySpec = new SecretKeySpec(secretKey, \"AES\")\n\n  def encrypt(clearText: Array[Byte], iv: Array[Byte] = null): Array[Byte] = {\n\n    val cipher = javax.crypto.Cipher.getInstance(\"AES/CBC/PKCS5Padding\")\n\n    if (iv == null) cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, keySpec)\n    else cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, keySpec, new IvParameterSpec(iv))\n\n    val digest = Hash.digest[Sha256](clearText).bytes\n    val paddedLength = (clearText.length >> 4) + 1 << 4\n    val cipherText = new Array[Byte](paddedLength + (if (iv == null) 48 else 0))\n\n    if (iv == null) {\n      Array.copy(cipher.getIV, 0, cipherText, 0, 16)\n      cipher.update(digest, 0, 32, cipherText, 16)\n    }\n    cipher.doFinal(clearText, 0, clearText.length, cipherText, if (iv == null) 48 else 0)\n\n    cipherText\n  }\n\n  def decrypt(cipherText: Array[Byte], iv: Array[Byte] = null)(\n      implicit mode: Mode[`AesEncryption#decrypt`]): mode.Wrap[Array[Byte], DecryptionException] = mode.wrap {\n    if (iv == null && cipherText.length < 48) mode.exception(DecryptionException())\n\n    val cipher = javax.crypto.Cipher.getInstance(\"AES/CBC/PKCS5Padding\")\n    val ips = if (iv == null) new IvParameterSpec(cipherText, 0, 16) else new IvParameterSpec(iv)\n\n    cipher.init(javax.crypto.Cipher.DECRYPT_MODE, keySpec, ips)\n\n    val n = if (iv == null) 64 else 0\n\n    val digest1 = if (iv == null) cipher.update(cipherText, 16, 48) else Array[Byte]()\n    val clearText = cipher.doFinal(cipherText, n, cipherText.length - n)\n\n    if (iv == null) {\n      val digest2 = Hash.digest[Sha256](clearText).bytes\n      var i = 0\n      var r = true\n\n      while (i < 32) {\n        if (digest1(i) != digest2(i)) r = false\n        i += 1\n      }\n\n      if (!r) {\n        Arrays.fill(digest1, 0.toByte)\n        Arrays.fill(digest2, 0.toByte)\n        Arrays.fill(clearText, 0.toByte)\n        mode.exception(DecryptionException())\n      }\n    }\n\n    clearText\n  }\n\n  def apply(clearText: Array[Byte]): Array[Byte] = encrypt(clearText)\n\n  def unapply(cipherText: Array[Byte]): Option[Array[Byte]] =\n    try Some(decrypt(cipherText))\n    catch { case DecryptionException() => None }\n}\n"
  },
  {
    "path": "crypto/shared/src/main/scala/rapture/crypto/digest.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.crypto\nimport rapture.core._\nimport rapture.codec._\n\nimport java.security._\nimport javax.crypto.Mac\n\ntrait DigestType\ntrait Sha1 extends DigestType\ntrait Sha256 extends DigestType\ntrait Sha384 extends DigestType\ntrait Sha512 extends DigestType\ntrait Md2 extends DigestType\ntrait Md5 extends DigestType\n\nclass Digest[T <: DigestType](bytes: Array[Byte]) extends Bytes(bytes)\n\npackage ciphers {\n  object des {\n    implicit def desGenerator: KeyGenerator[Des] = Des.keyGenerator\n    implicit def desDecryption = Des.decryption\n    implicit def desEncryption = Des.encryption\n  }\n\n  object blowfish {\n    implicit def blowfishGenerator: KeyGenerator[Blowfish] = Blowfish.keyGenerator\n    implicit def blowfishDecryption = Blowfish.decryption\n    implicit def blowfishEncryption = Blowfish.encryption\n  }\n\n  object aes {\n    implicit def aesGenerator: KeyGenerator[Aes] = Aes.keyGenerator\n    implicit def aesDecryption = Aes.decryption\n    implicit def aesEncryption = Aes.encryption\n  }\n\n}\n\nclass EncryptedData[C <: CipherType](bytes: Array[Byte]) extends Bytes(bytes)\n\nobject Hash {\n  def digest[D <: DigestType: Digester](msg: Bytes): Digest[D] =\n    new Digest[D](?[Digester[D]].digest(msg.bytes))\n}\n\nobject Digester {\n  implicit val sha1: Digester[Sha1] = digests.sha1\n  implicit val sha256: Digester[Sha256] = digests.sha256\n  implicit val sha512: Digester[Sha512] = digests.sha512\n  implicit val sha384: Digester[Sha384] = digests.sha384\n  implicit val md5: Digester[Md5] = digests.md5\n  implicit val md2: Digester[Md2] = digests.md2\n}\nabstract class Digester[D <: DigestType] {\n\n  /** Digests the array of bytes. */\n  def digest(msg: Array[Byte]): Array[Byte]\n}\n\ncase class Salt(value: String)\n\nobject Password {\n  def apply(value: String)(implicit salt: Salt) = new HashedPassword(value)(salt)\n}\n\nclass Password(private val value: String)(implicit salt: Salt) {\n  def digest: String = Bytes(Digester.sha256.digest((value + salt).getBytes(\"UTF-8\"))).encode[Hex]\n  override def toString = s\"password:$digest\"\n  def check(password: String) = new Password(password).digest == digest\n}\n\nclass HashedPassword(hash: String)(implicit salt: Salt) extends Password(null)(salt) {\n  override def digest: String = hash\n}\n\nobject digests {\n\n  implicit val sha1: Digester[Sha1] = new Digester[Sha1] {\n    def digest(msg: Array[Byte]): Array[Byte] =\n      MessageDigest.getInstance(\"SHA-1\").digest(msg)\n  }\n\n  /** SHA-256 digester, with additional methods for secure password encoding. */\n  implicit val sha256: Digester[Sha256] = new Digester[Sha256] {\n\n    /** Digests the given bytes. */\n    def digest(msg: Array[Byte]): Array[Byte] =\n      MessageDigest.getInstance(\"SHA-256\").digest(msg)\n  }\n\n  /** SHA-512 digester, with additional methods for secure password encoding. */\n  implicit val sha512: Digester[Sha512] = new Digester[Sha512] {\n    def digest(msg: Array[Byte]): Array[Byte] =\n      MessageDigest.getInstance(\"SHA-512\").digest(msg)\n  }\n\n  /** SHA-384 digester, with additional methods for secure password encoding. */\n  implicit val sha384: Digester[Sha384] = new Digester[Sha384] {\n    def digest(msg: Array[Byte]): Array[Byte] =\n      MessageDigest.getInstance(\"SHA-384\").digest(msg)\n  }\n\n  /** MD5 Digester. This is included for backwards compatibility. MD5 is no\n    * longer considered future-proof and new designs should prefer SHA-256. */\n  implicit val md5: Digester[Md5] = new Digester[Md5] {\n    def digest(msg: Array[Byte]): Array[Byte] =\n      MessageDigest.getInstance(\"MD5\").digest(msg)\n  }\n\n  implicit val md2: Digester[Md2] = new Digester[Md2] {\n    def digest(msg: Array[Byte]): Array[Byte] =\n      MessageDigest.getInstance(\"MD2\").digest(msg)\n  }\n}\n\ntrait CipherType\ntrait Blowfish extends CipherType\n\nclass JavaxCryptoImplementations[Codec <: CipherType](codec: String) {\n  implicit def encryption: Encryption[Codec, Bytes] = new Encryption[Codec, Bytes] {\n    def encrypt(key: Array[Byte], message: Bytes) = {\n      val cipher = javax.crypto.Cipher.getInstance(codec)\n      cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, new javax.crypto.spec.SecretKeySpec(key, codec))\n      cipher.doFinal(message.bytes)\n    }\n  }\n\n  implicit def decryption = new Decryption[Codec] {\n    def decrypt(key: Array[Byte], message: Array[Byte]) = {\n      val cipher = javax.crypto.Cipher.getInstance(codec)\n      cipher.init(javax.crypto.Cipher.DECRYPT_MODE, new javax.crypto.spec.SecretKeySpec(key, codec))\n      cipher.doFinal(message)\n    }\n  }\n\n  implicit def keyGenerator: KeyGenerator[Codec] = new KeyGenerator[Codec] {\n    def generate(): Array[Byte] = {\n      val keyGen = javax.crypto.KeyGenerator.getInstance(codec)\n      keyGen.generateKey().getEncoded\n    }\n  }\n}\n\ntrait Aes extends CipherType\nobject Aes extends JavaxCryptoImplementations[Aes](\"AES\")\nobject Des extends JavaxCryptoImplementations[Des](\"DES\")\nobject Blowfish extends JavaxCryptoImplementations[Blowfish](\"Blowfish\")\n\ntrait TripleDes extends CipherType\ntrait Des extends CipherType\n\ntrait KeyGenerator[K <: CipherType] {\n  type KeyType = K\n  def generate(): Array[Byte]\n}\n\ntrait Encryption[-C <: CipherType, Msg] {\n  def encrypt(key: Array[Byte], message: Msg): Array[Byte]\n}\n\ncase class DecryptionException() extends Exception\n\ntrait Decryption[C <: CipherType] {\n  def decrypt(key: Array[Byte], message: Array[Byte]): Array[Byte]\n}\n\nobject Key {\n  def generate[K <: CipherType]()(implicit gen: KeyGenerator[K]): Key[gen.KeyType] =\n    new Key[gen.KeyType](?[KeyGenerator[K]].generate())\n\n  def read[K <: CipherType](key: Bytes): Key[K] =\n    new Key[K](key.bytes)\n}\n\nclass Key[C <: CipherType](bytes: Array[Byte]) extends Bytes(bytes) {\n  def encrypt[Msg](message: Msg)(implicit encryption: Encryption[C, Msg]): EncryptedData[C] =\n    new EncryptedData[C](encryption.encrypt(bytes, message))\n\n  def decrypt(message: EncryptedData[C])(implicit mode: Mode[`Key#decrypt`],\n                                         decryption: Decryption[C]): mode.Wrap[Bytes, DecryptionException] =\n    mode wrap {\n      try Bytes(decryption.decrypt(bytes, message.bytes))\n      catch {\n        case e: Exception => mode.exception(DecryptionException())\n      }\n    }\n}\n\ncase class HmacSigner(key: Bytes) {\n  type Sha256Hmac <: DigestType\n  implicit val hmac: Digester[Sha256Hmac] = new Digester[Sha256Hmac] {\n    def digest(msg: Array[Byte]): Array[Byte] = {\n      val mac = Mac.getInstance(\"HmacSHA256\")\n      val secretKey = new javax.crypto.spec.SecretKeySpec(key.bytes, \"HmacSHA256\")\n      mac.init(secretKey)\n      mac.doFinal(msg)\n    }\n  }\n\n}\n"
  },
  {
    "path": "css/shared/src/main/scala/rapture/css/context.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.css\n\nimport rapture.base._\nimport rapture.core._\nimport rapture.data._\n\nimport language.experimental.macros\n\nprivate[css] object CssMacros {\n\n  def parseSource(s: List[String], substitutions: List[String], stylesheet: Boolean): Option[(Int, Int, String)] =\n    try {\n      if(stylesheet) CssParser.parseStylesheet(s, substitutions)\n      else CssParser.parse(s, substitutions)\n      None\n    } catch {\n      case CssParser.ValidationException(strNo, pos, msg) =>\n        Some((strNo, pos, s\"failed to parse Css literal: $msg\"))\n    }\n\n  // FIXME: Unify these three implementations, and use quasiquotes\n  def cssClassContextMacro(c: BlackboxContext)(\n      exprs: c.Expr[ForcedConversion[CssClass]]*): c.Expr[CssClass] = {\n    import c.universe._\n\n    c.prefix.tree match {\n      case Select(Apply(_, List(Apply(_, rawPart :: Nil))), _) =>\n        val Literal(Constant(className: String)) = rawPart\n        if(!className.matches(\"-?[_a-zA-Z]+[_a-zA-Z0-9-]*\"))\n          c.abort(c.enclosingPosition, \"this is not a valid CSS class identifier\")\n\n        c.Expr(q\"_root_.rapture.css.CssClass(_root_.scala.collection.immutable.Set($rawPart))\")\n    }\n  }\n\n  def stylesheetContextMacro(c: BlackboxContext)(\n      exprs: c.Expr[Embed[CssStylesheet]]*): c.Expr[CssStylesheet] = {\n    import c.universe._\n\n    c.prefix.tree match {\n      case Select(Apply(_, List(Apply(_, rawParts))), _) =>\n        val text = rawParts.map { case Literal(Constant(part: String)) => part }\n\n        val listExprs = c.Expr[List[Embed[CssStylesheet]]](q\"_root_.scala.List(..${exprs.map(_.tree).to[List]})\")\n\n        def resolveEmbeddableName(name: String) = name match {\n          case \"domId\" => \"#foo\"\n          case \"css\" => \"color: red;\"\n          case \"cssClass\" => \".foo\"\n          case \"int\" => \"1\"\n          case \"double\" => \"1.0\"\n          case _ => \"null\"\n        }\n\n        val substitutions: List[String] = listExprs.tree match {\n          case Apply(_, applications) =>\n            applications.map {\n              case Apply(Apply(TypeApply(Select(_, _), _), _), List(Select(_, name))) => resolveEmbeddableName(name.toString)\n            }\n        }\n\n        parseSource(text, substitutions, true).foreach {\n          case (n, offset, msg) =>\n            val oldPos = rawParts(n).asInstanceOf[Literal].pos\n            val newPos = oldPos.withPoint(oldPos.start + offset)\n            c.error(newPos, msg)\n        }\n\n        val listParts = c.Expr[List[String]](q\"_root_.scala.List(..$rawParts)\")\n\n        reify {\n          val sb = new StringBuilder\n          val textParts = listParts.splice.iterator\n          val expressions: Iterator[Embed[CssStylesheet]] = listExprs.splice.iterator\n\n          sb.append(textParts.next())\n\n          while (textParts.hasNext) {\n            sb.append(expressions.next.content)\n            sb.append(textParts.next)\n          }\n          CssParser.parseStylesheet(List(sb.toString), Nil)\n        }\n    }\n  }\n\n  def cssContextMacro(c: BlackboxContext)(\n      exprs: c.Expr[Embed[Css]]*): c.Expr[Css] = {\n    import c.universe._\n    import compatibility._\n\n    c.prefix.tree match {\n      case Select(Apply(_, List(Apply(_, rawParts))), _) =>\n        val text = rawParts.map { case Literal(Constant(part: String)) => part }\n\n        val listExprs = c.Expr[List[Embed[Css]]](\n            Apply(\n                Select(reify(List).tree, termName(c, \"apply\")),\n                exprs.map(_.tree).to[List]\n            ))\n\n        def resolveEmbeddableName(name: String) = name match {\n          case \"cssCss\" => \"color: red;\"\n          case \"cssInt\" => \"1\"\n          case \"cssDouble\" => \"1.0\"\n          case _ => \"null\"\n        }\n\n        val substitutions: List[String] = listExprs.tree match {\n          case Apply(_, applications) =>\n            applications.map {\n              case Apply(Apply(TypeApply(Select(_, _), _), _), List(Select(_, name))) => resolveEmbeddableName(name.toString)\n            }\n        }\n\n        parseSource(text, substitutions, false).foreach {\n          case (n, offset, msg) =>\n            val oldPos = rawParts(n).asInstanceOf[Literal].pos\n            val newPos = oldPos.withPoint(oldPos.start + offset)\n            c.error(newPos, msg)\n        }\n\n        val listParts = c.Expr[List[String]](q\"_root_.scala.List(..$rawParts)\")\n\n        reify {\n          val sb = new StringBuilder\n          val textParts = listParts.splice.iterator\n          val expressions: Iterator[Embed[Css]] = listExprs.splice.iterator\n\n          sb.append(textParts.next())\n\n          while (textParts.hasNext) {\n            sb.append(expressions.next.content)\n            sb.append(textParts.next)\n          }\n          CssParser.parse(List(sb.toString), Nil)\n        }\n    }\n  }\n}\n\nprivate[css] class CssStrings(sc: StringContext) {\n  class CssContext() {\n    def apply(exprs: Embed[Css]*): Css = macro CssMacros.cssContextMacro\n  }\n  \n  class CssClassContext() {\n    def apply(exprs: Nothing*): CssClass = macro CssMacros.cssClassContextMacro\n  }\n  \n  class StylesheetContext() {\n    def apply(exprs: Embed[CssStylesheet]*): CssStylesheet = macro CssMacros.stylesheetContextMacro\n  }\n  val css = new CssContext()\n  val cls = new CssClassContext()\n  val cssStylesheet = new StylesheetContext()\n}\n"
  },
  {
    "path": "css/shared/src/main/scala/rapture/css/css.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.css\n\nimport rapture.dom._\nimport rapture.core._\n\nimport scala.collection.immutable.ListMap\n\nobject Css {\n\n  implicit def stringSerializer: StringSerializer[Css] = new StringSerializer[Css] {\n    def serialize(css: Css): String = css.content\n  }\n}\n\ncase class Css(properties: ListMap[String, String]) {\n  def content = properties.map { case (k, v) => s\"$k: $v;\" }.mkString(\" \")\n  override def toString = s\"\"\"css${\"\\\"\" * 3}$content${\"\\\"\" * 3}\"\"\"\n  def +(css: Css) = Css(properties ++ css.properties)\n}\n\nobject CssStylesheet { \n  implicit def stringSerializer: StringSerializer[CssStylesheet] = new StringSerializer[CssStylesheet] {\n    def serialize(css: CssStylesheet): String = css.content\n  }\n}\ncase class CssStylesheet(rules: List[CssRule]) {\n  override def toString = s\"\"\"cssStylesheet${\"\\\"\" * 3}$content${\"\\\"\" * 3}\"\"\"\n  def content = rules.mkString(\"\\n\")\n}\n\nobject DomId {\n  def auto(implicit assignedName: AssignedName) = DomId(assignedName.name)\n}\ncase class DomId(id: String) {\n  override def toString = s\"#$id\"\n}\n\nobject CssClass {\n  def auto(implicit assignedName: AssignedName) = CssClass(Set(assignedName.name))\n  val empty = CssClass(Set())\n}\n\ncase class CssClass(classes: Set[String]) {\n  def +(cssClass: CssClass): CssClass = CssClass(classes ++ cssClass.classes)\n\n  def asString = classes.mkString(\" \")\n  \n  override def toString = classes.mkString(\".\", \".\", \"\")\n}\n\nobject CssEmbed {\n  implicit def embedCssClass(cssClass: CssClass): CssEmbed = CssEmbed(cssClass.classes.mkString(\".\", \".\", \"\"))\n  implicit def embedDomId(domId: DomId): CssEmbed = CssEmbed(s\"#${domId.id}\")\n}\ncase class CssEmbed(content: String)\n\n\nobject Embeddable {\n  implicit val domId: Embeddable[DomId, CssStylesheet] = new Embeddable[DomId, CssStylesheet] { def embed(value: DomId): String = s\"#${value.id}\" }\n  \n  implicit val cssClass: Embeddable[CssClass, CssStylesheet] = new Embeddable[CssClass, CssStylesheet] {\n    def embed(value: CssClass): String = value.classes.mkString(\".\", \".\", \"\")\n  }\n  \n  implicit val domTag: Embeddable[Tag[_, _, _], CssStylesheet] = new Embeddable[Tag[_, _, _], CssStylesheet] {\n    def embed(value: Tag[_, _, _]): String = value.tagName.toLowerCase\n  }\n  \n  implicit val css: Embeddable[Css, CssStylesheet] = new Embeddable[Css, CssStylesheet] {\n    def embed(value: Css): String = value.content\n  }\n  \n  implicit val string: Embeddable[String, CssStylesheet] = new Embeddable[String, CssStylesheet] {\n    def embed(value: String): String = value\n  }\n  \n  implicit val int: Embeddable[Int, CssStylesheet] = new Embeddable[Int, CssStylesheet] {\n    def embed(value: Int): String = value.toString\n  }\n  \n  implicit val double: Embeddable[Double, CssStylesheet] = new Embeddable[Double, CssStylesheet] {\n    def embed(value: Double): String = value.toString\n  }\n  \n  implicit val cssString: Embeddable[String, Css] = new Embeddable[String, Css] {\n    def embed(value: String): String = value\n  }\n  \n  implicit val cssInt: Embeddable[Int, Css] = new Embeddable[Int, Css] {\n    def embed(value: Int): String = value.toString\n  }\n  \n  implicit val cssDouble: Embeddable[Double, Css] = new Embeddable[Double, Css] {\n    def embed(value: Double): String = value.toString\n  }\n  \n  implicit val cssCss: Embeddable[Css, Css] = new Embeddable[Css, Css] {\n    def embed(value: Css): String = value.content\n  }\n}\n\ntrait Embeddable[-From, +To] { def embed(value: From): String }\n\nobject Embed {\n  implicit def embed[From, To](value: From)(implicit embeddable: Embeddable[From, To]): Embed[To] = Embed(embeddable.embed(value))\n}\n\ncase class Embed[To](content: String)\n"
  },
  {
    "path": "css/shared/src/main/scala/rapture/css/model.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.css\n\nimport rapture.core._\n\nsealed trait CssRule\ncase class CssCharset(encoding: String) extends CssRule {\n  override def toString = s\"@charset '$encoding';\"\n}\ncase class CssFontFace(properties: Css) extends CssRule {\n  override def toString = s\"@font-face { ${properties.content} }\"\n}\ncase class CssImport(href: String, media: String) extends CssRule {\n  override def toString = s\"@import url('$href') $media;\"\n}\ncase class CssMedia(cssRules: List[CssRule], media: String) extends CssRule {\n  override def toString = s\"@media $media { ${cssRules.mkString(\" \")} }\"\n}\ncase class CssPage(selectorText: String, properties: Css) extends CssRule {\n  override def toString = s\"@page $selectorText { ${properties.content} }\"\n}\ncase class CssStyle(selectorText: String, properties: Css) extends CssRule {\n  override def toString = s\"$selectorText { ${properties.content} }\"\n}\ncase class CssUnknown(text: String) extends CssRule {\n  override def toString = text\n}\n\n"
  },
  {
    "path": "css/shared/src/main/scala/rapture/css/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.css\n\nimport language.implicitConversions\n\nobject `package` {\n  implicit def cssStringContext(sc: StringContext): CssStrings = new CssStrings(sc)\n}\n"
  },
  {
    "path": "css/shared/src/main/scala/rapture/css/properties.scala",
    "content": "package rapture.css\n\nobject Properties {\n\n  // List of properties supported by Firefox\n  val all = Set(\n      \"align-content\",\n      \"align-items\",\n      \"align-self\",\n      \"alignment-adjust\",\n      \"alignment-baseline\",\n      \"anchor-point\",\n      \"animation\",\n      \"animation-delay\",\n      \"animation-direction\",\n      \"animation-duration\",\n      \"animation-fill-mode\",\n      \"animation-iteration-count\",\n      \"animation-name\",\n      \"animation-play-state\",\n      \"animation-timing-function\",\n      \"appearance\",\n      \"azimuth\",\n      \"backface-visibility\",\n      \"background\",\n      \"background-attachment\",\n      \"background-blend-mode\",\n      \"background-clip\",\n      \"background-color\",\n      \"background-image\",\n      \"background-origin\",\n      \"background-position\",\n      \"background-repeat\",\n      \"background-size\",\n      \"baseline-shift\",\n      \"binding\",\n      \"bleed\",\n      \"bookmark-label\",\n      \"bookmark-level\",\n      \"bookmark-state\",\n      \"bookmark-target\",\n      \"border\",\n      \"border-bottom\",\n      \"border-bottom-color\",\n      \"border-bottom-left-radius\",\n      \"border-bottom-right-radius\",\n      \"border-bottom-style\",\n      \"border-bottom-width\",\n      \"border-collapse\",\n      \"border-color\",\n      \"border-image\",\n      \"border-image-outset\",\n      \"border-image-repeat\",\n      \"border-image-slice\",\n      \"border-image-source\",\n      \"border-image-width\",\n      \"border-left\",\n      \"border-left-color\",\n      \"border-left-style\",\n      \"border-left-width\",\n      \"border-radius\",\n      \"border-right\",\n      \"border-right-color\",\n      \"border-right-style\",\n      \"border-right-width\",\n      \"border-spacing\",\n      \"border-style\",\n      \"border-top\",\n      \"border-top-color\",\n      \"border-top-left-radius\",\n      \"border-top-right-radius\",\n      \"border-top-style\",\n      \"border-top-width\",\n      \"border-width\",\n      \"bottom\",\n      \"box-decoration-break\",\n      \"box-shadow\",\n      \"box-sizing\",\n      \"break-after\",\n      \"break-before\",\n      \"break-inside\",\n      \"caption-side\",\n      \"clear\",\n      \"clip\",\n      \"color\",\n      \"color-profile\",\n      \"column-count\",\n      \"column-fill\",\n      \"column-gap\",\n      \"column-rule\",\n      \"column-rule-color\",\n      \"column-rule-style\",\n      \"column-rule-width\",\n      \"column-span\",\n      \"column-width\",\n      \"columns\",\n      \"content\",\n      \"counter-increment\",\n      \"counter-reset\",\n      \"crop\",\n      \"cue\",\n      \"cue-after\",\n      \"cue-before\",\n      \"cursor\",\n      \"direction\",\n      \"display\",\n      \"dominant-baseline\",\n      \"drop-initial-after-adjust\",\n      \"drop-initial-after-align\",\n      \"drop-initial-before-adjust\",\n      \"drop-initial-before-align\",\n      \"drop-initial-size\",\n      \"drop-initial-value\",\n      \"elevation\",\n      \"empty-cells\",\n      \"fit\",\n      \"fit-position\",\n      \"flex\",\n      \"flex-basis\",\n      \"flex-direction\",\n      \"flex-flow\",\n      \"flex-grow\",\n      \"flex-shrink\",\n      \"flex-wrap\",\n      \"float\",\n      \"float-offset\",\n      \"flow-from\",\n      \"flow-into\",\n      \"font\",\n      \"font-feature-settings\",\n      \"font-family\",\n      \"font-kerning\",\n      \"font-language-override\",\n      \"font-size\",\n      \"font-size-adjust\",\n      \"font-stretch\",\n      \"font-style\",\n      \"font-synthesis\",\n      \"font-variant\",\n      \"font-variant-alternates\",\n      \"font-variant-caps\",\n      \"font-variant-east-asian\",\n      \"font-variant-ligatures\",\n      \"font-variant-numeric\",\n      \"font-variant-position\",\n      \"font-weight\",\n      \"grid\",\n      \"grid-area\",\n      \"grid-auto-columns\",\n      \"grid-auto-flow\",\n      \"grid-auto-position\",\n      \"grid-auto-rows\",\n      \"grid-column\",\n      \"grid-column-end\",\n      \"grid-column-start\",\n      \"grid-row\",\n      \"grid-row-end\",\n      \"grid-row-start\",\n      \"grid-template\",\n      \"grid-template-areas\",\n      \"grid-template-columns\",\n      \"grid-template-rows\",\n      \"hanging-punctuation\",\n      \"height\",\n      \"hyphens\",\n      \"icon\",\n      \"image-orientation\",\n      \"image-rendering\",\n      \"image-resolution\",\n      \"inline-box-align\",\n      \"justify-content\",\n      \"left\",\n      \"letter-spacing\",\n      \"line-break\",\n      \"line-height\",\n      \"line-stacking\",\n      \"line-stacking-ruby\",\n      \"line-stacking-shift\",\n      \"line-stacking-strategy\",\n      \"list-style\",\n      \"list-style-image\",\n      \"list-style-position\",\n      \"list-style-type\",\n      \"margin\",\n      \"margin-bottom\",\n      \"margin-left\",\n      \"margin-right\",\n      \"margin-top\",\n      \"marker-offset\",\n      \"marks\",\n      \"marquee-direction\",\n      \"marquee-loop\",\n      \"marquee-play-count\",\n      \"marquee-speed\",\n      \"marquee-style\",\n      \"max-height\",\n      \"max-width\",\n      \"min-height\",\n      \"min-width\",\n      \"move-to\",\n      \"nav-down\",\n      \"nav-index\",\n      \"nav-left\",\n      \"nav-right\",\n      \"nav-up\",\n      \"object-fit\",\n      \"object-position\",\n      \"opacity\",\n      \"order\",\n      \"orphans\",\n      \"outline\",\n      \"outline-color\",\n      \"outline-offset\",\n      \"outline-style\",\n      \"outline-width\",\n      \"overflow\",\n      \"overflow-style\",\n      \"overflow-wrap\",\n      \"overflow-x\",\n      \"overflow-y\",\n      \"padding\",\n      \"padding-bottom\",\n      \"padding-left\",\n      \"padding-right\",\n      \"padding-top\",\n      \"page\",\n      \"page-break-after\",\n      \"page-break-before\",\n      \"page-break-inside\",\n      \"page-policy\",\n      \"pause\",\n      \"pause-after\",\n      \"pause-before\",\n      \"perspective\",\n      \"perspective-origin\",\n      \"pitch\",\n      \"pitch-range\",\n      \"play-during\",\n      \"position\",\n      \"presentation-level\",\n      \"punctuation-trim\",\n      \"quotes\",\n      \"region-break-after\",\n      \"region-break-before\",\n      \"region-break-inside\",\n      \"region-fragment\",\n      \"rendering-intent\",\n      \"resize\",\n      \"rest\",\n      \"rest-after\",\n      \"rest-before\",\n      \"richness\",\n      \"right\",\n      \"rotation\",\n      \"rotation-point\",\n      \"ruby-align\",\n      \"ruby-overhang\",\n      \"ruby-position\",\n      \"ruby-span\",\n      \"shape-image-threshold\",\n      \"shape-inside\",\n      \"shape-margin\",\n      \"shape-outside\",\n      \"size\",\n      \"speak\",\n      \"speak-as\",\n      \"speak-header\",\n      \"speak-numeral\",\n      \"speak-punctuation\",\n      \"speech-rate\",\n      \"stress\",\n      \"string-set\",\n      \"tab-size\",\n      \"table-layout\",\n      \"target\",\n      \"target-name\",\n      \"target-new\",\n      \"target-position\",\n      \"text-align\",\n      \"text-align-last\",\n      \"text-decoration\",\n      \"text-decoration-color\",\n      \"text-decoration-line\",\n      \"text-decoration-skip\",\n      \"text-decoration-style\",\n      \"text-emphasis\",\n      \"text-emphasis-color\",\n      \"text-emphasis-position\",\n      \"text-emphasis-style\",\n      \"text-height\",\n      \"text-indent\",\n      \"text-justify\",\n      \"text-outline\",\n      \"text-overflow\",\n      \"text-shadow\",\n      \"text-size-adjust\",\n      \"text-space-collapse\",\n      \"text-transform\",\n      \"text-underline-position\",\n      \"text-wrap\",\n      \"top\",\n      \"transform\",\n      \"transform-origin\",\n      \"transform-style\",\n      \"transition\",\n      \"transition-delay\",\n      \"transition-duration\",\n      \"transition-property\",\n      \"transition-timing-function\",\n      \"unicode-bidi\",\n      \"vertical-align\",\n      \"visibility\",\n      \"voice-balance\",\n      \"voice-duration\",\n      \"voice-family\",\n      \"voice-pitch\",\n      \"voice-range\",\n      \"voice-rate\",\n      \"voice-stress\",\n      \"voice-volume\",\n      \"volume\",\n      \"white-space\",\n      \"widows\",\n      \"width\",\n      \"word-break\",\n      \"word-spacing\",\n      \"word-wrap\",\n      \"z-index\"\n  )\n\n}\n"
  },
  {
    "path": "css/shared/src/main/scala/rapture/css/validator.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.css\n\nimport rapture.core._\n\nimport com.steadystate.css.parser._\nimport org.w3c.css.sac._\nimport org.w3c.dom.css._\nimport java.io._\n\nimport scala.collection.immutable.ListMap\n\nobject CssParser {\n\n  case class ValidationException(strNo: Int, pos: Int, msg: String) extends Exception\n\n  def parseStylesheet(parts: List[String], substitutions: List[String]): CssStylesheet = {\n    val errHandler = new ErrorHandler {\n      \n      def stringNo(c: Int): (Int, Int) =\n        parts.zip(substitutions).map { case (p, s) => p.length + s.length }.foldLeft(0 -> 0) { case ((sum, count), n) => if(sum > c) (sum, count) else (sum + n, count + 1) }\n      \n      def error(e: CSSParseException) = {\n        val c = e.getColumnNumber - 1\n        val (sum, cnt) = stringNo(c)\n        throw ValidationException(cnt, c - sum, e.getMessage)\n      }\n      \n      def fatalError(e: CSSParseException) = error(e)\n      def warning(e: CSSParseException) = error(e)\n    }\n    \n    val source = new InputSource(new StringReader(parts.zip(substitutions :+ \"\").map { case (k, v) => k+v }.mkString))\n    val parser = new CSSOMParser(new SACParserCSS3())\n    parser.setErrorHandler(errHandler)\n\n    val stylesheet = CssStylesheet(convertStylesheet(parser.parseStyleSheet(source, null, null)))\n    stylesheet.rules.foreach(checkRule)\n    stylesheet\n  }\n\n  def checkRule(cssRule: CssRule): Unit = cssRule match {\n    case CssFontFace(css) => checkProperties(css)\n    case CssMedia(rules, _) => rules.foreach(checkRule)\n    case CssPage(_, css) => checkProperties(css)\n    case CssStyle(_, css) => checkProperties(css)\n    case _ => ()\n  }\n\n  def parse(parts: List[String], substitutions: List[String]): Css = {\n    val errHandler = new ErrorHandler {\n      \n      def stringNo(c: Int): (Int, Int) =\n        parts.zip(substitutions).map { case (p, s) => p.length + s.length }.foldLeft(0 -> 0) { case ((sum, count), n) => if(sum > c) (sum, count) else (sum + n, count + 1) }\n      \n      def error(e: CSSParseException) = {\n        val c = e.getColumnNumber - 1\n        val (sum, cnt) = stringNo(c)\n        throw ValidationException(cnt, c - sum, e.getMessage)\n      }\n      \n      def fatalError(e: CSSParseException) = error(e)\n      def warning(e: CSSParseException) = error(e)\n    }\n    val source = new InputSource(new StringReader(parts.zip(substitutions :+ \"\").map { case (k, v) => k+v }.mkString))\n    val parser = new CSSOMParser(new SACParserCSS3())\n    parser.setErrorHandler(errHandler)\n\n    val styles = convertStyleDeclaration(parser.parseStyleDeclaration(source))\n    checkProperties(styles)\n    styles\n  }\n\n  def checkProperties(css: Css) = {\n    var prefixes = List(\"-webkit-\", \"-moz-\", \"-ms-\", \"-o-\")\n    for((k, v) <- css.properties) if (!prefixes.exists(k.startsWith) && !Properties.all.contains(k)) throw ValidationException(0, 0, s\"invalid CSS attribute '$k'\")\n  }\n  def convertStylesheet(cssStylesheet: CSSStyleSheet): List[CssRule] = {\n    val rules = cssStylesheet.getCssRules()\n    (0 until rules.getLength).map { r => convertRule(rules.item(r)) }.to[List]\n  }\n\n  def convertRule(rule: CSSRule): CssRule = rule match {\n    case rule: CSSCharsetRule => CssCharset(rule.getEncoding)\n    case rule: CSSFontFaceRule => CssFontFace(convertStyleDeclaration(rule.getStyle))\n    case rule: CSSImportRule => CssImport(rule.getHref, rule.getMedia.getMediaText)\n    case rule: CSSMediaRule =>\n      val rules = rule.getCssRules\n      val convertedRules = (0 until rules.getLength).map { r => convertRule(rules.item(r)) }.to[List]\n      CssMedia(convertedRules, rule.getMedia.getMediaText)\n    case rule: CSSPageRule => CssPage(rule.getSelectorText, convertStyleDeclaration(rule.getStyle))\n    case rule: CSSStyleRule => CssStyle(rule.getSelectorText, convertStyleDeclaration(rule.getStyle))\n    case rule: CSSUnknownRule => CssUnknown(rule.getCssText)\n  }\n\n  def convertStyleDeclaration(styleDecl: CSSStyleDeclaration): Css = {\n    val decls = (0 until styleDecl.getLength).map(styleDecl.item(_)).map { p => p -> styleDecl.getPropertyValue(p) }\n    Css(ListMap(decls: _*))\n  }\n}\n"
  },
  {
    "path": "css-test/shared/src/test/scala/rapture/css-test/tests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.css.test\n\nimport rapture.core._\nimport rapture.css._\nimport rapture.html._\nimport rapture.test._\n\nclass TestRun extends Programme {\n  include(CssTests)\n}\n\nobject CssTests extends TestSuite {\n  val `Embed ID in CSS` = test {\n    val identifier = DomId.auto\n    cssStylesheet\"\"\"$identifier { color: red; }\"\"\"\n  } returns cssStylesheet\"\"\"#identifier { color: red; }\"\"\"\n  \n  val `Embed class in CSS` = test {\n    val identifier = CssClass.auto\n    cssStylesheet\"\"\"$identifier { color: red; }\"\"\"\n  } returns cssStylesheet\"\"\".identifier { color: red; }\"\"\"\n  \n  val `Embed properties in CSS stylesheet` = test {\n    val properties = css\"border-width: 1px; color: red\"\n    cssStylesheet\"\"\".class { display: block; $properties }\"\"\"\n  } returns cssStylesheet\"\"\".class { display: block; border-width: 1px; color: red; }\"\"\"\n \n  val `Embed string in CSS` = test {\n    val color = \"red\"\n    css\"color: $color\"\n  }\n\n  val `Embed HTML tag in CSS stylesheet` = test {\n    \n    import htmlSyntax._\n    \n    cssStylesheet\"\"\"$Div { color: red; }\"\"\"\n  } returns cssStylesheet\"\"\"div { color: red; }\"\"\"\n  \n  val `Check stylesheet well-formedness` = test {\n    \n    cssStylesheet\"\"\"div { color: red; }\"\"\"\n  } returns cssStylesheet\"\"\"div { color: red; }\"\"\"\n}\n\n"
  },
  {
    "path": "csv/shared/src/main/scala/rapture/csv/csv.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.csv\n\nimport rapture.core._\nimport rapture.io._\nimport rapture.uri._\nimport rapture.fs._\nimport rapture.codec._\n\nimport encodings.`UTF-8`._\n\nimport language.experimental.macros\n\nobject ReadCsvHeader {\n  implicit val readCsvHeader: ReadCsvHeader = ReadCsvHeader(true)\n}\ncase class ReadCsvHeader(header: Boolean)\n\nobject CsvTest {\n  import csvBackends.simple._\n  def main(args: Seq[String]) = Csv.parse(uri\"file:///home/jpretty/test.csv\")\n}\n\ncase class CsvParseException(line: Int, col: Int) extends RuntimeException {\n  override def getMessage = s\"\"\"parse error: expected `\"`\"\"\"\n}\nsealed trait CsvGetException extends RuntimeException\ncase class CsvMissingValue(col: Int) extends CsvGetException {\n  override def getMessage = s\"missing value: Column $col does not exist\"\n}\ncase class CsvTypeMismatch(typeName: String, col: Int) extends CsvGetException {\n  override def getMessage = s\"type mismatch: Could not read value of type $typeName in column $col\"\n}\n\ntrait `Csv.parse` extends MethodConstraint\ntrait `CsvRow#as` extends MethodConstraint\ntrait `Csv#mapAs` extends MethodConstraint\ntrait `CsvCell#as` extends MethodConstraint\n\nclass KeyedCsvRow(val csvRow: CsvRow, val keys: Map[String, Int]) {\n  def apply(key: String): CsvCell = csvRow.apply(keys(key))\n}\n\nclass CsvRow(val elems: Seq[String]) {\n  def apply(idx: Int): CsvCell = CsvCell(elems(idx), idx)\n  def as[T](implicit mode: Mode[`CsvRow#as`], extractor: CsvRowExtractor[T]): mode.Wrap[T, CsvGetException] =\n    extractor.extract(elems, mode)\n\n  override def toString = elems.mkString(\"\\\"\", \"\\\",\\\"\", \"\\\"\")\n}\n\nobject CsvRowExtractor {\n  implicit def generateExtractor[T]: CsvRowExtractor[T] = macro Macros.extractorMacro[T]\n}\ntrait CsvRowExtractor[T] {\n  def extract(values: Seq[String], mode: Mode[_]): mode.Wrap[T, CsvGetException]\n}\n\ncase class BadLength(len: Int) extends Exception(\"Bad length: \" + len)\n\nobject CsvCellExtractor {\n  implicit val stringExtractor: CsvCellExtractor[String] = new CsvCellExtractor[String] {\n    type ExceptionType = CsvGetException\n    def extract(value: String, c: Int, mode: Mode[_]): mode.Wrap[String, CsvGetException] =\n      mode.wrap(value)\n  }\n\n  implicit val intExtractor: CsvCellExtractor[Int] = new CsvCellExtractor[Int] {\n    type ExceptionType = CsvGetException\n    def extract(value: String, c: Int, mode: Mode[_]): mode.Wrap[Int, CsvGetException] =\n      mode.wrap {\n        try value.toInt\n        catch { case e: Exception => mode.exception(CsvTypeMismatch(\"integer\", c)) }\n      }\n  }\n\n  implicit val doubleExtractor: CsvCellExtractor[Double] = new CsvCellExtractor[Double] {\n    type ExceptionType = CsvGetException\n    def extract(value: String, c: Int, mode: Mode[_]): mode.Wrap[Double, CsvGetException] =\n      mode.wrap {\n        try value.toDouble\n        catch { case e: Exception => mode.exception(CsvTypeMismatch(\"double\", c)) }\n      }\n  }\n\n  implicit val charExtractor: CsvCellExtractor[Char] = new CsvCellExtractor[Char] {\n    type ExceptionType = BadLength\n    def extract(value: String, c: Int, mode: Mode[_]): mode.Wrap[Char, CsvGetException with BadLength] = mode.wrap {\n      if (value.length == 1) value.head\n      else {\n        mode.exception(CsvTypeMismatch(\"character\", c))\n        '\\u0000'\n      }\n    }\n  }\n}\n\ntrait CsvCellExtractor[T] {\n  type ExceptionType <: Exception\n  def extract(value: String, c: Int, mode: Mode[_]): mode.Wrap[T, CsvGetException with ExceptionType]\n}\n\ncase class CsvCell(value: String, col: Int) {\n  def as[T](mode: Mode[`CsvCell#as`])(ext: CsvCellExtractor[T]): mode.Wrap[T, CsvGetException with ext.ExceptionType] =\n    ext.extract(value, col, mode)\n\n  override def toString = value\n}\n\ncase class Csv(rows: Vector[CsvRow]) extends Seq[CsvRow] {\n  def iterator = rows.iterator\n  def apply(idx: Int) = rows(idx)\n  def length = rows.length\n\n  override def toString = rows.take(4).mkString(\"\\n\") + (if (rows.length > 4) \"\\n...\" else \"\")\n\n  def mapAs[T: CsvRowExtractor](implicit mode: Mode[`Csv#mapAs`]): mode.Wrap[Seq[T], CsvGetException] = mode.wrap {\n    rows.map { row =>\n      mode.unwrap(?[CsvRowExtractor[T]].extract(row.elems, mode))\n    }\n  }\n}\n\nobject Csv {\n  def parse[Res](resource: Res)(implicit mode: Mode[`Csv.parse`],\n                                reader: Reader[Res, String],\n                                backend: CsvBackend): mode.Wrap[Csv, CsvParseException] = mode.wrap {\n    Csv(reader.input(resource).to[Vector].zipWithIndex.map {\n      case (ln, idx) =>\n        new CsvRow(mode.unwrap(backend.parseRow(ln, idx, mode)))\n    })\n  }\n\n  def extractor[T: CsvCellExtractor] = ?[CsvCellExtractor[T]]\n}\n\ntrait CsvBackend { def parseRow(s: String, line: Int, mode: Mode[_]): mode.Wrap[Seq[String], CsvParseException] }\n\nobject csvBackends {\n  object simple {\n    implicit val simpleBackend: CsvBackend = new CsvBackend {\n      def parseRow(s: String, line: Int, mode: Mode[_]): mode.Wrap[Seq[String], CsvParseException] = mode.wrap {\n        var cells: Vector[String] = Vector()\n        var cur = 0\n        var quoted = false\n        var expectingQuote = false\n        var sb = new StringBuilder\n        while (cur < s.length) {\n          s(cur) match {\n            case '\"' =>\n              if (sb.isEmpty && !quoted) {\n                quoted = true\n              } else if (quoted) {\n                quoted = false\n              } else if (expectingQuote) {\n                sb.append('\"')\n                expectingQuote = false\n              } else expectingQuote = true\n              cur += 1\n            case _ if expectingQuote =>\n              mode.exception(CsvParseException(line, cells.length))\n            case ',' if !quoted =>\n              cells = cells :+ sb.toString.trim\n              sb = new StringBuilder\n              cur += 1\n            case other =>\n              sb.append(other)\n              cur += 1\n          }\n        }\n        cells :+ sb.toString.trim\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "csv/shared/src/main/scala/rapture/csv/macros.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.csv\n\nimport rapture.core._\nimport rapture.base._\n\nobject Macros {\n\n  def extractorMacro[T: c.WeakTypeTag](c: BlackboxContext): c.Expr[CsvRowExtractor[T]] = {\n    import c.universe._\n    import compatibility._\n\n    val cellExtractor = typeOf[CsvCellExtractor[_]].typeSymbol.asType.toTypeConstructor\n\n    require(weakTypeOf[T].typeSymbol.asClass.isCaseClass)\n\n    val params = declarations(c)(weakTypeOf[T]).collect {\n      case m: MethodSymbol if m.isCaseAccessor => m.asMethod\n    }.zipWithIndex.map {\n      case (p, i) =>\n        val searchType = appliedType(cellExtractor, List(p.returnType))\n        val inferredImplicit = c.inferImplicitValue(searchType, false, false)\n\n        q\"mode.unwrap($inferredImplicit.extract(values($i), $i, mode))\"\n    }\n\n    val construction = c.Expr[T](q\"new ${weakTypeOf[T]}(..$params)\")\n\n    reify {\n      new CsvRowExtractor[T] {\n        def extract(values: Seq[String], mode: Mode[_]): mode.Wrap[T, CsvGetException] =\n          mode.wrap(construction.splice)\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "currency/shared/src/main/scala/rapture/currency/currency.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.currency\n\nimport rapture.core._\n\nobject Currency {\n\n  trait Key\n  case class Evidence[C <: Currency.Key](currency: Currency { type Key = C })\n\n  object Arithmetic extends Arithmetic_1 {\n    implicit def sameCurrencies[C <: Currency.Key]: Arithmetic[Money[C], Money[C]] { type Return = Money[C] } =\n      new Arithmetic[Money[C], Money[C]] {\n        type Return = Money[C]\n        def add(left: Money[C], right: Money[C]): Money[C] = Money(left.currency, left.amount + right.amount)\n      }\n\n    implicit def currencyBaskets[C <: Currency.Key, C2 <: Currency.Key]\n      : Arithmetic[CurrencyBasket[C], CurrencyBasket[C2]] { type Return = CurrencyBasket[C with C2] } =\n      new Arithmetic[CurrencyBasket[C], CurrencyBasket[C2]] {\n        type Return = CurrencyBasket[C with C2]\n        def add(left: CurrencyBasket[C], right: CurrencyBasket[C2]): CurrencyBasket[C with C2] =\n          CurrencyBasket[C with C2](left.amounts.foldLeft(right.amounts) {\n            case (acc, (k, v)) =>\n              acc.updated(k, acc.get(k).getOrElse(0.0) + v)\n          })\n      }\n\n    implicit def currencyBasketAndMoney[C <: Currency.Key, C2 <: Currency.Key]\n      : Arithmetic[CurrencyBasket[C], Money[C2]] { type Return = CurrencyBasket[C with C2] } =\n      new Arithmetic[CurrencyBasket[C], Money[C2]] {\n        type Return = CurrencyBasket[C with C2]\n        def add(left: CurrencyBasket[C], right: Money[C2]): CurrencyBasket[C with C2] =\n          CurrencyBasket[C with C2](\n              left.amounts.updated(right.currency, left.amounts.get(right.currency).getOrElse(0.0) + right.amount))\n      }\n\n    implicit def moneyAndCurrencyBasket[C <: Currency.Key, C2 <: Currency.Key]\n      : Arithmetic[Money[C], CurrencyBasket[C2]] { type Return = CurrencyBasket[C with C2] } =\n      new Arithmetic[Money[C], CurrencyBasket[C2]] {\n        type Return = CurrencyBasket[C with C2]\n        def add(left: Money[C], right: CurrencyBasket[C2]): CurrencyBasket[C with C2] =\n          CurrencyBasket[C with C2](\n              right.amounts.updated(left.currency, right.amounts.get(left.currency).getOrElse(0.0) + left.amount))\n      }\n  }\n\n  trait Arithmetic_1 {\n    implicit def differentCurrencies[C <: Currency.Key, C2 <: Currency.Key]\n      : Arithmetic[Money[C], Money[C2]] { type Return = CurrencyBasket[C with C2] } =\n      new Arithmetic[Money[C], Money[C2]] {\n        type Return = CurrencyBasket[C with C2]\n        def add(left: Money[C], right: Money[C2]): CurrencyBasket[C with C2] =\n          if (left.currency == right.currency)\n            CurrencyBasket[C with C2](Map(left.currency -> (left.amount + right.amount)))\n          else\n            CurrencyBasket[C with C2](Map(left.currency -> left.amount, right.currency -> right.amount))\n      }\n  }\n\n  trait Arithmetic[T1, T2] {\n    type Return\n    def add(left: T1, right: T2): Return\n  }\n}\n\ncase class Currency(code: String, name: String, decimalPlaces: Int, prefix: String, suffix: String) {\n  type Key <: Currency.Key\n  override def hashCode = code.hashCode\n  override def toString = code\n  override def equals(that: Any) = that match {\n    case that: Currency if that.code == code => true\n    case _ => false\n  }\n  def apply[N: Numeric](amount: N): Money[Key] = Money[Key](this, implicitly[Numeric[N]].toDouble(amount))\n}\n\ncase class InvalidMoney(currency: Currency)\n    extends Exception(s\"this is not a valid money value of currency ${currency.code}\")\n\nobject Money {\n  implicit def moneySerializer[C <: Currency.Key]: StringSerializer[Money[C]] = new StringSerializer[Money[C]] {\n    def serialize(m: Money[C]) = {\n      implicit val df: DecimalFormat = DecimalPlaces(m.currency.decimalPlaces)\n      s\"${String(m.amount)}${m.currency.code}\"\n    }\n  }\n\n  implicit def moneyParser[C <: Currency.Key](\n      implicit ev: Currency.Evidence[C]): StringParser[Money[C]] { type Throws = InvalidMoney } =\n    new StringParser[Money[C]] {\n      type Throws = InvalidMoney\n      def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Money[C], InvalidMoney] = mode.wrap {\n        if (s.substring(s.length - 3) == ev.currency.code) {\n          try Money[C](ev.currency, s.dropRight(3).toDouble)\n          catch { case e: Exception => throw InvalidMoney(ev.currency) }\n        } else throw InvalidMoney(ev.currency)\n      }\n    }\n}\n\ncase class Money[C <: Currency.Key](currency: Currency { type Key = C }, amount: Double) {\n\n  def unary_- = Money[C](currency, -amount)\n\n  def +[C2 <: Currency.Key](m: Money[C2])(\n      implicit arithmetic: Currency.Arithmetic[Money[C], Money[C2]]): arithmetic.Return =\n    arithmetic.add(this, m)\n\n  def -[C2 <: Currency.Key](m: Money[C2])(\n      implicit arithmetic: Currency.Arithmetic[Money[C], Money[C2]]): arithmetic.Return =\n    arithmetic.add(this, -m)\n\n  def *[N: Numeric](times: N): Money[C] = Money(currency, amount * implicitly[Numeric[N]].toDouble(times))\n\n  def /[N: Numeric](divisor: N): Money[C] = *(1.0 / implicitly[Numeric[N]].toDouble(divisor))\n\n  def <(m: Money[C]) = amount < m.amount\n  def <=(m: Money[C]) = amount <= m.amount\n  def >(m: Money[C]) = amount > m.amount\n  def >=(m: Money[C]) = amount >= m.amount\n\n  override def toString = {\n    implicit val df: DecimalFormat = DecimalPlaces(currency.decimalPlaces)\n    s\"${currency.prefix}${String(amount)}${currency.suffix}\"\n  }\n\n}\n\ncase class CurrencyBasket[C <: Currency.Key](amounts: Map[Currency, Double]) {\n\n  def +[M](m: M)(implicit arithmetic: Currency.Arithmetic[CurrencyBasket[C], M]): arithmetic.Return =\n    arithmetic.add(this, m)\n\n  def unary_- = CurrencyBasket[C](amounts.mapValues(-_))\n\n  def *[N: Numeric](times: N): CurrencyBasket[C] =\n    CurrencyBasket(amounts.mapValues(_ * implicitly[Numeric[N]].toDouble(times)))\n\n  def /[N: Numeric](divisor: N): CurrencyBasket[C] = *(1.0 / implicitly[Numeric[N]].toDouble(divisor))\n\n  def apply[C2 >: C <: Currency.Key](implicit ev: Currency.Evidence[C2]): Money[C2] =\n    Money[C2](ev.currency, amounts(ev.currency))\n\n  override def toString =\n    amounts.map {\n      case (currency, value) =>\n        implicit val df: DecimalFormat = DecimalPlaces(currency.decimalPlaces)\n        s\"${String(value)}${currency.code}\"\n    }.mkString(\", \")\n}\n"
  },
  {
    "path": "currency/shared/src/main/scala/rapture/currency/iso.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.currency\n\n/* Includes the twenty most-traded currencies, as listed on Wikipedia, with the exception of Turkish Lira, because\n   its ISO 4217 code is `TRY`, which is an inconvenient identifier. */\nobject currencies {\n  object Gbp extends Currency(\"GBP\", \"Pound sterling\", 2, \"£\", \"\") {\n    type Key = Gbp\n    implicit val currencyEvidence: Currency.Evidence[Gbp] = Currency.Evidence(this)\n  }\n  trait Gbp extends Currency.Key\n\n  object Usd extends Currency(\"USD\", \"United States dollar\", 2, \"$\", \"\") {\n    type Key = Usd\n    implicit val currencyEvidence: Currency.Evidence[Usd] = Currency.Evidence(this)\n  }\n  trait Usd extends Currency.Key\n\n  object Eur extends Currency(\"EUR\", \"Euros\", 2, \"€\", \"\") {\n    type Key = Eur\n    implicit val currencyEvidence: Currency.Evidence[Eur] = Currency.Evidence(this)\n  }\n  trait Eur extends Currency.Key\n\n  object Jpy extends Currency(\"JPY\", \"Japanese yen\", 2, \"¥\", \"\") {\n    type Key = Jpy\n    implicit val currencyEvidence: Currency.Evidence[Jpy] = Currency.Evidence(this)\n  }\n  trait Jpy extends Currency.Key\n\n  object Aud extends Currency(\"AUD\", \"Australian dollar\", 2, \"$\", \"\") {\n    type Key = Aud\n    implicit val currencyEvidence: Currency.Evidence[Aud] = Currency.Evidence(this)\n  }\n  trait Aud extends Currency.Key\n\n  object Chf extends Currency(\"CHF\", \"Swiss franc\", 2, \"Fr\", \"\") {\n    type Key = Chf\n    implicit val currencyEvidence: Currency.Evidence[Chf] = Currency.Evidence(this)\n  }\n  trait Chf extends Currency.Key\n\n  object Cad extends Currency(\"CAD\", \"Canadian dollar\", 2, \"$\", \"\") {\n    type Key = Cad\n    implicit val currencyEvidence: Currency.Evidence[Cad] = Currency.Evidence(this)\n  }\n  trait Cad extends Currency.Key\n\n  object Mxn extends Currency(\"MXN\", \"Mexican peso\", 2, \"$\", \"\") {\n    type Key = Mxn\n    implicit val currencyEvidence: Currency.Evidence[Mxn] = Currency.Evidence(this)\n  }\n  trait Mxn extends Currency.Key\n\n  object Cny extends Currency(\"CNY\", \"Chinese yuan\", 2, \"¥\", \"\") {\n    type Key = Cny\n    implicit val currencyEvidence: Currency.Evidence[Cny] = Currency.Evidence(this)\n  }\n  trait Cny extends Currency.Key\n\n  object Nzd extends Currency(\"NZD\", \"New Zealand dollar\", 2, \"$\", \"\") {\n    type Key = Nzd\n    implicit val currencyEvidence: Currency.Evidence[Nzd] = Currency.Evidence(this)\n  }\n  trait Nzd extends Currency.Key\n\n  object Sek extends Currency(\"SEK\", \"Swedish krona\", 2, \"kr\", \"\") {\n    type Key = Sek\n    implicit val currencyEvidence: Currency.Evidence[Sek] = Currency.Evidence(this)\n  }\n  trait Sek extends Currency.Key\n\n  object Rub extends Currency(\"RUB\", \"Russian ruble\", 2, \"₽\", \"\") {\n    type Key = Rub\n    implicit val currencyEvidence: Currency.Evidence[Rub] = Currency.Evidence(this)\n  }\n  trait Rub extends Currency.Key\n\n  object Hkd extends Currency(\"HKD\", \"Hong Kong dollar\", 2, \"$\", \"\") {\n    type Key = Hkd\n    implicit val currencyEvidence: Currency.Evidence[Hkd] = Currency.Evidence(this)\n  }\n  trait Hkd extends Currency.Key\n\n  object Nok extends Currency(\"NOK\", \"Norwegian krone\", 2, \"kr\", \"\") {\n    type Key = Nok\n    implicit val currencyEvidence: Currency.Evidence[Nok] = Currency.Evidence(this)\n  }\n  trait Nok extends Currency.Key\n\n  object Sgd extends Currency(\"SGD\", \"Singapore dollar\", 2, \"$\", \"\") {\n    type Key = Sgd\n    implicit val currencyEvidence: Currency.Evidence[Sgd] = Currency.Evidence(this)\n  }\n  trait Sgd extends Currency.Key\n\n  object Krw extends Currency(\"KRW\", \"South Korean won\", 2, \"₩\", \"\") {\n    type Key = Krw\n    implicit val currencyEvidence: Currency.Evidence[Krw] = Currency.Evidence(this)\n  }\n  trait Krw extends Currency.Key\n\n  object Zar extends Currency(\"ZAR\", \"South African Rand\", 2, \"R\", \"\") {\n    type Key = Zar\n    implicit val currencyEvidence: Currency.Evidence[Zar] = Currency.Evidence(this)\n  }\n  trait Zar extends Currency.Key\n\n  object Brl extends Currency(\"BRL\", \"Brazilian real\", 2, \"R$\", \"\") {\n    type Key = Brl\n    implicit val currencyEvidence: Currency.Evidence[Brl] = Currency.Evidence(this)\n  }\n  trait Brl extends Currency.Key\n\n  object Inr extends Currency(\"INR\", \"Indian rupee\", 2, \"₹\", \"\") {\n    type Key = Inr\n    implicit val currencyEvidence: Currency.Evidence[Inr] = Currency.Evidence(this)\n  }\n  trait Inr extends Currency.Key\n\n}\n"
  },
  {
    "path": "data/shared/src/main/scala/rapture/data/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.data\n\nimport rapture.core._\n\nobject DataTypes {\n  sealed class DataType(val name: String)\n  case object Number extends DataType(\"number\")\n  case object String extends DataType(\"string\")\n  case object Null extends DataType(\"null\")\n  case object Boolean extends DataType(\"boolean\")\n  case object Array extends DataType(\"array\")\n  case object Object extends DataType(\"object\")\n  case object Scalar extends DataType(\"scalar\")\n  case object Container extends DataType(\"container\")\n  case object Any extends DataType(\"any\")\n}\n\n@implicitNotFound(msg = \"Cannot find ${Ast} parser for values of type ${Source}\")\ntrait Parser[-Source, +Ast <: DataAst] {\n  val ast: Ast\n  def parse(s: Source): Option[Any]\n}\n\ntrait DataAst {\n\n  /** Dereferences the named element within the JSON object. */\n  def dereferenceObject(obj: Any, element: String): Any =\n    getObject(obj)(element)\n\n  /** Returns at `Iterator[String]` over the names of the elements in the JSON object. */\n  def getKeys(obj: Any): Iterator[String] =\n    getObject(obj).keys.iterator\n\n  /** Gets the indexed element from the parsed JSON array. */\n  def dereferenceArray(array: Any, element: Int): Any =\n    getArray(array)(element)\n\n  /** Tests if the element represents an `Object` */\n  def isObject(any: Any): Boolean\n\n  /** Tests if the element represents an `Array` */\n  def isArray(any: Any): Boolean\n\n  def isNull(any: Any): Boolean\n\n  /** Extracts a JSON object as a `Map[String, Any]` from the parsed JSON. */\n  def getObject(obj: Any): Map[String, Any]\n\n  def getChildren(obj: Any): Seq[Any] = {\n    val m = getObject(obj)\n    getKeys(obj).to[List] map m\n  }\n\n  def fromObject(obj: Map[String, Any]): Any\n\n  /** Extracts a JSON array as a `Seq[Any]` from the parsed JSON. */\n  def getArray(array: Any): Seq[Any]\n\n  def fromArray(array: Seq[Any]): Any\n\n  def isScalar(any: Any): Boolean\n\n  def getString(any: Any): Any\n  def isString(any: Any): Boolean\n\n  def convert(any: Any, oldAst: DataAst): Any\n}\n\ntrait MutableDataAst extends DataAst {\n  def setObjectValue(obj: Any, name: String, value: Any): Any\n  def setArrayValue(array: Any, index: Int, value: Any): Any\n  def removeObjectValue(obj: Any, name: String): Any\n  def addArrayValue(array: Any, value: Any): Any\n}\n"
  },
  {
    "path": "data/shared/src/main/scala/rapture/data/context.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.data\n\nimport rapture.base._\nimport rapture.core._\n\nobject patternMatching {\n  object exactArrays {\n    implicit val implicitArrayMachingConfig = new ArrayMatchingConfig { def checkLengths = true }\n  }\n\n  object exactObjects {\n    implicit val implicitArrayMachingConfig = new ObjectMatchingConfig { def checkSizes = true }\n  }\n\n  object exact {\n    implicit val implicitArrayMachingConfig = new ObjectMatchingConfig with ArrayMatchingConfig {\n      def checkSizes = true\n      def checkLengths = true\n    }\n  }\n}\n\nobject ArrayMatchingConfig {\n  implicit val ignoreByDefault = new ArrayMatchingConfig { def checkLengths = false }\n}\n\nobject ObjectMatchingConfig {\n  implicit val ignoreByDefault = new ObjectMatchingConfig { def checkSizes = false }\n}\n\ntrait ArrayMatchingConfig { def checkLengths: Boolean }\ntrait ObjectMatchingConfig { def checkSizes: Boolean }\n\nabstract class DataContextMacros[+Data <: DataType[Data, DataAst], -AstType <: DataAst] {\n\n  def parseSource(s: List[String], stringsUsed: List[Boolean]): Option[(Int, Int, String)]\n\n  def dataCompanion(c: BlackboxContext): c.Expr[DataCompanion[Data, AstType]]\n\n  def contextMacro(c: BlackboxContext)(exprs: c.Expr[ForcedConversion[Data]]*)(\n      parser: c.Expr[Parser[String, AstType]]): c.Expr[Data] = {\n    import c.universe._\n    \n    c.prefix.tree match {\n      case Select(Apply(Apply(_, List(Apply(_, rawParts))), _), _) =>\n        val ys = rawParts.to[List]\n        val text = rawParts map { case lit @ Literal(Constant(part: String)) => part }\n\n        val listExprs = c.Expr[List[ForcedConversion[Data]]](q\"_root_.scala.List(..${exprs.map(_.tree).to[List]})\")\n\n        val stringsUsed: List[Boolean] = listExprs.tree match {\n          case Apply(_, bs) =>\n            bs.map {\n              case Apply(Apply(TypeApply(Select(_, nme), _), _), _) => nme.toString == \"forceStringConversion\"\n            }\n        }\n\n        parseSource(text, stringsUsed) foreach {\n          case (n, offset, msg) =>\n            val oldPos = ys(n).asInstanceOf[Literal].pos\n\n            val newPos = oldPos.withPoint(oldPos.start + offset)\n            c.error(newPos, msg)\n        }\n\n        val listParts = c.Expr[List[ForcedConversion[Data]]](q\"_root_.scala.List(..$rawParts)\")\n\n        val comp = dataCompanion(c)\n\n        reify {\n          val sb = new StringBuilder\n          val textParts = listParts.splice.iterator\n          val expressions: Iterator[ForcedConversion[_]] = listExprs.splice.iterator\n\n          sb.append(textParts.next())\n\n          while (textParts.hasNext) {\n            sb.append(\n                comp.splice.construct(MutableCell(expressions.next.value), Vector())(parser.splice.ast).toBareString)\n            sb.append(textParts.next)\n          }\n\n          comp.splice.construct(MutableCell(parser.splice.parse(sb.toString).get), Vector())(parser.splice.ast)\n        }\n    }\n  }\n}\n\nclass DataContext[+Data <: DataType[Data, DataAst], -AstType <: DataAst](companion: DataCompanion[Data, AstType],\n                                                                         sc: StringContext) {\n\n  protected def uniqueNonSubstring(s: String) = {\n    var cur, m = 0\n    s foreach { c =>\n      cur = if (c == '_') cur + 1 else 0\n      m = m max cur\n    }\n    \"_\" * (m + 1)\n  }\n\n  def unapplySeq[D <: DataType[D, DataAst]](data: D)(\n      implicit arrayMatching: ArrayMatchingConfig,\n      objectMatching: ObjectMatchingConfig,\n      parser: Parser[String, AstType]): Option[Seq[DataType[D, DataAst]]] =\n    try {\n      val placeholder = uniqueNonSubstring(sc.parts.mkString)\n      val PlaceholderNumber = (placeholder + \"([0-9]+)\" + placeholder).r\n      val count = Iterator.from(0)\n      val txt = sc.parts.reduceLeft(_ + s\"\"\"\"${placeholder}${count.next()}${placeholder}\" \"\"\" + _)\n\n      val paths: Array[Vector[Either[Int, String]]] =\n        Array.fill[Vector[Either[Int, String]]](sc.parts.length - 1)(Vector())\n\n      val arrayLengths = new collection.mutable.HashMap[Vector[Either[Int, String]], Int]\n      val objectSizes = new collection.mutable.HashMap[Vector[Either[Int, String]], Int]\n\n      def extract(any: Any, path: Vector[Either[Int, String]]): Unit = {\n        // FIXME: Avoid using isScalar if possible\n        if (parser.ast.isScalar(any)) {\n          val ext = data.$extract(path).as[Any]\n          if (data.$extract(path).as[Any] != any) throw new Exception(\"Value doesn't match (1)\")\n        } else if (parser.ast.isObject(any)) {\n          val obj = parser.ast.getObject(any)\n          objectSizes(path) = obj.size\n          obj foreach {\n            case (k, v) =>\n              if (parser.ast.isString(v)) parser.ast.getString(v) match {\n                case str: CharSequence =>\n                  str match {\n                    case PlaceholderNumber(n) =>\n                      paths(n.toInt) = path :+ Right(k)\n                    case _ => extract(v, path :+ Right(k))\n                  }\n              } else extract(v, path :+ Right(k))\n          }\n        } else if (parser.ast.isArray(any)) {\n          val array = parser.ast.getArray(any)\n          if (arrayMatching.checkLengths) arrayLengths(path) = array.length\n          array.zipWithIndex foreach {\n            case (e, i) =>\n              if (parser.ast.isString(e)) parser.ast.getString(e) match {\n                case str: CharSequence =>\n                  str match {\n                    case PlaceholderNumber(n) =>\n                      paths(n.toInt) = path :+ Left(i)\n                    case _ => extract(e, path :+ Left(i))\n                  }\n              } else extract(e, path :+ Left(i))\n          }\n        } else throw new Exception(\"Value doesn't match (2)\")\n      }\n\n      extract(parser.parse(txt).get, Vector())\n\n      // Using a ListBuffer to work around SI-8947\n      val extractsBuffer = new collection.mutable.ListBuffer[D]\n      paths foreach { p =>\n        extractsBuffer += data.$extract(p)\n      }\n      val extracts = extractsBuffer.toList\n      extracts.foreach(_.$normalize)\n      val matchedArrayLengths = arrayLengths.forall {\n        case (p, len) =>\n          parser.ast.getArray(data.$extract(p).$normalize).length == len\n      }\n\n      val matchedObjectSizes = objectSizes.forall {\n        case (p, s) =>\n          if (objectMatching.checkSizes) parser.ast.getObject(data.$extract(p).$normalize).size == s\n          else parser.ast.getObject(data.$extract(p).$normalize).size >= 0\n      }\n\n      if (extracts.exists(_.$root.value == null) || !matchedArrayLengths || !matchedObjectSizes)\n        None\n      else Some(extracts)\n    } catch {\n      case e: Exception =>\n        None\n    }\n}\n"
  },
  {
    "path": "data/shared/src/main/scala/rapture/data/data.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.data\n\nimport rapture.core._\n\nimport scala.util.Try\n\nimport language.dynamics\n\n@implicitNotFound(\"Cannot find an implicit Formatter for ${AstType} data.\")\ntrait Formatter[-AstType <: DataAst] {\n  type Out\n  def format(any: Any): Out\n}\n\nobject DataCompanion { object Empty }\n\nobject serializedNames {\n  object inUnderscoreStyle {\n    def apply[V, D] = nameMapperImplicit[V, D]\n    implicit def nameMapperImplicit[V, D] = new NameMapper[V, D] {\n      def encode(name: String): String = name.flatMap {\n        case lower if lower.isLower => lower.toString\n        case upper if upper.isUpper => s\"_$upper\".toLowerCase\n        case other => other.toString\n      }\n\n      def decode(name: String): String = name.foldLeft((\"\", false)) {\n        case ((acc, _), '_') => (acc, true)\n        case ((acc, true), other) => (acc+other.toString.toUpperCase, false)\n        case ((acc, false), other) => (acc+other, false)\n      }._1\n    }\n  }\n  \n  object inDashedStyle {\n    def apply[V, D] = nameMapperImplicit[V, D]\n    implicit def nameMapperImplicit[V, D] = new NameMapper[V, D] {\n      def encode(name: String): String = name.flatMap {\n        case lower if lower.isLower => lower.toString\n        case upper if upper.isUpper => s\"-$upper\".toLowerCase\n        case other => other.toString\n      }\n\n      def decode(name: String): String = name.foldLeft((\"\", false)) {\n        case ((acc, _), '-') => (acc, true)\n        case ((acc, true), other) => (acc+other.toString.toUpperCase, false)\n        case ((acc, false), other) => (acc+other, false)\n      }._1\n    }\n  }\n  \n  object identical {\n    def apply[V, D] = nameMapperImplicit[V, D]\n    implicit def nameMapperImplicit[V, D] = new NameMapper[V, D] {\n      def encode(name: String): String = name\n      def decode(name: String): String = name\n    }\n  }\n}\n\nobject NameMapper {\n  implicit def identityNameMapper[V, D]: NameMapper[V, D] = serializedNames.identical[V, D]\n}\n\ntrait NameMapper[+Value, +Data] {\n  def encode(name: String): String\n  def decode(name: String): String\n}\n\ntrait DataCompanion[+Type <: DataType[Type, DataAst], -AstType <: DataAst] {\n\n  type ParseMethodConstraint <: MethodConstraint\n\n  def empty(implicit ast: AstType) =\n    construct(MutableCell(ast.fromObject(Map())), Vector())\n\n  def construct(any: MutableCell, path: Vector[Either[Int, String]])(implicit ast: AstType): Type\n\n  def parse[Source: StringSerializer](s: Source)(implicit mode: Mode[ParseMethodConstraint],\n                                                 parser: Parser[Source, AstType]): mode.Wrap[Type, ParseException] =\n    mode wrap {\n      construct(try MutableCell(parser.parse(s).get)\n                catch {\n                  case e: NoSuchElementException => mode.exception(ParseException(String(s)))\n                },\n                Vector())(parser.ast)\n    }\n\n  def raw(value: Any)(implicit ast: AstType): Type =\n    construct(MutableCell(value), Vector())\n\n  def format[T <: DataType[T, AstType]](data: T)(implicit f: Formatter[_ <: AstType]): f.Out =\n    f.format(data.$normalize)\n\n}\n\ncase class DynamicApplication[D](path: List[Either[Int, String]], application: ForcedConversion2[D])\n\nobject dictionaries {\n  object dynamic {\n    implicit val implicitDictionary: Dictionary[Nothing] = new Dictionary[Nothing](Nil)\n  }\n}\n\nobject Dictionary {\n\n  implicit def stringToDefineParam[S <: String](s: S): DefineParam[s.type] = new DefineParam[s.type](s)\n  class DefineParam[-T <: String](val value: String)\n\n  def define[T <: String](params: DefineParam[T]*): Dictionary[T] = new Dictionary[T](params.map(_.value))\n}\n@implicitNotFound(\"the key ${S} is not in the dictionary\")\nclass Dictionary[+S <: String](params: Seq[String])\n\ncase class DynamicPath[D](path: List[Either[Int, String]]) extends Dynamic {\n  def self = selectDynamic(\"self\")(null)\n  def selectDynamic[S <: String](v: S)(implicit dictionary: Dictionary[v.type]) = DynamicPath[D](Right(v) :: path)\n  def applyDynamic[S <: String](v: String)(i: Int)(implicit dictionary: Dictionary[v.type]) = DynamicPath[D](Left(i) :: Right(v) :: path)\n  def apply(i: Int) = DynamicPath[D](Left(i) :: path)\n\n  def updateDynamic[S <: String](v: String)(value: ForcedConversion2[D])(implicit dictionary: Dictionary[v.type]) =\n    DynamicApplication(Right(v) :: path, value)\n\n  def update(i: Int, value: ForcedConversion2[D]) =\n    DynamicApplication(Left(i) :: path, value)\n}\n\ncase class DynamicAccess[D](path: List[Either[Int, String]]) extends Dynamic {\n  def self = selectDynamic(\"self\")\n  def selectDynamic(v: String) = DynamicAccess[D](Right(v) :: path)\n  def applyDynamic(v: String)(i: Int) = DynamicAccess[D](Left(i) :: Right(v) :: path)\n  def apply(i: Int) = DynamicAccess[D](Left(i) :: path)\n}\n\ncase class MutableCell(var value: Any)\n\ntrait DynamicData[+T <: DynamicData[T, AstType], +AstType <: DataAst] extends Dynamic {\n\n  /** Assumes the Json object wraps a `Map`, and extracts the element `key`. */\n  def selectDynamic[S <: String](key: S)(implicit dictionary: Dictionary[key.type]): T = $deref(Right(key) +: $path)\n  \n  def self = selectDynamic(\"self\")(null)\n\n  //def applyDynamic(key: String)(i: Int = 0): T = $deref(Left(i) +: Right(key) +: $path)\n\n  def $deref($path: Vector[Either[Int, String]]): T\n  def $path: Vector[Either[Int, String]]\n\n}\n\nobject DataType {\n\n  class DataClassOperations[T <: DataType[T, AstType], AstType <: DataAst](dataType: T) {\n    def ++[S <: DataType[S, Rep] forSome { type Rep }](b: S): T = {\n      val ast = dataType.$ast\n\n      def merge(a: Any, b: Any): Any = {\n        if (ast.isObject(a) && ast.isObject(b)) {\n          ast.fromObject(ast.getKeys(b).foldLeft(ast.getObject(a)) {\n            case (as, k) =>\n              as + (k -> {\n                    if (as contains k) merge(as(k), ast.dereferenceObject(b, k)) else ast.dereferenceObject(b, k)\n                  })\n          })\n        } else if (ast.isArray(a) && ast.isArray(b)) ast.fromArray(ast.getArray(a) ++ ast.getArray(b))\n        else b\n      }\n\n      val left = dataType.$normalize\n      val right = if (ast != b.$ast) ast.convert(b.$normalize, b.$ast.asInstanceOf[DataAst]) else b.$normalize\n\n      dataType.$wrap(merge(left, right), Vector())\n    }\n\n    def delete(pvs: (DynamicAccess[T] => DynamicAccess[_ <: DataType[T, _ <: AstType]])*): T = {\n      dataType.$wrap(pvs.foldLeft(dataType.$normalize) {\n        case (cur, pv) =>\n          val dPath = pv(DynamicAccess(Nil))\n          val ast = dataType.$ast\n\n          def nav(path: List[Either[Int, String]], dest: Any): Any = path match {\n            case Nil =>\n              ???\n\n            case Right(next) :: Nil =>\n              ast.fromObject(ast.getObject(if(ast.isObject(dest)) dest else Map()) - next)\n              \n            case Right(next) :: list =>\n              val d = try ast.dereferenceObject(dest, next)\n              catch { case e: Exception => ast.fromObject(Map()) }\n              val src = ast.getObject(if (ast.isObject(dest)) dest else Map())\n              ast.fromObject(src + ((next, nav(list, d))))\n\n            case Left(next) :: Nil =>\n              val src = if (ast.isArray(dest)) ast.getArray(dest) else Nil\n              ast.fromArray(src.slice(0, next) ++ src.slice(next + 1, src.length))\n\n            case Left(next) :: list =>\n              val d = try ast.dereferenceArray(dest, next)\n              catch { case e: Exception => ast.fromArray(List()) }\n              val src = if (ast.isArray(dest)) ast.getArray(dest) else Nil\n              ast.fromArray(src.padTo(next + 1, ast.fromObject(Map())).updated(next, nav(list, d)))\n          }\n\n          nav(dPath.path.reverse, cur)\n      })\n    }\n    \n    def copy(pvs: (DynamicPath[T] => DynamicApplication[_ <: DataType[T, _ <: AstType]])*): T = {\n      dataType.$wrap(pvs.foldLeft(dataType.$normalize) {\n        case (cur, pv) =>\n          val dPath = pv(DynamicPath(Nil))\n          val ast = dataType.$ast\n\n          if (dPath.application.nothing) cur\n          else {\n\n            def nav(path: List[Either[Int, String]], dest: Any, v: Any): Any = path match {\n              case Nil =>\n                v\n\n              case Right(next) :: list =>\n                val d = try ast.dereferenceObject(dest, next)\n                catch { case e: Exception => ast.fromObject(Map()) }\n                val src = ast.getObject(if (ast.isObject(dest)) dest else Map())\n                ast.fromObject(src + ((next, nav(list, d, v))))\n\n              case Left(next) :: list =>\n                val d = try ast.dereferenceArray(dest, next)\n                catch { case e: Exception => ast.fromArray(List()) }\n                val src = if (ast.isArray(dest)) ast.getArray(dest) else Nil\n                ast.fromArray(src.padTo(next + 1, ast.fromObject(Map())).updated(next, nav(list, d, v)))\n            }\n\n            nav(dPath.path.reverse, cur, dPath.application.value)\n          }\n      })\n    }\n  }\n}\n\ntrait DataType[+T <: DataType[T, AstType], +AstType <: DataAst] {\n  val $root: MutableCell\n  implicit def $ast: AstType\n  def $path: Vector[Either[Int, String]]\n  def $normalize: Any = doNormalize(false)\n  def $wrap(any: Any, $path: Vector[Either[Int, String]] = Vector()): T\n  def $deref($path: Vector[Either[Int, String]] = Vector()): T\n  def $extract($path: Vector[Either[Int, String]]): T\n\n  def \\(key: String): T = $deref(Right(key) +: $path)\n  def \\(index: Int): T = $deref(Left(index) +: $path)\n\n  def \\\\(key: String): T = $wrap($ast.fromArray(derefRecursive(key, $normalize)))\n\n  def toBareString: String\n\n  private def derefRecursive(key: String, any: Any): Seq[Any] =\n    if ($ast.isObject(any)) $ast.getKeys(any).to[Seq].flatMap {\n      case k if k == key => Seq($ast.dereferenceObject(any, k))\n      case k => derefRecursive(key, $ast.dereferenceObject(any, k))\n    } else if ($ast.isArray(any)) $ast.getArray(any).flatMap(derefRecursive(key, _))\n      \n    else Nil\n\n  protected def doNormalize(orEmpty: Boolean): Any = {\n    yCombinator[(Any, Vector[Either[Int, String]]), Any] { fn =>\n      {\n        case (j, Vector()) => j: Any\n        case (j, t :+ e) =>\n          fn(({\n            if (e.bimap(x => $ast.isArray(j), x => $ast.isObject(j))) {\n              try e.bimap($ast.dereferenceArray(j, _), $ast.dereferenceObject(j, _))\n              catch {\n                case TypeMismatchException(exp, fnd) => throw TypeMismatchException(exp, fnd)\n                case exc: Exception =>\n                  if (orEmpty) DataCompanion.Empty\n                  else {\n                    e match {\n                      case Left(e) => throw MissingValueException(s\"[$e]\")\n                      case Right(e) => throw MissingValueException(e)\n                    }\n                  }\n              }\n            } else\n              throw TypeMismatchException(\n                  if ($ast.isArray(j)) DataTypes.Array else DataTypes.Object,\n                  e.bimap(l => DataTypes.Array, r => DataTypes.Object)\n              )\n          }, t))\n      }\n    }($root.value -> $path)\n  }\n\n  /** Assumes the Json object is wrapping a `T`, and casts (intelligently) to that type. */\n  def as[S](implicit ext: Extractor[S, T], mode: Mode[`Data#as`]): mode.Wrap[S, ext.Throws] =\n    ext.extract(this.asInstanceOf[T], $ast, mode)\n\n  def is[S](implicit ext: Extractor[S, T]): Boolean =\n    try {\n      ext.extract(this.asInstanceOf[T], $ast, modes.throwExceptions())\n      true\n    } catch {\n      case e: Exception => false\n    }\n\n  def apply(i: Int = 0): T = $deref(Left(i) +: $path)\n\n  override def equals(any: Any) =\n    try {\n      any match {\n        case any: DataType[_, _] => $normalize == any.$normalize\n        case _ => false\n      }\n    } catch { case e: Exception => false }\n\n  override def hashCode = $root.value.hashCode ^ 3271912\n\n}\n\ntrait MutableDataType[+T <: DataType[T, AstType], AstType <: MutableDataAst] extends DataType[T, AstType] {\n\n  def $updateParents(p: Vector[Either[Int, String]], newVal: Any): Unit =\n    p match {\n      case Vector() =>\n        $root.value = newVal\n      case Left(idx) +: init =>\n        val jb = $deref(init)\n        val newJb = $ast.setArrayValue(Try(jb.$normalize).getOrElse($ast.fromArray(Nil)), idx, newVal)\n\n        if (jb match {\n              case jb: AnyRef =>\n                newJb match {\n                  case newJb: AnyRef => jb ne newJb\n                  case _ => false\n                }\n              case jb => jb == newJb\n            }) $updateParents(init, newJb)\n      case Right(key) +: init =>\n        val jb = $deref(init)\n        val newJb = $ast.setObjectValue(Try(jb.$normalize).getOrElse($ast.fromObject(Map())), key, newVal)\n\n        if (jb match {\n              case jb: AnyRef =>\n                newJb match {\n                  case newJb: AnyRef => jb ne newJb\n                  case _ => false\n                }\n              case jb => jb == newJb\n            }) $updateParents(init, newJb)\n    }\n\n  /** Updates the element `key` of the JSON object with the value `v` */\n  def updateDynamic(key: String)(v: ForcedConversion2[T]): Unit =\n    if (!v.nothing)\n      $updateParents($path, $ast.setObjectValue(Try($normalize).getOrElse($ast.fromObject(Map())), key, v.value))\n\n  /** Updates the `i`th element of the JSON array with the value `v` */\n  def update[T2](i: Int, v: T2)(implicit ser: Serializer[T2, T]): Unit =\n    $updateParents($path, $ast.setArrayValue(Try($normalize).getOrElse($ast.fromArray(Nil)), i, ser.serialize(v)))\n\n  /** Removes the specified key from the JSON object */\n  def -=(k: String): Unit = $updateParents($path, $ast.removeObjectValue(doNormalize(true), k))\n\n  /** Adds the specified value to the JSON array */\n  def +=[T2](v: T2)(implicit ser: Serializer[T2, T]): Unit = {\n    val r = doNormalize(true)\n    val insert = if (r == DataCompanion.Empty) $ast.fromArray(Nil) else r\n    $updateParents($path, $ast.addArrayValue(insert, ser.serialize(v)))\n  }\n}\n\ntrait `Data#as` extends MethodConstraint\ntrait `Data#normalize` extends MethodConstraint\n\nobject ForcedConversion2 extends ForcedConversion2_1 {\n  implicit def forceOptConversion[T, D](opt: Option[T])(implicit ser: Serializer[T, D]) =\n    opt.map(t => ForcedConversion2[D](ser.serialize(t), false)) getOrElse\n      ForcedConversion2[D](null, true)\n}\n\ntrait ForcedConversion2_1 {\n  implicit def forceConversion[T, D](t: T)(implicit ser: Serializer[T, D]) =\n    ForcedConversion2[D](ser.serialize(t), false)\n}\n\ncase class ForcedConversion2[-D](value: Any, nothing: Boolean)\n\nobject ForcedConversion extends ForcedConversion_1 {\n  implicit def forceOptConversion[T, D](opt: Option[T])(implicit ser: Serializer[T, D]) =\n    opt.map(t => ForcedConversion[D](ser.serialize(t), false)) getOrElse\n      ForcedConversion[D](null, true)\n}\n\ntrait ForcedConversion_1 extends ForcedConversion_2 {\n  implicit def forceConversion[T, D](t: T)(implicit ser: Serializer[T, D]) =\n    ForcedConversion[D](ser.serialize(t), false)\n}\n\ntrait ForcedConversion_2 {\n  // The name of this method is significant for some additional checking done in the macro `contextMacro`.\n  implicit def forceStringConversion[D, T: StringSerializer](value: T)(implicit ser: Serializer[String, D]) =\n    ForcedConversion[D](ser.serialize(?[StringSerializer[T]].serialize(value)), false)\n}\n\ncase class ForcedConversion[-D](value: Any, nothing: Boolean)\n\ncase class ParseException(source: String, line: Option[Int] = None, column: Option[Int] = None)\n    extends Exception(\"Failed to parse source\")\n"
  },
  {
    "path": "data/shared/src/main/scala/rapture/data/exceptions.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.data\n\nsealed abstract class DataGetException(msg: String) extends RuntimeException(msg)\n\ncase class TypeMismatchException(found: DataTypes.DataType, expected: DataTypes.DataType)\n    extends DataGetException(s\"type mismatch: Expected ${expected.name} but found ${found.name}\")\n\ncase class MissingValueException(name: String = \"\")\n    extends DataGetException(\n        if (name.isEmpty)\n          \"missing value\"\n        else s\"missing value: $name\")\n"
  },
  {
    "path": "data/shared/src/main/scala/rapture/data/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.data\n\nimport rapture.core._\n\nimport scala.annotation._\n\nimport language.higherKinds\n\nimport scala.util._\n\ncase class FilterException() extends Exception(\"value was removed by filter\")\ncase class NotEmptyException() extends Exception\n\nobject GeneralExtractors {\n\n  def tryExtractor[Data <: DataType[Data, _ <: DataAst], T](\n      implicit ext: Extractor[T, Data]): Extractor[Try[T], Data] { type Throws = Nothing } =\n    new Extractor[Try[T], Data] {\n      type Throws = Nothing\n      def extract(any: Data, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Try[T], Throws] = mode.wrap {\n        try ext.extract(any.$wrap(any.$normalize), any.$ast, modes.returnTry())\n        catch {\n          case e: Exception => Failure(e)\n        }\n      }\n    }\n\n  def optionExtractor[Data <: DataType[Data, _ <: DataAst], T](\n      implicit ext: Extractor[T, Data]): Extractor[Option[T], Data] { type Throws = Nothing } = {\n\n    new Extractor[Option[T], Data] {\n      type Throws = Nothing\n      def extract(any: Data, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Option[T], Throws] =\n        mode.wrap {\n          try ext.extract(any.$wrap(any.$normalize), any.$ast, modes.returnOption())\n          catch {\n            case e: Exception => None\n          }\n        }\n    }\n  }\n\n  def noneExtractor[Data <: DataType[_, DataAst]]\n    : Extractor[None.type, Data] { type Throws = DataGetException with NotEmptyException } =\n    new Extractor[None.type, Data] {\n      type Throws = DataGetException with NotEmptyException\n      def extract(value: Data, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[None.type, Throws] =\n        mode.wrap {\n          val v = value.$wrap(value.$normalize)\n          if (ast.isObject(v) && ast.getKeys(v).size == 0) None\n          else mode.exception[None.type, NotEmptyException](NotEmptyException())\n        }\n    }\n\n  def genSeqExtractor[T, Coll[_], Data <: DataType[Data, _ <: DataAst]](\n      implicit cbf: scala.collection.generic.CanBuildFrom[Nothing, T, Coll[T]],\n      ext: Extractor[T, Data]): Extractor[Coll[T], Data] { type Throws = ext.Throws } = {\n\n    new Extractor[Coll[T], Data] {\n      type Throws = ext.Throws\n      def extract(value: Data, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Coll[T], Throws] =\n        mode.wrap {\n          mode.catching[DataGetException, Coll[T]] {\n            val v = value.$wrap(value.$normalize)\n            v.$ast\n              .getArray(v.$root.value)\n              .to[List]\n              .zipWithIndex\n              .map {\n                case (e, i) =>\n                  mode.unwrap(ext.safeExtract(v.$wrap(e), v.$ast, Some(Left(i)), mode), s\"($i)\")\n              }\n              .to[Coll]\n          }\n        }\n    }\n  }\n\n  def mapExtractor[K, T, Data <: DataType[Data, _ <: DataAst]](\n      implicit ext: Extractor[T, Data],\n      ext2: StringParser[K]): Extractor[Map[K, T], Data] { type Throws = ext.Throws with ext2.Throws } =\n    new Extractor[Map[K, T], Data] {\n      type Throws = ext.Throws with ext2.Throws\n      def extract(value: Data, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Map[K, T], Throws] =\n        mode.wrap {\n          value.$ast.getObject(value.$normalize) map {\n            case (k, v) =>\n              mode.unwrap(ext2.parse(k, mode)) -> mode.unwrap(\n                  ext.safeExtract(value.$wrap(v), value.$ast, Some(Right(k)), mode))\n          }\n        }\n    }\n}\n\nobject Extractor {\n  implicit def anyExtractor[Data <: DataType[_, DataAst]]: Extractor[Any, Data] { type Throws = Nothing } =\n    new Extractor[Any, Data] {\n      type Throws = Nothing\n      def extract(value: Data, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Any, Throws] =\n        mode.wrap(value.$normalize)\n    }\n}\n\n@implicitNotFound(\"cannot extract type ${T} from ${D}.\")\nabstract class Extractor[T, -D] extends Functor[({ type L[x] = Extractor[x, D] })#L, T] { ext =>\n  type Throws <: Exception\n\n  def safeExtract(any: D,\n                  ast: DataAst,\n                  prefix: Option[Either[Int, String]],\n                  mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, Throws] = mode.wrap {\n    try mode.unwrap(extract(any, ast, mode))\n    catch {\n      case e @ TypeMismatchException(_, _) => mode.exception(e)\n      case e @ MissingValueException(_) => mode.exception(e)\n    }\n  }\n\n  def extract(any: D, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, Throws]\n\n  def rawMap[T2](fn: (T, Mode[_ <: MethodConstraint]) => T2): Extractor[T2, D] = new Extractor[T2, D] {\n    def extract(any: D, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[T2, Throws] =\n      mode.wrap(fn(mode.unwrap(ext.extract(any, ast, mode)), mode.generic))\n  }\n\n  def filter(pred: T => Boolean): Extractor[T, D] { type Throws = ext.Throws with FilterException } =\n    new Extractor[T, D] {\n      type Throws = ext.Throws with FilterException\n      def extract(any: D, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, Throws] = mode.wrap {\n        val result = mode.unwrap(ext.extract(any, ast, mode))\n        if (pred(result)) result else mode.exception[T, FilterException](FilterException())\n      }\n    }\n\n  def orElse[TS >: T, T2 <: TS, D2 <: D](\n      ext2: => Extractor[T2, D2]): Extractor[TS, D2] { type Throws = DataGetException } =\n    new Extractor[TS, D2] {\n      type Throws = DataGetException\n      def extract(any: D2, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[TS, Throws] = mode.wrap {\n        try mode.unwrap(ext.extract(any, ast, mode))\n        catch {\n          case e: Exception => mode.unwrap(ext2.extract(any, ast, mode))\n        }\n      }\n    }\n}\n"
  },
  {
    "path": "data/shared/src/main/scala/rapture/data/macros.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.data\n\nimport rapture.base._\nimport rapture.core._\n\nobject Macros {\n\n  // FIXME: Include enclosing position in the HashSet too\n  val emittedWarnings = new collection.mutable.HashSet[String]\n\n  def extractorMacro[T: c.WeakTypeTag, Data: c.WeakTypeTag, Th](\n      c: WhiteboxContext): c.Expr[Extractor[T, Data]] = {\n    import c.universe._\n    import compatibility._\n\n    val extractorType = typeOf[Extractor[_, _]].typeSymbol.asType.toTypeConstructor\n    val nameMapperType = typeOf[NameMapper[_, _]].typeSymbol.asType.toTypeConstructor\n\n    val implicitSearchFailures = collection.mutable.ListMap[String, List[String]]().withDefault(_ => Nil)\n\n    val extractionType = weakTypeOf[T].typeSymbol.asClass\n\n    if (weakTypeOf[T] <:< typeOf[AnyVal]) {\n      val param = paramLists(c)(declarations(c)(weakTypeOf[T]).collect {\n        case t: MethodSymbol => t.asMethod\n      }.find(_.isPrimaryConstructor).get).head.head\n\n      val paramType = param.typeSignature\n\n      val inferredExtractor =\n        c.inferImplicitValue(appliedType(extractorType, List(paramType, weakTypeOf[Data])), false, false)\n\n      c.Expr[Extractor[T, Data]](q\"$inferredExtractor.map { new ${weakTypeOf[T]}(_) }\")\n\n    }/* else if (extractionType.isSealed) {\n      \n      val subclasses = extractionType.knownDirectSubclasses.to[List]\n      def tsort(todo: Map[Set[String], Symbol], done: List[Symbol] = Nil): List[Symbol] = if(todo.isEmpty) done else {\n        val move = todo.filter { case (key, v) => (todo - key).forall(!_._1.subsetOf(key)) }\n        tsort(todo -- move.map(_._1), move.map(_._2).to[List] ::: done)\n      }\n\n      val paramSets = subclasses.map { subclass =>\n        (declarations(c)(subclass.asType.toType).collect {\n          case m: MethodSymbol if m.isCaseAccessor => m.asMethod\n        }.map(_.name.decodedName.toString).to[Set], subclass)\n      }\n\n      val sortedExtractors = tsort(paramSets.toMap).map { subclass =>\n        val searchType = appliedType(extractorType, List(subclass.asType.toType, weakTypeOf[Data]))\n        c.inferImplicitValue(searchType, false, false)\n      }\n      \n      val NothingType = weakTypeOf[Nothing]\n          \n      val throwsType = sortedExtractors.last.tpe.member(typeName(c, \"Throws\")).typeSignature\n      \n      val combinedExtractors = sortedExtractors.reduceLeft { (left, right) => q\"$left.orElse($right)\" }\n      \n      c.Expr[Extractor[T, Data]](q\"\"\"\n        (new _root_.rapture.data.Extractor[${weakTypeOf[T]}, ${weakTypeOf[Data]}] {\n          def extract(data: ${weakTypeOf[Data]}, ast: _root_.rapture.data.DataAst, mode: _root_.rapture.core.Mode[_  <: _root_.rapture.core.MethodConstraint]): mode.Wrap[${weakTypeOf[\n          T]}, Throws] = mode.wrap { $combinedExtractors }\n        }).asInstanceOf[_root_.rapture.data.Extractor[${weakTypeOf[T]}, ${weakTypeOf[Data]}] {\n          type Throws = ${throwsType}\n        }]\n      \"\"\")\n\n    }*/ else {\n\n      require(weakTypeOf[T].typeSymbol.asClass.isCaseClass)\n\n      val typeDeclaration = companion(c)(weakTypeOf[T].typeSymbol).typeSignature\n      val valueParameters = paramLists(c)(declaration(c)(typeDeclaration, termName(c, \"apply\")).asMethod)\n      val defaults = valueParameters.flatten.map(_.asTerm.isParamWithDefault).zipWithIndex.filter(_._1).map(_._2 + 1).to[Set]\n      \n      // FIXME integrate these into a fold\n      var throwsTypes: Set[Type] = Set(typeOf[DataGetException])\n\n      val params = declarations(c)(weakTypeOf[T]).collect {\n        case m: MethodSymbol if m.isCaseAccessor => m.asMethod\n      }.zipWithIndex map {\n        case (p, idx) =>\n          val nameMappingImplicit = c.inferImplicitValue(appliedType(nameMapperType, List(weakTypeOf[T], weakTypeOf[Data])), false, false)\n          val deref = q\"\"\"data.selectDynamic($nameMappingImplicit.encode(${p.name.decodedName.toString}))\"\"\"\n\n          val NothingType = weakTypeOf[Nothing]\n\n          val inferredImplicit =\n            try c.inferImplicitValue(appliedType(extractorType, List(p.returnType, weakTypeOf[Data])), false, false)\n            catch {\n              case e: Exception =>\n                implicitSearchFailures(p.returnType.toString) ::= p.name.decodedName.toString\n                null\n            }\n\n          val t = try {\n            inferredImplicit.tpe.member(typeName(c, \"Throws\")).typeSignature match {\n              case NothingType => List()\n              case refinedType: RefinedType => refinedType.parents\n              case typ: Type => List(typ)\n              case _ => ???\n            }\n          } catch {\n            case e: Exception => List()\n          }\n\n          if(!defaults.contains(idx + 1)) throwsTypes ++= t\n\n          // Borrowed from Shapeless\n          def companionRef(tpe: Type): Tree = {\n            val global = c.universe.asInstanceOf[scala.tools.nsc.Global]\n            val gTpe = tpe.asInstanceOf[global.Type]\n            val pre = gTpe.prefix\n            val sym = gTpe.typeSymbol\n            val cSym = sym.companionSymbol\n            if (cSym != NoSymbol) global.gen.mkAttributedRef(pre, cSym).asInstanceOf[Tree]\n            else Ident(tpe.typeSymbol.name.toTermName)\n          }\n\n\n          if (defaults.contains(idx + 1)) q\"\"\"\n          mode.unwrap(try $deref.as($inferredImplicit, mode.generic) catch { case e: Exception => mode.wrap(${companionRef(weakTypeOf[T])}.${termName(\n              c, \"apply$default$\" + (idx + 1))}.asInstanceOf[${p.returnType}]) }, ${\".\" + p.name.decodedName})\n          \"\"\" else q\"\"\"\n          mode.unwrap($deref.as($inferredImplicit, mode.generic), ${\".\" + p.name.decodedName})\n        \"\"\"\n      }\n\n      if (implicitSearchFailures.nonEmpty) {\n        val paramStrings = implicitSearchFailures map {\n          case (t, p1 :: Nil) =>\n            s\"parameter `$p1' of type $t\"\n          case (t, p1 :: ps) =>\n            s\"parameters ${ps.map(v => s\"`$v'\").mkString(\", \")} and `$p1' of type $t\"\n          case (t, Nil) =>\n            ??? // Doesn't happen\n        }\n        val errorString = paramStrings.to[List].reverse match {\n          case t1 :: Nil => t1\n          case t1 :: ts => s\"${ts.mkString(\", \")} and $t1\"\n          case Nil => ??? // Doesn't happen\n        }\n        val plural =\n          if (implicitSearchFailures.flatMap(_._2).size > 1)\n            s\"${weakTypeOf[Data].typeSymbol.name} extractors\"\n          else\n            s\"a ${weakTypeOf[Data].typeSymbol.name} extractor\"\n\n        val err = s\"Could not generate a ${weakTypeOf[Data].typeSymbol.name} extractor for case \" +\n            s\"class ${weakTypeOf[T].typeSymbol.name} because $plural for $errorString could not \" +\n            s\"be found\"\n\n        if (!emittedWarnings.contains(err)) {\n          emittedWarnings += err\n          c.warning(NoPosition, err)\n        }\n      }\n\n      require(implicitSearchFailures.isEmpty)\n\n      val construction = c.Expr[T](q\"\"\"new ${weakTypeOf[T]}(..$params)\"\"\")\n\n      c.Expr[Extractor[T, Data]](q\"\"\"\n        (new _root_.rapture.data.Extractor[${weakTypeOf[T]}, ${weakTypeOf[Data]}] {\n          def extract(data: ${weakTypeOf[Data]}, ast: _root_.rapture.data.DataAst, mode: _root_.rapture.core.Mode[_  <: _root_.rapture.core.MethodConstraint]): mode.Wrap[${weakTypeOf[\n          T]}, Throws] = mode.wrap { ${construction} }\n        }).asInstanceOf[_root_.rapture.data.Extractor[${weakTypeOf[T]}, ${weakTypeOf[Data]}] {\n          type Throws = ${normalize(c)(typeIntersection(c)(throwsTypes.to[List]))}\n        }]\n      \"\"\")\n    }\n  }\n\n  def serializerMacro[T: c.WeakTypeTag, Data: c.WeakTypeTag](c: WhiteboxContext)(\n      ast: c.Expr[DataAst]): c.Expr[Serializer[T, Data]] = {\n    import c.universe._\n    import compatibility._\n\n    val tpe = weakTypeOf[T].typeSymbol.asClass\n    val nameMapperType = typeOf[NameMapper[_, _]].typeSymbol.asType.toTypeConstructor\n    val serializer = typeOf[Serializer[_, _]].typeSymbol.asType.toTypeConstructor\n\n    if (weakTypeOf[T] <:< typeOf[AnyVal]) {\n\n      val param = paramLists(c)(declarations(c)(weakTypeOf[T]).collect {\n        case t: MethodSymbol => t.asMethod\n      }.find(_.isPrimaryConstructor).get).head.head\n\n      val paramName = param.name.decodedName.toString\n      val paramType = param.typeSignature\n      val inferredSerializer =\n        c.inferImplicitValue(appliedType(serializer, List(paramType, weakTypeOf[Data])), false, false)\n\n      val newName = termName(c, freshName(c)(\"param$\"))\n\n      c.Expr[Serializer[T, Data]](q\"$inferredSerializer.contramap[${weakTypeOf[T]}](_.${termName(c, paramName)})\")\n    } else {\n      if (tpe.isCaseClass) {\n        val params = declarations(c)(weakTypeOf[T]).collect {\n          case m: MethodSymbol if m.isCaseAccessor => m.asMethod\n        }.map { p =>\n          val imp = c.inferImplicitValue(appliedType(serializer, List(p.returnType, weakTypeOf[Data])), false, false)\n          val appliedSerializerType = appliedType(nameMapperType, List(weakTypeOf[T], weakTypeOf[Data]))\n          val nameMapperImplicit = c.inferImplicitValue(appliedSerializerType, false, false)\n          q\"\"\"($nameMapperImplicit.encode(${p.name.decodedName.toString}),\n              $imp.serialize(${termName(c, \"t\")}.${p}))\"\"\"\n        }\n\n        c.Expr[Serializer[T, Data]](q\"\"\"new _root_.rapture.data.Serializer[${weakTypeOf[T]}, ${weakTypeOf[Data]}] {\n          def serialize(t: ${weakTypeOf[T]}): _root_.scala.Any =\n            $ast.fromObject(_root_.scala.collection.immutable.ListMap(..$params).filterNot { v => $ast.isNull(v._2) })\n        }\"\"\")\n      } else if (tpe.isSealed) {\n        val cases = tpe.knownDirectSubclasses.to[List]\n        val caseClauses = cases.map { sc =>\n          val fullySpecifiedSerializer = appliedType(serializer, List(sc.asType.toType, weakTypeOf[Data]))\n          val caseSerializer = c.inferImplicitValue(fullySpecifiedSerializer, false, false)\n          val pattern = pq\"v: ${sc.asClass}\"\n          cq\"${pattern} => $caseSerializer.serialize(v)\"\n        }\n        \n        c.Expr[Serializer[T, Data]](q\"\"\"new _root_.rapture.data.Serializer[${weakTypeOf[T]}, ${weakTypeOf[Data]}] {\n          def serialize(t: ${weakTypeOf[T]}): _root_.scala.Any = t match { case ..$caseClauses }\n        }\"\"\")\n      } else throw new Exception()\n\n    }\n  }\n}\n"
  },
  {
    "path": "data/shared/src/main/scala/rapture/data/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.data\n\nimport rapture.core._\nimport scala.annotation._\n\n@implicitNotFound(\n    \"Cannot serialize type $\"+\"{T} to $\"+\"{D}. Please provide an implicit Serializer \" +\n      \"of type $\"+\"{T}.\")\ntrait Serializer[T, -D] { ser =>\n  def serialize(t: T): Any\n\n  def contramap[T2](fn: T2 => T) = new Serializer[T2, D] {\n    def serialize(t: T2): Any = ser.serialize(fn(t))\n  }\n\n}\n"
  },
  {
    "path": "doc/core-scalaz.md",
    "content": "[![Build Status](https://travis-ci.org/propensive/rapture-core-scalaz.png?branch=master)](https://travis-ci.org/propensive/rapture-core-scalaz)\n# Rapture Core/Scalaz\n\nThe Rapture Core/Scalaz project provides integration between Rapture Core and Scalaz 7. So far\nthis consists only of two additional return-type strategies:\n\n - A validation return-type strategy for returning Scalaz `Validation`s\n - A task return-type strategy, for returning Scalaz `Task`s\n\n### Availability\n\n#### Building from source\n\nTo build Rapture Core Scalaz from source, follow these steps:\n\n```\ngit clone git@github.com:propensive/rapture-core-scalaz.git\ncd rapture-core-scalaz\nsbt package\n```\n\nIf the compilation is successful, the compiled JAR file should be found in target/scala-2.10\n\n### Return-Type Strategies\n\nBy importing `scalazStrategy.returnValidation`, every fallible method will return a result of\ntype `Validation[E, T]`.\n\n```scala\n> import scalazStrategy.returnValidation\n> Json.parse(\"{}\")\nres: Validation[ParseException, Json] = {}\n```\n\nIf using the standard `strategy.explicit` you can get a `Validation` by calling `.valid` on the\nunexpanded result.\n\n```scala\n> import strategy.explicit\n> Json.parse(\"{}\").valid\nres: Validation[ParseException, Json] = {}\n```\n\nAlternatively, by importing `scalazStrategy.returnTasks`, and providing a valid implicit\n`ExecutorService`, every fallible method in Rapture will return a Scalaz `Task`.\n\n```scala\n> import scalazStrategy.returnTasks\n> implicit val exec = scalaz.concurrent.Strategy.DefaultExecutorService\n> Json.parse(\"{}\")\nres: Task[Json] = Task@7961b5f3\n```\n\nYou can call `.task` on an unexpanded result when using `strategy.explicit` to get the same\neffect.\n\nSee https://github.com/propensive/rapture-core#return-type-strategies for more information on\nRapture Core return-type strategies.\n"
  },
  {
    "path": "doc/core.md",
    "content": "[![Build Status](https://travis-ci.org/propensive/rapture-core.png?branch=master)](https://travis-ci.org/propensive/rapture-core)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/propensive/rapture?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\n# Rapture Core\n\nThe Rapture Core project provides a common foundation upon which other Rapture projects are\nbased, however it provides utilities which may be useful in any project. Namely,\n\n - Modes (previously called return-type strategies)\n - A lightweight abstraction on time libraries, and implementations for Java time\n - A tiny (but growing) collection of conveniences for working within the REPL\n - An alias for `implicitly`\n - A really simple implementation of actors, based on `scala.concurrent`\n - Reusable string serializers and deserializers, with implicit-based configurable number formatting\n - Miscellaneous other small tools and utilities\n\n### Availability\n\nRapture Core 1.1.0 is available under the Apache 2.0 License from Maven Central with group ID `com.propensive` and artifact ID `rapture-core_2.10`.\n\n#### SBT\n\nYou can include Rapture Core as a dependency in your own project by adding the following library dependency to your build file:\n\n```scala\nlibraryDependencies ++= Seq(\"com.propensive\" %% \"rapture-core\" % \"1.1.0\")\n```\n\n#### Maven\n\nIf you use Maven, include the following dependency:\n\n```xml\n<dependency>\n  <groupId>com.propensive</groupId>\n  <artifactId>rapture-core_2.11</artifactId>\n  <version>1.1.0<version>\n</dependency>\n```\n\n#### Download\n\nYou can download Rapture Core directly from the [Rapture website](http://rapture.io/)\nRapture Core depends on Scala 2.11, but has no other dependencies.\n\n#### Building from source\n\nTo build Rapture Core from source, follow these steps:\n\n```\ngit clone -b scala-2.11 git@github.com:propensive/rapture-core.git\ncd rapture-core\nsbt package\n```\n\nIf the compilation is successful, the compiled JAR file should be found in target/scala-2.11.0-RC4\n\n### Modes\n\nRapture's modes allow library methods to be written in such a way that they may\nbe wrapped in another function (and have a different return type) at the call site. This\npattern allows *users* of the library to choose the return type and additional pre- and\npost-execution processing to be performed, depending on their needs.  For example, using Rapture\nJSON, given one of the imported modes,\n\n```scala\nimport modes.returnEither._\nJson.parse(\"[1, 2, 3]\")\n```\n\nwill have return type `Either[ParseException, Json]`. Hopefully the parsing succeeded, and the\nreturn type will be `Right[Json]` rather than `Left[ParseException]`.\n\nAlternatively, given a different imported mode, we will get a different return type.\n\n```scala\nimport modes.returnFuture._\nJson.parse(\"[1, 2, 3]\")\n```\n\nThis will immediately return a `Future[Json]`, from which the result can be obtained once\nprocessing completes.\n\nA selection of modes are provided:\n\n- `modes.throwExceptions._` - does no additional processing, and simply returns the value,\n  leaving any thrown exceptions unhandled. This is the default.\n- `modes.returnEither._` - captures successful results in the `Right` branch of an\n  `Either`, or exceptions in the `Left` branch.\n- `modes.returnOption._` - returns an `Option` of the result, where the exceptional case\n  collapses to `None`.\n- `modes.returnTry` - wraps the result in a `scala.util.Try`.\n- `modes.returnFuture._` - wraps the result in a `scala.concurrent.Future`; requires an\n  implicit ExecutionContext.\n- `modes.timeExecution._` - times the duration of carrying out the execution, returning a tuple\n  of the return value and the time taken; requires an implicit `rapture.core.TimeSystem`.\n- `modes.keepCalmAndCarryOn._` - catches exceptions and silently returns them as\n  null; this is strongly discouraged!\n- `modes.explicit._` - returns an instance of `Explicit` which requires the mode\n  to be explicitly specified at the call site every time.\n\nMultiple modes can be composed, should this be required, for example,\n\n```scala\nimplicit val handler = modes.returnTry compose modes.timeExecution\n```\n\n#### The `modally` method\n\nThe `modally` method takes a lambda and evaluates it in the current mode, e.g.\n\n```scala\nimport modes.returnTry._\nmodally { Class.forName(className) }\n// Returns a Try[Class[_]]\n```\n\nThis may provide a convenient (and adaptive) alternative to `try`/`catch`.\n\n#### Writing methods to use modes\n\nTo transform a method like this,\n\n```scala\ndef doSomething[T](arg: String, arg2: T): Double = {\n  // method body\n}\n```\n\ninto one which offers end-users a choice of mode, include an implicit\nMode parameter, and wrap your method body and return type, like this,\n\n```scala\ndef doSomething[T](arg: String, arg2: T)(implicit mode: Mode[_]):\n    mode.Wrap[Double, Exception] = mode wrap {\n  // method body\n}\n```\n\nIf you know that your method body will only throw exceptions of a certain type, you can\nspecify this in the method return type in place of `Exception`, which may make processing\nexceptions easier when using a mode which captures them (e.g. `modes.returnEither`).\n\n#### Conveniences for existing methods\n\nYou may already have existing implementations of methods you would like to modify to utilize\nmodes, but which already have a return type which captures (or discards) the exception\nrather than throwing it. The `wrapEither`, `wrapTry` and `wrapOption` methods are provided\nas alternatives to `wrap` to transform methods which already return `Either`, `Try` or\n`Option` respectively. Note, however, that because `wrapOption` loses its exception in the\nreturn type, that there is no way to recover it. This means that when using it with modes\nsuch as `returnEither`, that the exceptional cases will always return as a\n`java.util.NoSuchElementException`.\n\n### REPL utilities\n\nWhen working within the REPL, it is useful to receive the immediate feedback that a fallible\noperation has failed (as the `throwExceptions` mode provides), but seeing large and unwieldy\nstack traces can be annoying.  By including the following import,\n\n```scala\nimport rapture.core.repl._\n```\n\nstack traces from fallible Rapture methods will be suppressed, and a short error message\nwill be displayed instead. If you would like to view the stack trace, it can be rethrown by\ncalling `repl.lastException`.\n\n### Time System Abstraction\n\nMany APIs take parameters or return values which represent time. Unfortunately, there is no\nstandard for representing entities like instants and durations.  Rapture Core provides a general\ntype class for defining these types and methods for creating them, and provides two simple\nimplementations:\n\n- `timeSystems.numeric` - uses `Long`s to represent both instants and durations.\n- `timeSystems.javaUtil` - uses `java.util.Date`s to represent instants, and `Long`s to\n  represent durations.\n\n### Alias for `implicitly`\n\nContext-bounds provide a nice, lightweight syntax for working with type classes in Scala,\nhowever while explicitly specifying an implicit parameter necessarily provides a named handle\nfor that implicit, context-bounds force us to make repeated use of the `implicitly` method in\norder to use the type class. This can make using context-bounds more cumbersome than they\ndeserve.\n\nRapture Core introduces an alias for `implicitly` named `?`. Generally speaking, any occurrence\nof `implicitly` can be replaced by a `?`. This is particularly useful when calling methods which\ntake multiple implicit parameters and you would like to specify one of these explicitly. For\nexample, a method like this:\n\n```scala\ndef performAction[T](v: Int)(implicit alpha: Alpha[T], beta: Beta, gamma: Gamma) = { ... }\n```\n\nmay now be called quite concisely using\n\n```scala\nperformAction(42)(?, ?, myGamma)\n```\n\nif we only wanted to specify the parameter `myGamma` explicitly.\n"
  },
  {
    "path": "doc/html.md",
    "content": "# Rapture HTML\n\nRapture HTML provides simple but typesafe support for working with HTML5\ndocuments in Scala, enforcing the constraints of the document object model.\nIt is a small library which works independently of any other web framework.\n\nRapture HTML is part of the [Rapture](http://rapture.io/) project.\n\n## Features\n\n - Clean, elegant and intuitive DSL for creating HTML tree structures\n - Nesting constraints on HTML nodes are enforced by the type system\n - HTML attributes may only be applied to appropriate elements\n - Customized explanatory error messages given for badly-nested elements and\n   mismatched attributes\n - Attributes generally use rich Scala types, not `String`s\n - HTML Document object model specification is concise, extensible and\n   maintainable\n - Lightweight, typesafe accessors for navigating elements and attributes\n\n## Availability\n\nRapture HTML 0.1.0 is available under the *Apache 2.0 License* from Maven Central\nwith group ID `com.propensive` and artifact ID `rapture-html_2.10`.\n\n### SBT\n\nYou can include Rapture HTML as a dependency in your own project by adding the\nfollowing library dependency to your build file:\n\n```scala\nlibraryDependencies ++= Seq(\"com.propensive\" %% \"rapture-html\" % \"0.1.0\")\n```\n\n### Maven\n\nIf you use Maven, include the following dependency:\n\n```xml\n<dependency>\n  <groupId>com.propensive</groupId>\n  <artifactId>rapture-html_2.10</artifactId>\n  <version>0.1.0</version>\n</dependency>\n```\n\n### Building from source with SBT\n\nTo build Rapture HTML from source, follow these steps:\n\n```\ngit clone git@github.com:propensive/rapture-html.git\ncd rapture-html\nsbt package\n```\n\nIf the compilation is successful, the compiled JAR file should be found in the\ndirectory for the appropriate Scala version in the `target` directory.\n\n## Status\n\nRapture HTML is *experimental*. This means that the API is undergoing change,\nand new features may be added or removed without changes being documented.\n\n## Contributing\n\nRapture HTML -- like all the Rapture projects -- openly welcomes contributions!\nWe would love to receive pull requests of bugfixes and enhancements from other\ndevelopers. To avoid potential wasted effort, bugs should first be reported on\nthe Github issue tracker, and it's normally a good idea to talk about\nenhancements on the Rapture mailing list before embarking on any development.\nAlternatively, just send Jon Pretty (@propensive) a tweet to start a\nconversation.\n\n# Using Rapture HTML\n\nFirst of all, import the following:\n\n```\nimport rapture.html._\nimport htmlSyntax._\n```\n\nThe `htmlSyntax` package comprises a large namespace containing all HTML tag\nand attribute names, so it is recommended to import this only into scopes where\nit is to be immediately used.\n\n## HTML Elements\n\nA simple HTML element, with no attributes or child elements is as simple as\nwriting the tag name, with its first letter capitalized, for example,\n\n```\n// <form/>\nval html = Form\n```\n\nTo add attributes to an empty tag, list them like named parameters to the element, like this,\n\n```\n// <form id=\"signup\" method=\"POST\"/>\nval html = Form(id = 'signup, method = Post)\n```\n\nNote that the types of the attribute values are not, in general, `String`s.\nEach attribute is typed according to the values it allows to be assigned.\nA later version of Rapture HTML will offer multiple alternative types\n(originating from third-party projects) for HTML attribute values.\n\nMostly, attribute names in Rapture HTML are identical to their native HTML5\ncounterparts, but in several cases it has been necessary to tweak the names.\n\n - Any attribute containing a `-` is converted to camel case, for example\n   `http-equiv` becomes `httpEquiv`\n - The `class` attribute becomes `classes`\n - The `type` attrubute becomes `typeName`\n - The `for` attribute becomes `forName`\n - Custom `data-<name>` attributes become `data.<name>`\n\nBetter suggestions for more consistent handling of these attributes would be\nvery welcome.\n\nAn HTML element may also have child elements, by adding them as parameters in a\nsecond parameter block, like so,\n\n```\n// <form id=\"signup\" method=\"POST\"><label/><input/></form>\nval html = Form(id = 'signup, method = Post)(Label, Input)\n```\n\nRemember, `Label` and `Input` are just empty elements.\n\nThe first parameter block of any HTML element, however, is completely optional\nand can be omitted if no attributes are required. For example,\n\n```\n// <form><label/><input/></form>\nval html = Form(Label, Input)\n```\n\n## Cautionary notice\n\nScala does not offer any native support for an optional initial parameter\nblock, and the complex machinery necessary to offer this, whilst maintaining\nidiomatic-looking syntax may be best described as \"baroque\". Until this\napproach has been extensively tested, users should be aware that it may be an\nimperfect abstraction.\n\nThis syntax would not have been possible without help from *all* of the\nfollowing Scala features, mostly as a workaround for overloading interacting\nbadly with type inference:\n\n - Implicit parameters and conversions\n - Getters and setters\n - Dependent method types\n - Higher-kinded types\n - Macros\n - Dynamic type\n - Singleton types\n - Inheritance and variance\n\nBug reports around this approach would be very welcome.\n\n## Example HTML document\n\nA slightly more complete HTML document may look like this:\n\n```\nval html = Html(\n  Head(\n    Title(\"Hello world!\")\n  ),\n  Body(\n    H1(\"Hello World!\"),\n    Ul(\n      Li(id = 'first)(\"Apple\"),\n      Li(\"Orange\"),\n      Li(\"Pear\")\n    )\n  )\n)\n```\n\nThis works because each HTML element has been correctly placed within another\nelement that allows it as a child.\n\n## Nesting rules\n\nAlmost all of HTML5's rules on nesting elements, as specified in the working\ndraft, are enforced by Rapture HTML.\n\nWhilst it is possible to write `Table(Tbody(Tr(Td)))`, a compile error would be\nproduced by `Html(Head(Table))`, because in HTML, a `<table>` element cannot\nappear inside a `<head>` element.\n\nThe following custom error is produced at compile time:\n\n```\nerror: Attempted to nest a Flow node in a position where only Metadata nodes are permitted\nHtml(Head(Table))\n          ^\n```\n\nThe terms `Flow` and `Metadata` correspond to the terms used to describe\nelement types in the HTML5 Working Draft.\n\n## Attribute rules\n\nLikewise, attributes may only be applied to those elements which support them,\nfor example the `max` attribute is not valid on `Textarea` elements, so the\nfollowing line will result in a compile error.\n\n```\nTextarea(max = 100.0)\n```\n\nUnfortunately, possibly due to a type inference bug in Scalac, this error\ncurrently presents itself as less friendly type error.\n\n## Navigating an HTML document\n\nGiven an `Html` node, `html`, containing a document, nodes within that document\ncan be easily accessed using the `\\` operator and named tags, for example,\n\n```\nval rows = html \\ Body \\ Div \\ Div \\ Table \\ Tbody \\ Tr\nval firstRow = rows(0)\n```\n\nand the attributes of an existing HTML node may be accessed by dereferencing it\nwith the attribute name, for example, `firstRow.id` or `firstRow.style`. If the\nattribute is present, it will be returned as the original type it was set as,\ni.e.  not necessarily a `String`.\n\nThe `\\\\` operator will select all descendants (not just immediate children)\nmatching the specified tag.\n\n```\nval rows = html \\\\ Tr\nval firstRow = rows(0)\n```\n\nAll of these access methods take advantage of Rapture's\n[modes](https://github.com/propensive/rapture-core), to give a choice about how\nmissing elements or attributes should be handled.\n\n## Outputting HTML\n\nThe `toString` method on HTML elements will generate pretty-printed strings\nwhich neatly indent the HTML source into a readable form, and by default the\n`format` method will do the same. As an alternative, HTML may be output in\n\"compact\" form, without any additional whitespace, by importing an alternative\nformatter from the `rapture.dom` package, for example,\n\n```\nimport rapture.dom._\nimport domFormatters.compact._\n\nprintln(myHtml.format)\n```\n\nFormatters are pluggable, so it is easy to write a custom formatter which\noutputs the HTML in a different form, not necessarily to a `String`.\n\n## The HTML Document Object Model\n\nThe rules governing how HTML elements may be nested are defined in the [syntax\nfile](https://github.com/propensive/rapture-html/blob/master/src/syntax.scala)\nbased on some very simple [phantom\ntypes](https://github.com/propensive/rapture-html/blob/master/src/phantom.scala)\nwhich determine the name, basic types, child types and attribute types of each\ntag.\n\nThe current implementation is based on a version from an HTML5 working draft\nfrom 2013. It is likely that the current implementation is incomplete or\nincorrect in places, so corrections and additions to these files are very\nwelcome.\n\nAttribute definitions follow after the Tag definitions in the syntax file, but\nare currently more verbose. Hopefully it will be possible to improve the\ntersity of these definitions in a later release.\n\n## Tests\n\nThere is currently no test suite for Rapture HTML, though implementing a\nselection of tests is a medium-term priority.\n\n## Other DOMs\n\nThe Rapture DOM project, a dependency of Rapture HTML, is designed to support\nother HTML-like languages, just by defining tags, attributes and their\nassociated phantom types. Rapture HTML should serve as a reasonable starting\npoint for anyone looking to implement an alternative DOM language.\n\nAdditionally, for DOM-like languages which do not serialize to an SGML-like\nsyntax, but do follow the same basic structure, custom formatters may be\nwritten to produce the appropriate output.\n\n"
  },
  {
    "path": "doc/i18n.md",
    "content": "[![Build Status](https://travis-ci.org/propensive/rapture-i18n.png?branch=master)](https://travis-ci.org/propensive/rapture-i18n)\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/propensive/rapture?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\n# Rapture Internationalization (I18N)\n\nRapture I18N is a very simple library for working with typesafe localized\nstrings in Scala. It is part of the [Rapture](http://rapture.io/) project.\n\n## Features\n\n - Simple format for writing language-specific string literals\n - Internationalized Strings' types reflect the languages they support\n - Strings are typechecked to ensure that strings for all languages are provided\n - Support for language-dependent string substitution\n - Internationalized strings may be treated as normal strings by specifying a\n   default language\n - Convenient trait provided for writing \n\n## Tests\n\nTests for Rapture I18N are in their own project, [Rapture I18N\nTests](https://github.com/propensive/rapture-i18n-test)\n\n## Availability\n\nRapture I18N 2.0.0-M5 is available under the *Apache 2.0 License* from Maven Central\nwith group ID `com.propensive` and artifact ID `rapture-i18n_2.10`.\n\n### SBT\n\nYou can include Rapture I18N as a dependency in your own project by adding the\nfollowing library dependency to your build file:\n\n```scala\nlibraryDependencies ++= Seq(\"com.propensive\" %% \"rapture-i18n\" % \"latest.integration\")\n```\n\n### Maven\n\nIf you use Maven, include the following dependency:\n\n```xml\n<dependency>\n  <groupId>com.propensive</groupId>\n  <artifactId>rapture-i18n_2.11</artifactId>\n  <version>2.0.0-M5</version>\n</dependency>\n```\n\n### Building from source with SBT\n\nTo build Rapture I18N from source, follow these steps:\n\n```\ngit clone git@github.com:propensive/rapture-i18n.git\ncd rapture-i18n\nsbt package\n```\n\nIf the compilation is successful, the compiled JAR file should be found in the\ndirectory for the appropriate Scala version in the `target` directory.\n\n## Status\n\nRapture I18N is *experimental*. This means that the API is undergoing change,\nand new features may be added or removed without changes being documented.\n\n## Contributing\n\nRapture I18N -- like all the Rapture projects -- openly welcomes contributions!\nWe would love to receive pull requests of bugfixes and enhancements from other\ndevelopers. To avoid potential wasted effort, bugs should first be reported on\nthe Github issue tracker, and it's normally a good idea to talk about\nenhancements on the Rapture mailing list before embarking on any development.\nAlternatively, just send Jon Pretty (@propensive) a tweet to start a\nconversation.\n\n# Using Rapture I18N\n\nFirst of all, import the following:\n\n```scala\nimport rapture.i18n._\n```\n\nYou can write an internationalized string by writing `en\"Hello\"` or\n`fr\"Bonjour\"`. These have types I18n[String, En] and I18n[String, Fr], representing\nEnglish and French strings, respectively.\n\nMore importantly, you can define a single value representing an\ninternationalized string using the alternation operator (`&`), like this:\n\n```scala\nval greeting = en\"Hello\" & fr\"Bonjour\" & de\"Guten Tag\"\n```\n\nThe value `greeting` here represents a string in three different languages, and\nhas the type `I18n[String, En with Fr with De]`. Note that the `with` combinator\nrepresents a type intersection, which is the chosen implementation for\ncombining multiple language types in a single type parameter.\n\nGiven a value such as `greeting`, we can access the string for a language of\nour choice, simply by applying it as a type parameter to the identifier, e.g.\n`greeting[En]` will produce `\"Hello\"`, whereas `greeting[De]` will produce\n`\"Guten Tag\"`.\n\n## Subtyping\n\nTypes for internationalized strings behave such that a value may not overspecify\nlanguage strings for a given type, for example\n\n```scala\nval msgs: I18n[String, En with Fr] = fr\"Bonjour\" & en\"Hello\" & de\"Guten Tag\"\n```\n\nwill result in compile errors.\n\n```scala\nError: Some language translations were not provided: language\n  lazy val msgs: I18n[String, En with Fr] = fr\"Bonjour\" & en\"Hello\" & de\"Guten Tag\"\n                                                                    ^\n```\n\n```\nError:type mismatch;\n found   : rapture.i18n.I18n[String,rapture.i18n.De]\n required: rapture.i18n.I18n[String,rapture.i18n.Language]\nNote: rapture.i18n.De <: rapture.i18n.Language, but class I18n is invariant in type Languages.\nYou may wish to define Languages as +Languages instead. (SLS 4.5)\nlazy val msgs: I18n[String, En with Fr] = fr\"Bonjour\" & en\"Hello\" & de\"Guten Tag\"\n                                                                    ^\n```\n\nand also may not underspecify language strings, so this is not valid:\n\n```scala\nval msgs: I18n[String, En with Fr] = en\"Hello\"\n```\n\nand will result in compile errors.\n\n```scala\nError: Some language translations were not provided: fr\nlazy val msgs2: I18n[String, En with Fr] = en\"Hello\"\n                                           ^\n```\n\n```\nError: type mismatch;\n found   : rapture.i18n.I18n[String,rapture.i18n.En]\n required: rapture.i18n.I18n[String,rapture.i18n.En with rapture.i18n.Fr]\nNote: rapture.i18n.En >: rapture.i18n.En with rapture.i18n.Fr, but class I18n is invariant in type Languages.\nYou may wish to define Languages as -Languages instead. (SLS 4.5)\nlazy val msgs2: I18n[String, En with Fr] = en\"Hello\"\n                                           ^\n```\n\nThis helpfully indicates the missing language.\n\n## Substitution\n\nInternationalized strings may be specified with interpolated substitutions,\nwhich can themselves be either ordinary `String`s or other internationalized\nstrings. In the latter case, the internationalized string must provide the\nlanguage of the internationalized string it is being substituted into, for\nexample this is valid:\n\n```scala\nval greeting = en\"Hello\" & fr\"Bonjour\"\nen\"In England we greet people with '$greeting'.\"\n```\n\nbut not this,\n\n```scala\nval greeting = en\"Hello\" & fr\"Bonjour\"\nde\"In Deutschland sagen wir '$greeting'\"\n```\n\nwhich is another compile error.\n\n## Default languages\n\nIt is often useful to pick a single language for use within some scope, and use\ninternationalized strings as if they are ordinary `String`s. This is achievable\nby importing a default language, e.g.\n\n```scala\nimport languages.es._\n```\n\nAn internationalized string may then be used in place of an ordinary `String`,\nlike so:\n\n```scala\nimport languages.de._\nval errorMsg = en\"Oh no!\" & de\"Ach nein!\"\nthrow new Exception(errorMsg)\n```\n\nwhich will throw an exception with the German error message.\n\nWithout the import of a default language, this would produce a type error at\ncompile time. Beware, though, of methods like `+` on `String` which simply call\n`toString` on the operand, and consequently do not enforce the typesafe\nconversion to the correct language string. These methods should be avoided.\n\n## Standard methods\n\nThe `toString` method on `I18nString`s is implemented such that it should\nquickly be obvious that the string is an internationalized, rather than an\nordinary, string. For a given internationalized string, `toString` will display\ntwo-letter codes for all the languages it provides, followed by the contents of\nthe string in English, if available, or in some other language, if not.\n\nFor example,\n\n```scala\nscala> fr\"Bonjour\" & en\"Hello\"\nres: I18n[String, Fr with En] = fr&en:\"Hello\"\n```\n\nAdditionally `hashCode` and `equals` are implemented such that `I18nString`s\ncan be usefully compared. Internationalized strings are treated as sets, so\nreorderings are not significant.\n\n## Using I18N in your own projects\n\nA multilingual application, or even a module within a multilingual application\nwill usually make a decision about what languages it should support throughout.\nThis decision can be represented as a type, such as `En with Fr with Es`, and\nfor convenience, we can give this type an alias.\n\nThen, as the project develops, its choice of supported languages may change, so\nthe type alias becomes a useful way to change the supported languages globally,\nand enforce typechecking to ensure that every internationalized string in scope\nprovides every language. For example, define\n\n```scala\npackage object app {\n  type AppLangs = En with Fr with Es\n}\n```\n\nor alternatively,\n\n```scala\npackage object app {\n  type IString = I18n[String, En with Fr with Es]\n}\n```\n\nand then it is never necessary to refer to the application languages (`En`,\n`Fr`, `Es`) explicitly, but every string parameterized on `AppLangs` will\nnevertheless be typechecked to ensure all languages are provided.\n\nIt would then be easy to add an additional language, just by changing the type\nalias, and recompiling (which would produce a type error every time the\nnewly-added language has not been provided.\n\nIt is often convenient to store all user messages in a single place, to avoid\nlittering source code with strings. Using internationalized strings, you may\nput all your application messages in a single object, like this:\n\n```scala\nobject Messages {\n  val cart = en\"Shopping cart\" & fr\"Panier\"\n  def items(n: Int) = if(n == 1) en\"$n item\" & fr\"$n article\" else en\"$n items\" & fr\"$n articles\"\n  // more words and phrases\n}\n```\n\nThroughout your application internationalized strings may be passed around as a\nsingle value which represents several strings in different languages, however\nat some point the application will need to present a single string to an\nend-user, in a language determined by some runtime value, such as the string\n`\"EN\"` or `\"FR\"`, \"English (US)\" or \"Deutsch\".\n\nThis runtime value may come from a user request, from a session or a\nconfiguration file; this is a design choice for the application, and Rapture\nI18N imposes no constraints on recommendations on how it should be provided,\nexcept that the application must, at some point, resolve the runtime value\nrepresenting the language to its compile-time type representation, and use this\nto extract a standard `java.lang.String` from an `I18nString`.\n\nAn example may look like this:\n\n```scala\ndef resolve(msg: I18n[String, AppLangs], lang: String): String = lang match {\n  case \"EN\" => msg[En]\n  case \"FR\" => msg[Fr]\n  case \"ES\" => msg[De]\n}\n```\n\nThis logic, which derives a `String` from the runtime values of an `I18nString`\nrepresenting a message and a `String` representing a language, is implemented\njust once for the entire application, and corresponds to the small surface area\nin which runtime errors may occur; all other logic relating to language strings\nhas been safely typechecked.\n\n\n\n"
  },
  {
    "path": "doc/json.md",
    "content": "# Rapture JSON\n\n## Features\n\n - Clean, intuitive, unintrusive, boilerplate-free Scala API\n - Trivial extraction and serialization to/from primitives, collections and case classes\n - Consistent and typesafe type-class-based interfaces\n - Works with a choice of JSON parsers and backends\n - Simple, efficient conversion between different backends\n - Support for both immutable and mutable JSON\n - Flexible choice of error handling strategies using\n   [modes](https://github.com/propensive/rapture-core)\n - Can be easily extended using composable user-defined extractors and\n   serializers\n\n# Using Rapture JSON\n\n## JSON Representation\n\nRapture JSON is designed to be agnostic about the JSON parser and choice of AST\nrepresentation used throughout the library. This means that a choice of JSON\nbackend must be made in order to use Rapture JSON. Whilst different backend\nlibraries provide different features, all features of Rapture JSON are\navailable with every backend (with the exception of Jackson, which does not yet\nsupport mutable JSON operations).\n\nThe choice of backend should therefore depend on other characteristics such as\nperformance, memory usage, required dependencies, integration with existing\nlibraries, licensing and policy choices.\n\nThe following backends are available:\n\n - Argonaut (`argonaut`)\n - Jackson (`jackson`) [1]\n - Jawn (`jawn`)\n - JFC (`jfc`)\n - JSON4S (`json4s`)\n - Lift (`lift`)\n - Play (`play`)\n - Scala standard library JSON (`scalaJson`) [2]\n - Spray (`spray`)\n\nNotes:\n [1] Jackson (`jackson`) is a read-only backend (does not support mutable JSON, i.e. `JsonBuffer` is not supported).\n [2] Scala standard library JSON (`scalaJson`) backend got removed in v2.0.0 because it is deprecated.\n\nIt is also possible to integrate with other JSON backends, though this is not\ncovered by this document. Anyone interested should look at the existing\nintegration type classes, and contact the Rapture mailing list or the Gitter\nchannel.\n\nIn the source code, you should import `rapture.json.jsonBackends.<backend>._`.\n\n## The Json type\n\nA JSON value, whether an array, object, boolean, number or string, is\nrepresented by an instance of type `Json`. As JSON is inherently\ndynamically-typed, the `Json` type is used to provide a safe and immutable\nwrapper around the JSON tree, whose type is not known at compile time.\n\nInstances of `Json` consist of three things:\n\n - a reference to the root of a dynamically-typed JSON tree\n - a path into a node within the JSON tree\n - a reference to the parser used to create, modify and read the JSON tree\n\nAlthough using `Json` objects should seem very intuitive, it is important to\nunderstand the purpose of this state.\n\n```json\n{\n  \"fruits\": [\n    {\n      \"name\": \"apple\",\n      \"color\": \"red\"\n    },\n    {\n      \"name\": \"banana\",\n      \"color\": \"yellow\"\n    }\n  ]\n}\n```\n\nIf we were to parse the above JSON source, we should get a tree consisting of\nan object containing an array under the key \"fruits\", with two elements, each\nof which is an object containing two fields, \"name\" and \"color\", both of which\nare strings. Given this tree, we can refer to an element within with a path of\nstrings for indexing JSON objects, and integers for indexing JSON arrays, for\nexample, `fruits / 0 / name`, which would refer to the string `\"apple\"`.\n\nWe could also look into the same tree with the path `fruits / 3 / mass`, though\nthis wouldn't exist on account of there being only two elements in the `fruits`\nlist, but we would not know this until we attempted it at runtime.\n\nA `Json` instance represents both the JSON tree, and a lazily-evaluated path\ninto that tree, which may or may not point to a value. If we assume the full\nJSON tree is a starting point (most likely originating from being parsed from\nsource), `Json` instances can be created which hold the same reference to the\noriginal tree, but point -- by means of a path -- to any subtree of the\noriginal, without the performance cost of navigating the tree, or the\nrequirement to safely handle missing-value or type-mismatch errors which arise\nbecause the path attempts to access a value which isn't available.\n\nAt some later point, if the JSON is to yield some useful data which we can do\ninteresting things with, we will need to perform the access, and assign a Scala\ntype to it, as it passes from the dynamic to the static world. It is at this\npoint that all access failures will arise, so by deferring them to a single\npoint, they can be handled just once.\n\nAdditionally, every `Json` instance stores a reference to the backend which was\nused to create it, and which will be used to access it. As Rapture JSON permits\nmultiple different parsers to be used alongside each other, it is important\nthat the AST within each `Json` instance is always handled using the right\nbackend.\n\n## Accessing JSON values\n\n`Json` instances implement Scala's `Dynamic` trait, providing a very natural\nway to refer to object fields within a `Json` value just by calling that field\nname as if it were a method on the `Json` instance. Additionally, integers may\nbe applied to index into arrays.\n\nFor example, using the example JSON above, we can create a new `Json` instance\npointing to the string `\"yellow\"` as follows:\n\n```scala\njson.fruits(1).color\n```\n\nRemember, this is just creating a pointer into the `\"yellow\"` value; it's not\nbeen accessed yet.  To extract a value from a `Json` value, the `as` method is\nused. `as` takes a single type parameter, and is the single point at which a\nJSON type-mismatch or missing-value exception can occur.\n\n```scala\njson.fruits(1).color.as[String]\n```\n\nRapture JSON uses Rapture Core's modes on the `as` method, thus allowing\nfailure cases to be handled using the preferred exception-handling strategy,\nfor example by throwing an exception or returning a `Try`. See the section on\nerror messages below.\n\nNote that calling `toString`, as happens automatically after every evaluation\nin the Scala REPL, *will* cause the AST to be accessed, but any errors will be\nsuppressed, and the `toString` method will return the string `\"undefined\"`.\n\nA variety of types may be extracted from a `Json` value, including the\nfollowing:\n\n - Primitive types, such as `String`, `Int`, `Double` and `Boolean`\n - Scala collections of other extractable types, e.g. `List[Int]` or `Set[Int]`\n - Case classes, extracted by the names of their parameters, provided the type\n   of every parameter is extractable\n - `Option`s, where `None` will be extracted if the element is missing or the\n   wrong type\n - `Json` types -- the no-op extractor\n - Any other type for which an implicit `Extractor` exists in scope\n\nThese types compose, so it is possible to extract values of complex types like\n`Option[Vector[MyCaseClass]]`.\n\n## Creating JSON values\n\nJSON values can be created in a number of different ways. If starting with a\nJSON source, which will often be a `String` (but may be another type -- the\nJawn backend can parse directly from ByteBuffers, for example), we can call\n`Json.parse(src)` to attempt to parse the source `src`.\n\n`Json` values can also be created directly in code, using the `json` string\ncontext, like so:\n\n```scala\njson\"\"\"{\n  \"fruit\": \"apple\",\n  \"variants\": [\"cox\", \"braeburn\"]\n}\"\"\"\n```\n\nMuch like an interpolated string, Scala expressions may be substituted into a\n`json` string context, provided the expressions evaluate to a type which is\nserializable to Json. Generally speaking, all types which can be extracted from\na `Json` value (primitives, collections, case classes, Json) can also be serialized,\nlike so:\n\n```scala\nval f = \"apple\"\njson\"\"\"{\n  \"fruit\": $f,\n  \"variants\": ${List(\"cox\", \"braeburn\")}\n}\"\"\"\n```\n\nAny serializable type can also be converted to `Json` by applying it to the\n`Json` object, for example this,\n\n```scala\ncase class Fruit(name: String, variants: Set[String])\nJson(Fruit(\"apple\", Set(\"cox\", \"braeburn\")))\n```\n\nwill produce the same JSON as the previous examples.\n\nAn instructive compile error will be displayed in the event of an attempt to\nserialize a type which cannot be serialized to `Json`.\n\n## Pattern matching on JSON\n\nAn alternative way of extracting values from `Json` types in to use pattern\nmatching. A `Json` value can be pattern matched against JSON literals defined\ninline in the case clause, like this:\n\n```scala\nval json: Json = Json.parse(src)\njson match {\n  case json\"\"\" { \"fruit\": $name }\"\"\" =>\n    name.as[String]\n  case json\"\"\" { \"vegetable\": $name }\"\"\" =>\n    name.as[String]\n}\n```\n\nThis will first attempt to match any JSON object which contains a key called\n`fruit`, and bind the value to the identifier `name`. If that match fails, it\nwill attempt to match any JSON object which contains a key called `vegetable`,\nand likewise bind its value to `name`. In each case, we return the name as a\n`String`. The call to `.as[String]` is necessary because, as before, the\ncompiler will no know nothing about the nature of the type at compile time, so\nit must be explicitly specified.\n\nLiteral match values may also be explicitly specified, for example:\n\n```scala\nval json: Json = Json.parse(src)\njson match {\n  case json\"\"\" { \"fruit\": \"apple\", \"variety\": $vs }\"\"\" =>\n    vs.as[Set[String]]\n  case json\"\"\" { \"fruit\": \"lemon\" }\"\"\" =>\n    Set()\n}\n```\n\nMultiple values may be extracted, and the pattern match expression may involve\narbitrarily-deep object and array nesting.\n\nThe examples above use the default configuration for structural pattern\nmatching, however three configuration explicits control the strictness of\nstructural pattern matching.\n\n - `patternMatching.exactObjects._`\n - `patternMatching.exactArrays._`\n - `patternMatching.exact._`\n\nIf it is required that pattern matching on JSON objects should match the entire\nobject, i.e. the existence of any keys in the object which are not specified in\nthe pattern should result in failure to match, then include the following\nimport somewhere within the scope of the pattern match:\n\n```scala\nimport patternMatching.exactObjects._\n```\n\nBy default, array elements specified in a pattern are matched positionally, and\nsuperfluous array elements in the tail of the array are ignored, and the match\nwill be successful. If strict array matching is required, include:\n\n```scala\nimport patternMatching.exactArrays._\n```\n\nIf exact matching of both arrays and objects is required, then it is sufficient\nto import\n\n```scala\nimport patternMatching.exact._\n```\n\n## Modifying `Json`\n\nWhatever underlying backend is used, the `Json` type is immutable. A small\nnumber of methods are provided to create new `Json` values from existing\nvalues. Given a `Json` value, a new key may be added using the following\nsyntax:\n\n```scala\nval j = json\"\"\"{ \"fruit\": \"plum\" }\"\"\"\nj.copy(_.color = \"purple\")\n```\n\nThis syntax is designed to resemble the syntax for adding a value to a\n`scala.collection.Map`, whereby the tuple passed to the `+` operator contains a\nkey and a value, resulting in the addition of this value to the map. However,\nwith `Json` types, the \"key\" is a path into the `Json` structure, and the\n\"value\" is the value to be serialized to JSON and stored at that position in\nthe JSON tree.\n\nThe `++` operator can be used to combine two JSON structures, like so:\n\n```scala\nval j1 = json\"\"\"{ \"fruit\": { \"name\": \"grape\" } }\"\"\"\nval j2 = json\"\"\"{ \"fruit\": { \"color\": \"white\" } }\"\"\"\nval json = j1 ++ j2\n```\n\nThe resultant `json` value would be\n\n```json\n{\n  \"fruit\": {\n    \"name\": \"grape\",\n    \"color\": \"white\"\n  }\n}\n```\n\nCurrently, when merging, object keys from both sides will be merged, favoring\nthe right side in the event of a clash, and arrays will be concatenated. If the\ntypes of corresponding values do not match, the value from the right side will\nclobber that from the left. In a later version of Rapture JSON, more control\nover mechanisms for combining and merging `Json` values may be provided through\nconfiguration implicits.\n\n## Error messages\n\nBy default, failures in Rapture JSON operations will result in an exception\nbeing thrown, however, alternative exception handling methods can be used with\na simple import from the Rapture Core project which will determine the return\ntype of all fallible methods such as `Json.parse` and `as`. For example,\n\n```scala\nimport rapture.core._\nimport modes.returnTry._\nJson.parse(src)\n```\n\nwill result in the return type of `Json.parse` changing from `Json` to\n`Try[Json]`, safely capturing any failures which may result from the operation.\n\nAll Rapture JSON methods will throw a limited set of possible exceptions, which\nare implemented as case classes inheriting from a sealed trait. If choosing to\nuse the `captureExceptions` mode, or another mode which captures the exception\nand tracks the exception type in its signature, this allows exhaustivity\nchecking to be performed on errors, for example:\n\n```scala\nimport modes.returnEither._\njson.fruit.as[String] match {\n  case Right(f) =>\n    s\"Found fruit $f\"\n  case Left(TypeMismatchException(found, _, _)) =>\n    s\"Fruit was the wrong type: $found\"\n  case Left(MissingValueException(path)) =>\n    s\"Fruit value was missing at path $path\"\n}\n```\n\nIf either of the final two case clauses were omitted from this pattern match,\nthe compiler will issue a warning that the match may not be exhaustive.\n\n## Mutable JSON\n\nIn the same way that the `List` type from the Scala collections library has a\ncorresponding mutable `ListBuffer` type, the `Json` type has a corresponding\n`JsonBuffer` type, which supports mutability in addition to the operations\ndescribed above. The functionality of `JsonBuffer` is a strict superset of the\nfunctionality of `Json`.\n\nAn empty `JsonBuffer` may be created with\n\n```scala\nval jb = JsonBuffer.empty\n```\n\nand can be mutated with instructions such as\n\n```scala\njb.fruit.name = \"apple\"\njb.fruit.color = \"green\"\njb.fruit.varieties = List(\"cox\")\n```\n\nresulting in\n\n```json\n{\n  \"fruit\": {\n    \"name\": \"apple\",\n    \"color\": \"green\",\n    \"varieties\": [\"cox\"]\n  }\n}\n```\n\nNote that the top-level `fruit` object gets automatically created by the first\ninstruction, and that the right-hand side of the assignment is serialized to\nJSON using Rapture's standard serialization scheme, causing a compile-time\nerror if the type cannot be serialized.\n\nIt is additionally possible to append items to the end of an array using the\n`+=` operator, like this:\n\n```scala\njb.fruit.varieties += \"braeburn\"\n```\n\nNote that it is required to\n```scala\nimport rapture.json.dictionaries.dynamic._\n```\nor define a dictionary\n```scala\nimplicit val dict = rapture.data.Dictionary.define(\"name\", \"color\", \"varieties\", ...)\n```\nin order to compile your code. It goes part of the way towards ensuring you don't write `colour` when you meant `color`.\n\n\nMutable JSON is not yet available for all backends, though this work is in\nprogress. Note that the underlying JSON backend does not need to be inherently\nmutable to support mutable JSON. If a backend which uses an immutable AST is\nused, Rapture JSON will efficiently perform the necessary tree manipulations,\nupdating references as necessary to give the impression of a mutable data\nstructure. However, using a backend which uses a mutable JSON representation\nwill likely result in better performance.\n\n## Converting JSON\n\nAll JSON values are represented by the same Scala type, `Json`, regardless of\nwhether they represents a JSON object, array, string, number or boolean, and\nregardless of which backend was used to create it.\n\nIn order to combine two `Json` values, which may be represented using different\nASTs, it is sometimes necessary to convert the internal representations of the\nJSON values from one backend to another. In all cases, this happens seamlessly\nwhen required.\n\nFor example, given the two values `j1` and `j2`,\n\n```scala\nimport jsonBackends.jawn._\nval j1: Json = json\"\"\"{ \"foo\": \"bar\" }\"\"\"\nimport jsonBackends.jfc._\nval j2: Json = json\"\"\"{ \"baz\": \"quux\" }\"\"\"\n```\n\nthe two JSON objects can be merged with `j1 ++ j2`. This will traverse the AST\nof the value `j2`, converting it from a JFC to a Jawn representation, and then\nmerge it with the value `j1` to produce a `Json` value, represented as a Jawn\nAST.\n\nLikewise, substitutions into other JSON values will invoke conversions, as\nnecessary. So, given the previous two values `j1` and `j2`, we could substitute\nboth into a new JSON object (represented by some third backend AST), and each\nwill be converted to the new AST representation.\n\n```scala\nimport jsonBackends.argonaut._\nval j3 = json\"\"\"{ \"j1\": $j1, \"j2\": $j2 }\"\"\"\n```\n\nSometimes it is useful to eagerly force conversion of a `Json` value to the\ncurrent JSON backend. This can be achieved in one of two ways:\n\n - extract a `Json` type from the existing `Json` value, i.e.\n   `jsonValue.as[Json]`\n - construct a new `Json` value from the existing `Json` value, i.e.\n   `Json(jsonValue)`\n\nThese operations are equivalent, and usage is a matter of personal taste. If\nthe value `jsonValue` is already represented by the currently-scoped JSON\nbackend, these operations will be no-ops.\n\nGiven that conversion happens seamlessly, on demand, the detail of which AST is\nused to represent the JSON is abstracted away from the user. It can, however,\nbe revealed in a couple of ways:\n\n - extracting an `Any` from the `Json` value using `jsonValue.as[Any]`; this\n   returns the underlying representation of the JSON value\n - getting the `JsonAst` from the `Json` value using `Json.ast(jsonValue)`\n\n## Outputting JSON\n\nOften, the easiest way to output JSON from the `Json` type is to call\n`.toString` on the `Json` value. Although simple, this has the disadvantages\nthat it does not offer any flexibility in how the JSON is formatted, and it\nalways returns a `String` whereas other types, such as an input stream may be\nmore appropriate for some applications.\n\nThe more general method is to use the `Json.format` method, with an appropriate\nimplicit `Formatter` in scope. Two formatters are provided as standard:\n\n - `formatters.humanReadable._`, which formats the JSON with newlines and\n   indentation, attempting to make it as readable as possible,\n - `formatters.compact._`, which includes no unnecessary whitespace\n\nBoth formatters return `String`s, though it is possible for other backends to\nprovide their own formatters for outputting to other types.\n\nFor example,\n\n```scala\nimport formatters.compact._\nval out = Json.format(json)\n```\n\n## Defining custom extractors and serializers\n\nIn order to be able to extract or serialize values of a particular Scala type,\n`T` to or from JSON, an implicit instance of `Extractor[T]` or `Serializer[T]`\nmust be available in scope.\n\n### Extractors\n\nThe easiest way to define an `Extractor` for a particular type is to start with\nan existing extractor, e.g. the `String` extractor, by summoning it with\n`Json.extractor[String]`. Extractors are functors, so you can `map` across the\nextractor to produce a new extractor for a different type. For example, to\ncreate an extractor for `java.util.Date`s, where these are stored as numbers in\nthe JSON, we can write:\n\n```scala\nimplicit val dateExtractor = Json.extractor[Long].map(new java.util.Date(_))\n```\n\nand it then becomes possible to extract a date, e.g.\n\n```scala\nval j = json\"\"\"{ \"start\": 1438967950000 }\"\"\"\nval d = j.start.as[java.util.Date]\n```\n\nOften, the most useful starting point for defining a new extractor is the no-op\n`Json` extractor, `Json.extractor[Json]`. This allows definitions such as:\n\n```scala\nimplicit val rangeExt = Json.extractor[Json].map { j =>\n  Range(j.start.as[Int], j.end.as[Int])\n}\n```\n\nor\n\n```scala\nimplicit val msgExtractor = Json.extractor[Json].map {\n  case json\"\"\"{ \"ignore\": true }\"\"\" =>\n    None\n  case json\"\"\"{ \"message\": $msg, \"ignore\": false }\"\"\" =>\n    Some(Message(str.as[String]))\n}\n```\n\n### Serializers\n\nLikewise, `Serializer`s are cofunctors, so new serializers may be created by\n`contramap`ping across an existing serializer. We can summon the serializer for\na type `T` with `Json.serializer[T]`. To produce a serializer for a type `S`\nfrom this serializer, we need to provide the `contramap` method with a function\n`S => T`, though because Scala's type system can't infer the type `S` from a\nfunction literal, we need to specify this type explicitly to the `contramap`\nmethod.\n\nHere's an example:\n\n```scala\nimplicit val exceptionSerializer = Json.serializer[String].contramap[Exception] { e =>\n  s\"${e.getClass.getName}: ${e.getMessage}\"\n}\n```\n\nThe existence of this implicit serializer will then result in any `Exception`\nbeing serialized to a representative `String`, anywhere it needs to be\nconverted into a `Json` value.\n\nAs with `Extractor`s, the `Json` serializer is often a useful starting point:\n\n```scala\nimplicit val eitherSerializer = Json.serializer[Json].contramap[Either[String, Int]] {\n  case Left(s) =>\n    json\"\"\"{ \"branch\": \"left\", \"value\": $s }\"\"\"\n  case Right(i) =>\n    json\"\"\"{ \"branch\": \"right\", \"value\": $i }\"\"\"\n}\n```\n\n### Fallback extractors\n\nExtractors may sometimes encounter JSON data that doesn't fit their expected\npattern, and result in failure. It can be useful to provide alternative\nextractors for JSON in the event that the first one fails. Extractors can be\ncomposed in this way using the `orElse` combinator.\n\nFor example, the following extractor redefines the `Int` extractor to also\naccept integers provided as JSON strings as a fallback option:\n\n```scala\nimplicit val intExt = Json.extractor[Int] orElse Json.extractor[String].map(_.toInt)\n```\n\nHopefully this demonstrates the concise and readable syntax Rapture JSON uses\nfor defining extractors and serializers, and the ease with which they can be\ncomposed and transformed.\n\n"
  },
  {
    "path": "doc/m4-release.md",
    "content": "# Changes since Rapture 2.0.0-M3\n\n## HTML\n\n### Support for more HTML syntax (help)\n### Support for nesting iterables inside elements\n\n## JSON\n\n### Serialization and extraction of maps\n### Bugfixes: serialization of string-like things\n### Improvements to JSON addition\n\n## I18n\n\n### Google translate support\n### Use & operator instead of | for (thanks to @odersky)\n\n\n## HTTP\n\n### Fix for match errors on content types (help)\n### \n\n## CLI\n\n### Issue 61\n### Optional extractors always extract\n### \n\n## Core\n\n### Removal of some reflection (causing problems with Android and Scala JS)\n"
  },
  {
    "path": "dom/shared/src/main/scala/rapture/dom/dom.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.dom\n\nimport rapture.core._\n\nimport language.higherKinds\nimport language.implicitConversions\nimport language.dynamics\n\nimport scala.annotation._\n\nimport language.experimental.macros\n\ntrait ElementType\ntrait AttributeType\n\ntrait `DomNodes#apply` extends MethodConstraint\ntrait `Element#selectDynamic` extends MethodConstraint\n\nobject Applicable {\n  implicit def reportElementError[Child <: ElementType, Att <: AttributeType, Child2 <: ElementType,\n      Elem <: ElementType, Att2 <: AttributeType](value: DomNode[Child2, Elem, Att]): Any = macro DomMacros\n    .reportElementErrorMacro[Child, Att, Child2, Elem, Att2]\n\n  implicit def listToApplicable[Child <: ElementType,\n                                Elem <: ElementType,\n                                Att <: AttributeType,\n                                Ap <: Element[Child, Elem, Att]](apps: List[Ap]): Element[Child, Elem, Att] = apps.head\n\n  implicit def wrapIterable[Child <: ElementType, This <: ElementType, Att <: AttributeType](\n      xs: Iterable[Element[Child, This, Att]]): ElementLike[Child, This, Att] = ElementSeq[Child, This, Att](xs)\n\n}\n\ntrait Applicable[+ChildType, +ThisAttType, AppliedType[_ <: ElementType, _ <: ElementType, _ <: AttributeType]] {\n  def application[Child <: ElementType, This <: ElementType, Att <: AttributeType](\n      element: Element[Child, This, Att],\n      applied: Applicable[Child, Att, AppliedType]*): AppliedType[Child, This, Att]\n}\n\nsealed abstract class DomNode[+ChildType <: ElementType, +ThisType <: ElementType, ThisAttType <: AttributeType]\n    extends Applicable[ThisType, Nothing, AppliedElement] {\n\n  def block = true\n\n  def application[Child <: ElementType, This <: ElementType, Att <: AttributeType](\n      element: Element[Child, This, Att],\n      applied: Applicable[Child, Att, AppliedElement]*): AppliedElement[Child, This, Att] =\n    AppliedElement[Child, This, Att](\n        element.tagName,\n        element.attributes,\n        applied.to[List].asInstanceOf[List[Element[_ <: ElementType, Child, _ <: AttributeType]]],\n        element.forceClosingTag,\n        element.block\n    )\n}\n\ncase class DomNodes[ChildType <: ElementType, ThisType <: ElementType, AttType <: AttributeType](\n    elements: Vector[Element[ChildType, ThisType, AttType]])\n    extends AnyVal {\n\n  def apply(i: Int = 0)(implicit mode: Mode[`DomNodes#apply`]) = mode.wrap(elements(i))\n\n  override def toString = elements.mkString(\"\\n\")\n\n  def \\[Child <: ElementType, This <: ElementType, Att <: AttributeType](\n      tag: Tag[Child, This, Att]): DomNodes[Child, This, Att] =\n    DomNodes(elements.flatMap { xs =>\n      (xs \\ tag).elements\n    })\n\n  def \\\\[Child <: ElementType, This <: ElementType, Att <: AttributeType](\n      tag: Tag[Child, This, Att]): DomNodes[Child, This, Att] =\n    DomNodes(elements.flatMap { xs =>\n      (xs \\\\ tag).elements\n    })\n}\n\ncase class MissingAttributeException(name: String) extends Exception(s\"The attribute $name was not found\")\n\ncase class TextNode[ThisType <: ElementType, ThisAttType <: AttributeType, Position <: ElementType](text: String)\n    extends DomNode[Position, ThisType, ThisAttType] {\n  def format[Output](implicit formatter: DomFormatter[Output]): Output = formatter.format(this)\n  override def toString = DomFormatter.domFormatterImplicit.format(this)\n  override def block = false\n}\n\ncase class Comment(comment: String) extends DomNode {\n  def format[Output](implicit formatter: DomFormatter[Output]): Output = formatter.format(this)\n  override def toString = DomFormatter.domFormatterImplicit.format(this)\n}\n\nobject Element {\n  implicit def reportElementError2[Child <: ElementType, Att <: AttributeType, Child2 <: ElementType,\n      Elem <: ElementType](value: DomNode[Child2, Elem, Att]): Any = macro DomMacros\n    .reportElementError2Macro[Child, Att, Child2, Elem]\n}\n\nsealed abstract class ElementLike[ChildType <: ElementType, ThisType <: ElementType, AttType <: AttributeType]\n    extends DomNode[ChildType, ThisType, AttType]\n    with Applicable[ThisType, Nothing, AppliedElement]\n    with Dynamic\n    with Product\n    with Serializable {}\n\nsealed abstract class Element[ChildType <: ElementType, ThisType <: ElementType, AttType <: AttributeType]\n    extends ElementLike[ChildType, ThisType, AttType] {\n\n  def tagName: String\n  def attributes: Map[AttributeKey[String, AttributeType], Any]\n  def children: List[DomNode[_ <: ElementType, ChildType, _ <: AttributeType]]\n  def forceClosingTag: Boolean\n  def block: Boolean\n\n  def format[Output](implicit formatter: DomFormatter[Output]): Output = formatter.format(this)\n\n  def selectDynamic(s: String)(implicit ar: AttributeKey[s.type, AttType], mode: Mode[`Element#selectDynamic`]) =\n    mode.wrap {\n      val ar2 = ar.asInstanceOf[AttributeKey[String, AttributeType]]\n      if (attributes.contains(ar2)) attributes(ar2).asInstanceOf[ar.Value]\n      else mode.exception(MissingAttributeException(ar2.attributeName))\n    }\n\n  def \\[Child <: ElementType, This <: ElementType, Att <: AttributeType](\n      tag: Tag[Child, This, Att]): DomNodes[Child, This, Att] =\n    DomNodes[Child, This, Att](children.filter {\n      case elem: Element[_, _, _] => elem.tagName == tag.tagName\n      case _ => false\n    }.map(_.asInstanceOf[Element[Child, This, Att]]).to[Vector])\n\n  def \\\\[Child <: ElementType, This <: ElementType, Att <: AttributeType](\n      tag: Tag[Child, This, Att]): DomNodes[Child, This, Att] =\n    DomNodes(children.to[Vector].flatMap {\n      case e: Element[_, _, _] =>\n        val found = e \\ tag\n        found.elements ++ (e \\\\ tag).elements\n      case _ => Vector()\n    })\n\n  override def toString = DomFormatter.domFormatterImplicit.format(this)\n\n}\n\ncase class Tag[ChildType <: ElementType, ThisType <: ElementType, AttType <: AttributeType](\n    forceClosingTag: Boolean = false,\n    override val block: Boolean = true)(implicit assigned: AssignedName)\n    extends Element[ChildType, ThisType, AttType] {\n\n  type Content = AppliedElement[_ <: ElementType, ChildType, _ <: AttType]\n\n  def tagName = assigned.name.toLowerCase\n  def attributes = Map()\n  def children = List()\n\n  def apply[AppliedType[_ <: ElementType, _ <: ElementType, _ <: AttributeType] <: DomNode[_, _, _]](\n      first: Applicable[ChildType, AttType, AppliedType],\n      applied: Applicable[ChildType, AttType, AppliedType]*): AppliedType[ChildType, ThisType, AttType] =\n    first.application(this, first +: applied: _*)\n}\n\ncase class ElementSeq[ChildType <: ElementType, ThisType <: ElementType, AttType <: AttributeType](\n    elems: Iterable[Element[ChildType, ThisType, AttType]])\n    extends ElementLike[ChildType, ThisType, AttType]\n\ncase class EmptyElement[ChildType <: ElementType, ThisType <: ElementType, AttType <: AttributeType](\n    tagName: String,\n    attributes: Map[AttributeKey[String, AttributeType], Any],\n    forceClosingTag: Boolean = false,\n    override val block: Boolean = true\n) extends Element[ChildType, ThisType, AttType] {\n\n  def children = List()\n\n  def apply(elements: DomNode[_ <: ElementType, ChildType, _ <: AttributeType]*)\n    : AppliedElement[ChildType, ThisType, AttType] =\n    AppliedElement[ChildType, ThisType, AttType](tagName, attributes, elements.to[List], forceClosingTag, block)\n}\n\ncase class AppliedElement[ChildType <: ElementType, ThisType <: ElementType, AttType <: AttributeType](\n    tagName: String,\n    attributes: Map[AttributeKey[String, AttributeType], Any] = Map(),\n    children: List[DomNode[_ <: ElementType, ChildType, _ <: AttributeType]] = Nil,\n    forceClosingTag: Boolean,\n    override val block: Boolean\n) extends Element[ChildType, ThisType, AttType]\n\n@implicitNotFound(\"Cannot access the attribute ${Name} on ${AttType} DOM nodes\")\nabstract class AttributeKey[+Name <: String, AttType <: AttributeType](val attributeName: String, actualName: String = null) {\n  type Value\n  override def toString = if (actualName == null) attributeName else actualName\n  def serialize(t: Value): String\n\n  def set[Elem <: ElementType](v: Value) =\n    new Attribute[Elem, AttType, Value](this.asInstanceOf[AttributeKey[String, AttributeType]], v)\n\n  override def hashCode = attributeName.hashCode\n  override def equals(that: Any) = that match {\n    case ar: AttributeKey[typ, attType] => ar.attributeName == attributeName\n    case _ => false\n  }\n}\n\nobject Attribute {\n  def apply[Att <: AttributeType, V](name: String, actualName: String = null)(\n      serializer: V => String): AttributeKey[name.type, Att] { type Value = V } =\n    new AttributeKey[name.type, Att](if (actualName == null) name else actualName) {\n      type Value = V\n      def serialize(v: Value): String = serializer(v)\n    }\n}\n\nclass Attribute[Elem <: ElementType, AttType <: AttributeType, Value](val id: AttributeKey[String, AttributeType],\n                                                                      val value: Value)\n    extends Applicable[Elem, AttType, EmptyElement] {\n\n  def name = id.attributeName\n\n  def application[Child <: ElementType, This <: ElementType, Att <: AttributeType](\n      element: Element[Child, This, Att],\n      applied: Applicable[Child, Att, EmptyElement]*): EmptyElement[Child, This, Att] = {\n\n    val as = applied\n      .to[List]\n      .map { x =>\n        val y = x.asInstanceOf[Attribute[ElementType, AttributeType, Any]]\n        y.id -> y.value.asInstanceOf[Any]\n      }\n      .toMap\n\n    EmptyElement(element.tagName, as, element.forceClosingTag, element.block)\n  }\n}\n"
  },
  {
    "path": "dom/shared/src/main/scala/rapture/dom/format.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.dom\n\nimport rapture.core._\n\npackage domFormatters {\n  object compact {\n    implicit val domFormatterImplicit = new DomFormatter[String] {\n      def format(element: DomNode[_, _, _]): String = element match {\n        case TextNode(t) =>\n          text(t)\n\n        case Comment(c) =>\n          comment(c)\n\n        case elems: ElementSeq[_, _, _] =>\n          elems.elems.map { elem =>\n            val xs = elem.children.map(format).mkString\n\n            val as = elem.tagName +: elem.attributes.to[List].filter(_._2 != null).map {\n              case (k, v) =>\n                k.attributeName + \"=\\\"\" + k.serialize(v.asInstanceOf[k.Value]) + \"\\\"\"\n            }\n\n            if (xs.isEmpty && !elem.forceClosingTag) s\"<${as.mkString(\" \")}/>\"\n            else s\"<${as.mkString(\" \")}>$xs</${elem.tagName}>\"\n          }.mkString\n\n        case elem: Element[_, _, _] =>\n          val xs = elem.children.map(format).mkString\n\n          val as = elem.tagName +: elem.attributes.to[List].filter(_._2 != null).map {\n            case (k, v) =>\n              k.attributeName + \"=\\\"\" + k.serialize(v.asInstanceOf[k.Value]) + \"\\\"\"\n          }\n\n          if (xs.isEmpty && !elem.forceClosingTag) s\"<${as.mkString(\" \")}/>\"\n          else s\"<${as.mkString(\" \")}>$xs</${elem.tagName}>\"\n      }\n    }\n  }\n}\n\nobject DomFormatter {\n  implicit val domFormatterImplicit: DomFormatter[String] = new DomFormatter[String] {\n\n    def format(element: DomNode[_, _, _]): String =\n      format(0, element).map {\n        case (i, s) =>\n          (\"  \" * i) + s\n      }.mkString(\"\\n\")\n\n    protected def format(indent: Int, element: DomNode[_, _, _]): Vector[(Int, String)] = element match {\n      case TextNode(t) =>\n        Vector(indent -> text(t))\n\n      case Comment(c) =>\n        Vector(indent -> comment(c))\n\n      case elem: Element[_, _, _] =>\n        val children = elem.children.to[Vector]\n        //.asInstanceOf[Vector[DomNode[ElementType, ElementType, AttributeType]]]\n        val xs = children\n          .foldLeft(Vector[(Int, String)]() -> false) {\n            case ((Vector(), _), child) =>\n              (format(indent + 1, child), child.block)\n            case ((acc, blk), child) =>\n              val cs = format(indent + 1, child)\n              val join = cs.length == 1 && !blk\n              if (join) (acc.init :+ ((acc.last._1, acc.last._2 + cs(0)._2)), !join)\n              else (acc ++ cs, !join)\n          }\n          ._1\n\n        val hasBlock = elem.children.exists(_.block)\n\n        val as = elem.tagName +: elem.attributes.to[List].filter(_._2 != null).map {\n          case (k, v) =>\n            k.attributeName + \"=\\\"\" + k.serialize(v.asInstanceOf[k.Value]) + \"\\\"\"\n        }\n\n        if (xs.isEmpty && !elem.forceClosingTag) Vector(indent -> s\"<${as.mkString(\" \")}/>\")\n        else if (hasBlock || elem.block)\n          (indent -> s\"<${as.mkString(\" \")}>\") +: xs :+ (indent -> s\"</${elem.tagName}>\")\n        else Vector(indent -> s\"<${as.mkString(\" \")}>${xs.map(_._2).mkString}</${elem.tagName}>\")\n\n      case elem: ElementSeq[_, _, _] =>\n        elem.elems.to[Vector].flatMap(format(indent, _))\n    }\n  }\n}\n\ntrait DomFormatter[Output] {\n  protected def text(string: String): String = string.replace(\"&\", \"&amp;\").replace(\"<\", \"&lt;\").replace(\">\", \"&gt;\")\n  protected def comment(string: String) = \"<!--\" + string.replace(\"&\", \"&amp;\").replace(\"<\", \"&lt;\").replace(\">\", \"&gt;\") + \"-->\"\n\n  def format(element: DomNode[_, _, _]): Output\n}\n"
  },
  {
    "path": "dom/shared/src/main/scala/rapture/dom/macro.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.dom\n\nimport rapture.base._\n\nobject DomMacros {\n\n  // The macro is invoked primarily to provide meaningful errors \n  def reportElementErrorMacro[Child <: ElementType: c.WeakTypeTag,\n                              Att <: AttributeType: c.WeakTypeTag,\n                              Child2 <: ElementType: c.WeakTypeTag,\n                              Elem <: ElementType: c.WeakTypeTag,\n                              Att2 <: AttributeType: c.WeakTypeTag](c: WhiteboxContext)(\n      value: c.Expr[DomNode[Child2, Elem, Att]]): c.Expr[Any] = {\n    //c.Expr[Applicable[Child, Att2, DomNode]] = {\n\n    import c.universe._\n\n    if (weakTypeOf[Elem].weak_<:<(weakTypeOf[Child])) {\n      reify { value.splice.asInstanceOf[Applicable[Child, Att2, DomNode]] }\n    } else {\n      val found = weakTypeOf[Elem].toString.split(\" with \").map(_.split(\"\\\\.\").last).to[Vector] match {\n        case Vector(one) => one\n        case init :+ last => init.mkString(\", \") + \" or \" + last\n      }\n      val expected = weakTypeOf[Child].toString.split(\" with \").map(_.split(\"\\\\.\").last).to[Vector] match {\n        case Vector(one) => one\n        case init :+ last => init.mkString(\", \") + \" or \" + last\n      }\n\n      c.abort(c.enclosingPosition,\n              s\"Attempted to nest a $found node in a position where only $expected nodes are \" +\n                \"permitted\")\n    }\n  }\n\n  def reportElementError2Macro[Child <: ElementType: c.WeakTypeTag,\n                               Att <: AttributeType: c.WeakTypeTag,\n                               Child2 <: ElementType: c.WeakTypeTag,\n                               Elem <: ElementType: c.WeakTypeTag](c: WhiteboxContext)(\n      value: c.Expr[DomNode[Child2, Elem, Att]]): c.Expr[Element[_, Child, _]] = {\n\n    import c.universe._\n\n    if (weakTypeOf[Elem].weak_<:<(weakTypeOf[Child])) {\n      reify { value.splice.asInstanceOf[Element[_ <: ElementType, Child, _ <: AttributeType]] }\n    } else {\n      val found = weakTypeOf[Elem].toString.split(\" with \").map(_.split(\"\\\\.\").last).to[Vector] match {\n        case Vector(one) => one\n        case init :+ last => init.mkString(\", \") + \" or \" + last\n      }\n      val expected = weakTypeOf[Child].toString.split(\" with \").map(_.split(\"\\\\.\").last).to[Vector] match {\n        case Vector(one) => one\n        case init :+ last => init.mkString(\", \") + \" or \" + last\n      }\n\n      c.abort(c.enclosingPosition,\n              s\"Attempted to nest a $found node in a position where only $expected nodes are \" +\n                \"permitted\")\n    }\n  }\n}\n"
  },
  {
    "path": "etc/header",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\n"
  },
  {
    "path": "etc/updateheader.sh",
    "content": "#!/bin/bash\n\nOLDHEADERSIZE=18\n\nfor FILE in $(find . -name '*.scala'); do\n  # Remove old header\n  sed -i 1,${OLDHEADERSIZE}d ${FILE}\n  \n  # Create a new file with the new header\n  cat etc/header $FILE > $FILE.new\n  \n  # Replace the old file with the new one\n  mv $FILE.new $FILE\ndone\n"
  },
  {
    "path": "fs/shared/src/main/scala/rapture/fs/files.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.fs\n\nimport rapture.core._\nimport rapture.io._\nimport rapture.uri._\n\nimport java.io.{Reader => _, Writer => _, _}\n\ntrait FsMethods extends MethodConstraint\n\n/** Provides support for accessing the file system through FsUrls. This is a wrapper for Java's\n  * file handling facilities, and provides roughly the same functionality within the general URL\n  * framework. */\ntrait LowerPriorityImplicits {\n\n  /** Type class object for writing `FsUrl`s as `Output[Stream]`s */\n  implicit object FileStreamCharWriter extends Writer[FsUrl, Char] {\n    def output(url: FsUrl): Output[Char] =\n      new CharOutput(new BufferedWriter(new FileWriter(url.javaFile)))\n  }\n\n  implicit object FileStreamCharAppender extends Appender[FsUrl, Char] {\n    def appendOutput(url: FsUrl): Output[Char] =\n      new CharOutput(new BufferedWriter(new FileWriter(url.javaFile, true)))\n  }\n\n  implicit val fileSizable: Sizable[FsUrl, Byte] = new Sizable[FsUrl, Byte] {\n\n    /** Returns the size of the file in bytes. */\n    def size(file: FsUrl): Long = file.length(modes.throwExceptions())\n  }\n\n  implicit val fileDeletable: Deleter[FsUrl] = new Deleter[FsUrl] {\n\n    /** Returns the size of the file in bytes. */\n    def delete(file: FsUrl): Unit = file.javaFile.delete()\n  }\n}\n\ntrait LowPriorityImplicits extends LowerPriorityImplicits {\n\n  /** Type class object for writing `Byte`s to `FsUrl`s */\n  implicit object FileStreamByteWriter extends Writer[FsUrl, Byte] {\n    def output(url: FsUrl): Output[Byte] =\n      new ByteOutput(new BufferedOutputStream(new FileOutputStream(url.javaFile)))\n  }\n\n  implicit object FileStreamByteAppender extends Appender[FsUrl, Byte] {\n    def appendOutput(url: FsUrl): Output[Byte] =\n      new ByteOutput(new BufferedOutputStream(new FileOutputStream(url.javaFile, true)))\n  }\n\n  implicit val fileMovable: Movable[FsUrl, FsUrl] = new Movable[FsUrl, FsUrl] {\n    def move(from: FsUrl, to: FsUrl): Movable.Summary = {\n      from.javaFile.renameTo(to.javaFile)\n      Movable.Summary(None)\n      // FIXME: Handle failure\n    }\n  }\n\n  /*implicit class FileCopyable(f: FsUrl) {\n    /** Renames this file to a new location. */\n    def renameTo(dest: FsUrl): Boolean = f.javaFile.renameTo(dest.javaFile)\n    \n    /** Copies this file to a new location specified by the dest parameter. */\n    def copyTo(dest: FsUrl, overwrite: Boolean = false, recursive: Boolean = false)\n        (implicit sr: Reader[FsUrl, Byte], mode: Mode[FsMethods]):\n        mode.Wrap[Int, Exception] = mode.wrap {\n      if(dest.exists) {\n        if(f.isFile && !dest.isFile) throw new Exception(\"Cannot copy a file onto a directory\")\n        else if(!f.isFile && dest.isFile) throw new Exception(\"Cannot copy a directory onto a file\")\n        else if(!overwrite) throw new Exception(\"Destination already exists\")\n        else if(f.isFile) sr.pump(f, dest)\n        else if(!recursive) throw new Exception(\"Cannot copy directory\")\n        else NavigableFile.children(f)(raw).foldLeft(0) { (c, f2) =>\n          implicit val eh = raw\n          c + f2.copyTo(dest / f2.filename, overwrite, recursive)\n        }\n      } else {\n        if(f.isFile) sr.pump(f, dest) else {\n          dest.mkdir()\n          NavigableFile.children(f)(raw).foldLeft(0) { (c, f2) =>\n            implicit val eh = raw\n            c + f2.copyTo(dest / f2.filename, overwrite, recursive)\n          }\n        }\n      }\n    }\n\n    /** Moves this file to a new location specified by the dest parameter. This will first attempt\n   * to move the file by renaming it, but will attempt copying and deletion if renaming fails. */\n    def moveTo(dest: FsUrl)(implicit sr: Reader[FsUrl, Byte], mode: Mode[FsMethods]):\n        mode.Wrap[Boolean, Exception] =\n      mode.wrap(renameTo(dest) || (copyTo(dest)(sr, raw) > 0) && delete()(raw))\n\n    /** Deletes the file represented by this FsUrl. If the recursive flag is set and the\n   * filesystem object is a directory, all subfolders and their contents will also be\n   * deleted. */\n    def delete(recursive: Boolean = false)(implicit mode: Mode[FsMethods]):\n        mode.Wrap[Boolean, Exception] = mode.wrap(if(recursive) deleteRecursively(f)\n        else f.javaFile.delete())\n    \n    private def deleteRecursively(file: FsUrl): Boolean = {\n      if(NavigableFile.isDirectory(file)(raw))\n        NavigableFile.children(file)(raw).foreach(deleteRecursively)\n      \n      delete()(raw)\n    }\n  }*/\n\n  /** Specifies how file: URLs should be navigable. */\n  implicit object NavigableFile extends Navigable[FsUrl] {\n    def children(url: FsUrl)(implicit mode: Mode[`Navigable#children`]): mode.Wrap[List[FsUrl], Exception] =\n      mode.wrap { if (url.isFile) Nil else url.javaFile.list().to[List].map(url / _) }\n\n    def isDirectory(url: FsUrl)(implicit mode: Mode[`Navigable#isDirectory`]): mode.Wrap[Boolean, Exception] =\n      mode.wrap { url.javaFile.isDirectory() }\n  }\n\n}\n\nobject `package` extends LowPriorityImplicits {\n\n  /** Type class object for reading `Byte`s from `FsUrl`s */\n  implicit object FileStreamByteReader extends JavaInputStreamReader[FsUrl](f => new FileInputStream(f.javaFile))\n\n  implicit class EnrichedFileUriContext(uc: UriContext.type) {\n    def file(constants: List[String])(variables: List[String]) = {\n      val fileUrl =\n        constants.zip(variables :+ \"\").map { case (a, b) => a + b }.mkString.split(\"/\").filter(_ != \"\").to[Vector]\n      FsUrl(fileUrl)\n    }\n  }\n}\n\nobject FsUrl {\n  implicit val hasResourceName: HasResourceName[FsUrl] = new HasResourceName[FsUrl] {\n    def resourceName(fsUrl: FsUrl): String = fsUrl.filename\n  }\n  \n  implicit val fileCpUrl: ClasspathUrlable[FsUrl] = new ClasspathUrlable[FsUrl] {\n    def toClasspathUrlItem(f: FsUrl) = ClasspathUrlItem(List(new java.net.URL(f.toString)))\n  }\n\n  implicit def uriCapable: UriCapable[FsUrl] = new UriCapable[FsUrl] {\n    def uri(f: FsUrl): Uri =\n      Uri(\"file\", f.elements.mkString(\"///\", \"/\", \"\"))\n  }\n\n  implicit def fileSlashString: Dereferenceable[FsUrl, String, FsUrl] =\n    new Dereferenceable[FsUrl, String, FsUrl] {\n      def dereference(p1: FsUrl, p2: String) = {\n        val start = if (p1.elements.lastOption == Some(\"\")) p1.elements.init else p1.elements\n        FsUrl(start :+ p2)\n      }\n    }\n\n  implicit def fileSlashRelativePath[RP <: RelativePath]: Dereferenceable[FsUrl, RP, FsUrl] =\n    new Dereferenceable[FsUrl, RP, FsUrl] {\n      def dereference(p1: FsUrl, p2: RP) = FsUrl(p1.elements.dropRight(p2.ascent) ++ p2.elements)\n    }\n\n  implicit def fileSlashRootedPath[RP <: RootedPath]: Dereferenceable[FsUrl, RP, FsUrl] =\n    new Dereferenceable[FsUrl, RP, FsUrl] {\n      def dereference(p1: FsUrl, p2: RP) = {\n        val start = if (p1.elements.lastOption == Some(\"\")) p1.elements.init else p1.elements\n        FsUrl(start ++ p2.elements)\n      }\n    }\n\n  implicit def fileParentable: Parentable[FsUrl, FsUrl] = new Parentable[FsUrl, FsUrl] {\n    def parent(fsUrl: FsUrl): FsUrl = FsUrl(fsUrl.elements.dropRight(1))\n  }\n}\n\n/** Defines a URL for the file: scheme, and provides standard filesystem operations on the file\n  * represented by the URL. */\ncase class FsUrl(elements: Seq[String]) {\n\n  override def toString = s\"file:///${elements.mkString(\"/\")}\"\n\n  /** The java.io.File corresponding to this FsUrl. */\n  lazy val javaFile: java.io.File = new java.io.File(this.uri.schemeSpecificPart.drop(2))\n\n  /** Returns true if the file or directory represented by this FsUrl can be read from. */\n  def readable: Boolean = javaFile.canRead()\n\n  /** Returns true if the file or directory represented by this FsUrl can be written to. */\n  def writable: Boolean = javaFile.canWrite()\n\n  /** Add a hook to the filesystem to delete this file upon shutdown of the JVM. */\n  def deleteOnExit(): Unit = javaFile.deleteOnExit()\n\n  /** Returns true if this object exists on the filesystem. */\n  def exists: Boolean = javaFile.exists()\n\n  /** Returns the filename of this filesystem object. */\n  def filename: String = javaFile.getName()\n\n  /** Returns true if the filesystem object represented by this FsUrl is a file, and false if\n    * it is a directory. */\n  def isFile: Boolean = javaFile.isFile()\n\n  /** Returns true if the file or directory is hidden. */\n  def hidden: Boolean = if (exists) javaFile.isHidden() else throw new Exception()\n\n  /** Returns the date of the last modification to the file or directory. */\n  def lastModified[I: TimeSystem.ByInstant](implicit mode: Mode[FsMethods]): mode.Wrap[I, Exception] =\n    mode.wrap(javaFile.lastModified() match {\n      case 0L => throw new Exception()\n      case d => ?[TimeSystem.ByInstant[I]].instant(d)\n    })\n\n  /** Returns the size of the file in bytes. */\n  def length(implicit mode: Mode[FsMethods]): mode.Wrap[Long, Exception] =\n    mode.wrap(javaFile.length() match {\n      case 0L if !exists => throw new Exception()\n      case x => x\n    })\n\n  /** If the filesystem object represented by this FsUrl does not exist, it is created as a\n    * directory, provided that either the immediate parent directory already exists, or the\n    * makeParents path is set. */\n  def mkdir(makeParents: Boolean = false)(implicit mode: Mode[FsMethods]): mode.Wrap[Boolean, Exception] =\n    mode.wrap(\n        if (makeParents) javaFile.mkdirs()\n        else\n          javaFile.mkdir())\n\n  /** Extract the file extension from the name of this file. */\n  def extension(implicit mode: Mode[FsMethods]): mode.Wrap[Option[String], Exception] =\n    mode.wrap(if (filename contains \".\") Some(filename.split(\"\\\\.\").last) else None)\n}\n\n/** The file scheme object used as a factory for FsUrls. */\nobject File extends FsUrl(Vector()) {\n\n  private val UrlRegex = \"\"\"^file:///(.*)$\"\"\".r\n\n  /** Pares a path to a file */\n  def parse(s: String) = s match {\n    case UrlRegex(path) => FsUrl(path.split(\"\\\\/\").to[Vector])\n    case path => FsUrl(path.split(\"\\\\/\").to[Vector].dropWhile(_ == \"\"))\n  }\n\n  def homeDir = File.parse(System.getenv(\"HOME\"))\n}\n"
  },
  {
    "path": "google-translate/shared/src/main/scala/rapture/google-translate/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.i18n.googleTranslate\n\nimport rapture.base._\nimport rapture.i18n._\n\nimport scala.reflect._\n\nimport language.implicitConversions\nimport language.experimental.macros\n\nobject NotString {\n  implicit def ambiguous1: NotString[String] = null\n  implicit def ambiguous2: NotString[String] = null\n  implicit def unambiguous[S <: String]: NotString[S] = null\n}\n\nclass NotString[S <: String]\n\nclass GoogleApiKey[S <: String](key: S)(implicit notString: NotString[S])\n\nobject GoogleApiKey {\n  def apply[S <: String](key: S)(implicit notString: NotString[key.type]): GoogleApiKey[key.type] =\n    new GoogleApiKey[key.type](key)(notString)\n}\n\nobject `package` {\n  implicit def upcast[ToLang <: Language, FromLang <: Language, S <: String](from: I18n[String, FromLang])(implicit license: GoogleApiKey[S]): I18n[String, ToLang] =\n    macro Macros.missingTranslationsMacro[ToLang, FromLang, S]\n}\n\nobject Macros {\n  \n  def missingTranslationsMacro[ToLang <: Language: c.WeakTypeTag, FromLang <: Language: c.WeakTypeTag, S <: String: c.WeakTypeTag](c:\n      BlackboxContext)(from: c.Expr[I18n[String, FromLang]])(license: c.Expr[GoogleApiKey[S]]): c.Expr[I18n[String, ToLang]] = {\n    \n    import c.universe._\n    import compatibility._\n\n    // FIXME: Extract this correctly!\n    val key = weakTypeOf[S].toString.split(\"\\\"\")(1)\n\n    val fromLangs = (normalize(c)(weakTypeOf[FromLang]) match {\n      case rt: RefinedType => rt.parents\n      case typ: Type => List(typ)\n    }).map(_.toString.split(\"\\\\.\").last.toLowerCase).to[Set]\n\n    val toLangs = (normalize(c)(weakTypeOf[ToLang]) match {\n      case rt: RefinedType => rt.parents\n      case typ: Type => List(typ)\n    }).map(_.toString.split(\"\\\\.\").last.toLowerCase).to[Set]\n\n    val missing = toLangs -- fromLangs\n\n    def langs(tree: Tree): Map[String, String] = tree match {\n      case Apply(Select(Apply(Select(Select(Select(id1, id2), id3), id4), List(Apply(_, List(Literal(Constant(\n          str: String)))))), lang), _) if id1.toString == \"rapture\" && id2.toString == \"i18n\" &&\n          id3.toString == \"package\" && id4.toString == \"I18nEnrichedStringContext\" =>\n        \n        Map(lang.toString -> str)\n      \n      case Apply(app: Apply, _) =>\n        langs(app)\n      \n      case Apply(TypeApply(Select(q, id6), _), List(app)) if id6.toString == \"$bar\" =>\n        langs(q) ++ langs(app)\n    }\n\n    val ls = langs(from.tree)\n    val extras = ls.find(_._1 == \"en\").orElse(ls.find(_._1 == \"fr\")).getOrElse(ls.head) match {\n      case (lang, text) =>\n        missing.map { to =>\n          val tran = GoogleTranslate.translate(key, text, lang.toUpperCase, to.toUpperCase).replaceAll(\"\\\"\", \"\\\\\\\\\\\"\")\n\t  s\"\"\"${to.toLowerCase}\"${tran}\"\"\"\"\n        }\n    }\n\n    c.abort(c.enclosingPosition, s\"\"\"Not all required language translations have been provided. Consider appending the following translations to the expression:\\n\\n  ${extras.mkString(\"& \", \" & \", \"\")}\\n\"\"\")\n\n\n  }\n}\n\nobject GoogleTranslate {\n  import rapture.uri._\n  import rapture.net._\n  import rapture.io._\n  import rapture.codec._, encodings.`UTF-8`._\n  import rapture.json._, jsonBackends.jawn._\n\n  implicit val dict = Dictionary.define(\"translations\", \"data\", \"translatedText\")\n\n  def translate(key: String, text: String, from: String, to: String): String = {\n    val out = uri\"https://www.googleapis.com/language/translate/v2?q=$text&target=$to&format=text&source=$from&key=$key\".slurp[Char]\n    Json.parse(out).data.translations(0).translatedText.as[String]\n  }\n}\n"
  },
  {
    "path": "html/shared/src/main/scala/rapture/html/doc.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.html\n\npackage doctypes {\n  object html5 {\n    implicit val implicitDoctype: Doctype = Doctype(\"html\")\n  }\n}\n\nobject Doctype {\n  implicit val defaultDoctype: Doctype = doctypes.html5.implicitDoctype\n}\n\ncase class Doctype(parts: String*) {\n  override def toString = s\"<!DOCTYPE ${parts mkString \" \"}>\"\n}\n\ncase class HtmlDoc(html: htmlSyntax.HtmlRoot)(implicit val doctype: Doctype) {\n  def format = s\"$doctype\\n${html.format}\"\n}\n"
  },
  {
    "path": "html/shared/src/main/scala/rapture/html/phantom.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.html\n\nimport rapture.dom._\n\nobject Html5 {\n  trait Html extends AttributeType\n  trait Base extends AttributeType\n  trait Link extends AttributeType\n  trait Meta extends AttributeType\n  trait Style extends AttributeType\n  trait Script extends AttributeType\n  trait Body extends AttributeType\n  trait Blockquote extends AttributeType\n  trait Ol extends AttributeType\n  trait Li extends AttributeType\n  trait A extends AttributeType\n  trait Q extends AttributeType\n  trait Time extends AttributeType\n  trait Progress extends AttributeType\n  trait Meter extends AttributeType\n  trait Bdo extends AttributeType\n  trait Edit extends AttributeType\n  trait Img extends AttributeType\n  trait Iframe extends AttributeType\n  trait Embed extends AttributeType\n  trait Object extends AttributeType\n  trait Param extends AttributeType\n  trait Video extends AttributeType\n  trait Audio extends AttributeType\n  trait Source extends AttributeType\n  trait Canvas extends AttributeType\n  trait Map extends AttributeType\n  trait Area extends AttributeType\n  trait Col extends AttributeType\n  trait Td extends AttributeType\n  trait Th extends AttributeType\n  trait Form extends AttributeType\n  trait Fieldset extends AttributeType\n  trait Label extends AttributeType\n  trait Input extends AttributeType\n  trait Button extends AttributeType\n  trait Select extends AttributeType\n  trait Optgroup extends AttributeType\n  trait Option extends AttributeType\n  trait Textarea extends AttributeType\n  trait Output extends AttributeType\n  trait Details extends AttributeType\n  trait Command extends AttributeType\n  trait Bb extends AttributeType\n  trait Menu extends AttributeType\n\n  trait Global\n      extends Html\n      with Base\n      with Link\n      with Meta\n      with Style\n      with Script\n      with Body\n      with Blockquote\n      with Ol\n      with Li\n      with A\n      with Q\n      with Time\n      with Progress\n      with Meter\n      with Bdo\n      with Edit\n      with Img\n      with Iframe\n      with Embed\n      with Object\n      with Param\n      with Video\n      with Audio\n      with Source\n      with Canvas\n      with Map\n      with Area\n      with Col\n      with Td\n      with Th\n      with Form\n      with Fieldset\n      with Label\n      with Input\n      with Button\n      with Select\n      with Optgroup\n      with Option\n      with Textarea\n      with Output\n      with Details\n      with Command\n      with Bb\n      with Menu\n\n  trait Flow extends ElementType\n  trait Metadata extends ElementType\n  trait Top extends ElementType\n  trait Definitions extends ElementType\n  trait ListItems extends ElementType\n  trait TableItems extends ElementType\n  trait ColItems extends ElementType\n  trait TrItems extends ElementType\n  trait TdItems extends ElementType\n  trait OptionItems extends ElementType\n  trait Sectioning extends Flow\n  trait Heading extends Flow\n  trait Interactive extends Flow\n  trait Phrasing extends Flow\n  trait Embedded extends Phrasing\n  trait Text extends Phrasing\n}\n"
  },
  {
    "path": "html/shared/src/main/scala/rapture/html/syntax.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.html\n\nimport rapture.dom._\nimport rapture.core._\nimport rapture.codec._\nimport rapture.net._\nimport rapture.uri._\nimport rapture.js._\nimport rapture.css._\n\nimport language.{dynamics, implicitConversions}\n\ntrait DynamicCssReferences\n\nobject dynamicCssReferencing {\n  def apply(): DynamicCssReferences = dynamicCssReferencingImplicit\n  implicit val dynamicCssReferencingImplicit: DynamicCssReferences = new DynamicCssReferences {}\n}\n\nobject htmlSyntax {\n\n  import Html5._\n\n  class DynamicAttributeKey[Name <: String, Att <: AttributeType, Val](name: String, ser: Val => String) extends AttributeKey[Name, Att](name) with Dynamic {\n    type Value = Val\n    def serialize(v: Value): String = ser(v)\n\n    def selectDynamic(att: String) = Attribute[Global, String](s\"$name-$att\")(identity(_))\n    def updateDynamic[E <: ElementType](att: String)(v: String) = selectDynamic(att).set[E](v)\n  }\n\n  def dynamic[Att <: AttributeType, Val](name: String, actualName: String = null)(serializer: Val => String) = new DynamicAttributeKey[name.type, Att, Val](if(actualName == null) name else actualName, serializer)\n\n\n  implicit def stringToTextNode(str: String): TextNode[Nothing, Nothing, Html5.Text] =\n    TextNode[Nothing, Nothing, Html5.Text](str)\n\n  type HtmlRoot = Element[Top, ElementType, Html]\n\n  type HtmlElement[T <: ElementType] = Element[_ <: ElementType, _ <: T, _ <: AttributeType]\n\n  // FIXME: These tag types are not currently working\n  def A[T <: ElementType] = Tag[T, T, A](block = false)(new AssignedName(\"A\"))\n  def Ins[T <: ElementType] = Tag[T, T, Edit]()(new AssignedName(\"Ins\"))\n  def Del[T <: ElementType] = Tag[T, T, Edit]()(new AssignedName(\"Del\"))\n  def Object[T <: Embedded] = Tag[T, T, Object]()(new AssignedName(\"Object\"))\n  def Video[T <: Embedded with Interactive] = Tag[T, T, Video]()(new AssignedName(\"Video\"))\n  def Audio[T <: Embedded with Interactive] = Tag[T, T, Audio]()(new AssignedName(\"Audio\"))\n  def Canvas[T <: Embedded] = Tag[T, T, Canvas]()(new AssignedName(\"Canvas\"))\n\n  val Html = Tag[Top, ElementType, Html]()\n  val Head = Tag[Metadata, Top, Nothing]()\n  val Title = Tag[Text, Metadata, Global]()\n  val Base = Tag[Nothing, Metadata, Base]()\n  val Link = Tag[Nothing, Metadata, Link]()\n  val Meta = Tag[Metadata, Metadata, Meta]()\n  val Style = Tag[Text, Metadata with Flow, AttributeType](block = true)\n  val Script = Tag[Text, Metadata with Phrasing, Script](forceClosingTag = true, block = true)\n  val Noscript = Tag[Text, Metadata with Phrasing, AttributeType]()\n  val Body = Tag[Flow, Top, Body]()\n  val Section = Tag[Flow, Sectioning, AttributeType]()\n  val Nav = Tag[Flow, Sectioning, AttributeType]()\n  val Article = Tag[Flow, Sectioning, AttributeType]()\n  val Aside = Tag[Flow, Sectioning, AttributeType]()\n  val H1 = Tag[Phrasing, Heading, AttributeType]()\n  val H2 = Tag[Phrasing, Heading, AttributeType]()\n  val H3 = Tag[Phrasing, Heading, AttributeType]()\n  val H4 = Tag[Phrasing, Heading, AttributeType]()\n  val H5 = Tag[Phrasing, Heading, AttributeType]()\n  val H6 = Tag[Phrasing, Heading, AttributeType]()\n  val Header = Tag[Flow, Heading, AttributeType]()\n  val Footer = Tag[Flow, Flow, AttributeType]()\n  val Address = Tag[Flow, Flow, AttributeType]()\n  val P = Tag[Phrasing, Flow, AttributeType]()\n  val Hr = Tag[Nothing, Flow, AttributeType]()\n  val Br = Tag[Phrasing, Nothing, AttributeType](block = false)\n  val Pre = Tag[Phrasing, Flow, AttributeType](block = false)\n  val Dialog = Tag[Definitions, Flow, AttributeType]()\n  val Blockquote = Tag[Flow, Sectioning, Blockquote]()\n  val Ol = Tag[ListItems, Flow, Ol]()\n  val Ul = Tag[ListItems, Flow, AttributeType]()\n  val Li = Tag[Flow, ListItems, Li]()\n  val Dl = Tag[Definitions, Flow, AttributeType]()\n  val Dt = Tag[Phrasing, Definitions, AttributeType]()\n  val Dd = Tag[Flow, Definitions, AttributeType]()\n  val Q = Tag[Phrasing, Phrasing, AttributeType]()\n  val Cite = Tag[Phrasing, Phrasing, AttributeType]()\n  val Em = Tag[Phrasing, Phrasing, AttributeType](block = false)\n  val Strong = Tag[Phrasing, Phrasing, AttributeType](block = false)\n  val Small = Tag[Phrasing, Phrasing, AttributeType]()\n  val Mark = Tag[Phrasing, Phrasing, AttributeType]()\n  val Dfn = Tag[Phrasing, Phrasing, AttributeType]()\n  val Time = Tag[Phrasing, Phrasing, AttributeType]()\n  val Progress = Tag[Phrasing, Phrasing, AttributeType]()\n  val Meter = Tag[Phrasing, Phrasing, Meter]()\n  val Code = Tag[Phrasing, Phrasing, AttributeType](block = false)\n  val Var = Tag[Phrasing, Phrasing, AttributeType]()\n  val Samp = Tag[Phrasing, Phrasing, AttributeType]()\n  val Kbd = Tag[Phrasing, Phrasing, AttributeType]()\n  val Sup = Tag[Phrasing, Phrasing, AttributeType](block = false)\n  val Sub = Tag[Phrasing, Phrasing, AttributeType](block = false)\n  val Span = Tag[Phrasing, Phrasing, AttributeType](block = false)\n  val I = Tag[Phrasing, Phrasing, AttributeType](block = false)\n  val B = Tag[Phrasing, Phrasing, AttributeType](block = false)\n  val Bdo = Tag[Phrasing, Phrasing, AttributeType]()\n  val Ruby = Tag[Phrasing, Phrasing, AttributeType]()\n  val Rt = Tag[Nothing, Phrasing, AttributeType]()\n  val Rp = Tag[Nothing, Phrasing, AttributeType]()\n  val Figure = Tag[Flow, Sectioning, AttributeType]()\n  val Img = Tag[Nothing, Embedded, Img]()\n  val Iframe = Tag[Text, Embedded, Iframe]()\n  val Embed = Tag[Text, Embedded, Embed]()\n  val Param = Tag[Flow, Embedded, Param]()\n  val Source = Tag[Nothing, Flow, Source]()\n  val Map = Tag[Flow, Flow, Map]()\n  val Area = Tag[Nothing, Phrasing, Area]()\n  val Table = Tag[TableItems, Flow, Area]()\n  val Caption = Tag[Phrasing, TableItems, AttributeType]()\n  val Colgroup = Tag[ColItems, TableItems, Col]()\n  val Col = Tag[Nothing, ColItems, Col]()\n  val Tbody = Tag[TrItems, TableItems, AttributeType]()\n  val Thead = Tag[TrItems, TableItems, AttributeType]()\n  val Tfoot = Tag[TrItems, TableItems, AttributeType]()\n  val Tr = Tag[TdItems, TrItems, AttributeType]()\n  val Td = Tag[Flow, TdItems, Td]()\n  val Th = Tag[Flow, TdItems, Th]()\n  val Form = Tag[Flow, Flow, Form]()\n  val Fieldset = Tag[Flow, Flow, Fieldset]()\n  val Label = Tag[Phrasing, Phrasing with Interactive, Label]()\n  val Input = Tag[Nothing, Phrasing with Interactive, Input]()\n  val Button = Tag[Nothing, Phrasing with Interactive, Button]()\n  val Select = Tag[OptionItems, Phrasing with Interactive, Select]()\n  val Datalist = Tag[OptionItems, Phrasing with Interactive, AttributeType]()\n  val Optgroup = Tag[OptionItems, Phrasing, Optgroup]()\n  val Option = Tag[Text, OptionItems, Option]()\n  val Textarea = Tag[Text, Phrasing with Interactive, Textarea](forceClosingTag = true)\n  val Output = Tag[Phrasing, Phrasing, Output]()\n  val Details = Tag[Flow, Interactive, Details]()\n  val Command = Tag[Nothing, Metadata with Phrasing, Command]()\n  val Bb = Tag[Phrasing, Phrasing with Interactive, Bb]()\n  val Menu = Tag[ListItems, Phrasing with Interactive, Menu]()\n  val Legend = Tag[Phrasing, Flow, AttributeType]()\n  val Div = Tag[Flow, Flow, AttributeType](forceClosingTag = true)\n\n  implicit def id = Attribute[Global, String](\"id\")(identity)\n  def id_=[E <: ElementType, Value: DomIdable](v: Value) = id.set[E](implicitly[DomIdable[Value]].domId(v))\n\n  implicit def lang = Attribute[Global, Symbol](\"lang\")(_.name)\n  def lang_=[E <: ElementType](v: Symbol) = lang.set[E](v)\n\n  implicit def translate = Attribute[Global, Boolean](\"translate\")(v => if (v) \"yes\" else \"no\")\n  def translate_=[E <: ElementType](v: Boolean) = translate.set[E](v)\n\n  object CssClassable {\n\n    implicit val cssClassable: CssClassable[CssClass] =\n      new CssClassable[CssClass] { def cssClass(cssClass: CssClass) = cssClass.classes.to[List] }\n\n    implicit def stringCssClassable(implicit dynamicCssReferencing: DynamicCssReferences): CssClassable[String] =\n      new CssClassable[String] { def cssClass(string: String) = List(string) }\n\n    implicit def symbolCssClassable(implicit dynamicCssReferencing: DynamicCssReferences): CssClassable[Symbol] =\n      new CssClassable[Symbol] { def cssClass(symbol: Symbol) = List(symbol.name) }\n\n    implicit def stringListCssClassable(implicit dynamicCssReferencing: DynamicCssReferences): CssClassable[List[String]] =\n      new CssClassable[List[String]] { def cssClass(list: List[String]) = list }\n\n    implicit def symbolListCssClassable(implicit dynamicCssReferencing: DynamicCssReferences): CssClassable[List[Symbol]] =\n      new CssClassable[List[Symbol]] { def cssClass(list: List[Symbol]) = list.map(_.name) }\n  }\n\n  trait CssClassable[Value] { def cssClass(value: Value): List[String] }\n\n  object DomIdable {\n\n    implicit val domIdable: DomIdable[DomId] =\n      new DomIdable[DomId] { def domId(value: DomId): String = value.id }\n\n    implicit def stringDomIdable(implicit dynamicCssReferencing: DynamicCssReferences): DomIdable[String] =\n      new DomIdable[String] { def domId(string: String): String = string }\n\n    implicit def symbolDomIdable(implicit dynamicCssReferencing: DynamicCssReferences): DomIdable[Symbol] =\n      new DomIdable[Symbol] { def domId(symbol: Symbol): String = symbol.name }\n  }\n\n  trait DomIdable[Value] { def domId(value: Value): String }\n\n  implicit def cls = Attribute[Global, Seq[String]](\"cls\", \"class\")(_.mkString(\" \"))\n  def cls_=[E <: ElementType, Value: CssClassable](value: Value) =\n    cls.set(implicitly[CssClassable[Value]].cssClass(value))\n\n  implicit def onload = Attribute[Body, Js](\"onload\")(_.content)\n  def onload_=[E <: ElementType](v: Js) = onload.set[E](v)\n\n  implicit def onclick = Attribute[Global, Js](\"onclick\")(_.content)\n  def onclick_=[E <: ElementType](v: Js) = onclick.set[E](v)\n\n  implicit def onkeypress = Attribute[Global, Js](\"onkeypress\")(_.content)\n  def onkeypress_=[E <: ElementType](v: Js) = onkeypress.set(v)\n\n  implicit def onmouseover = Attribute[Global, Js](\"onmouseover\")(_.content)\n  def onmouseover_=[E <: ElementType](v: Js) = onmouseover.set(v)\n\n  implicit def onmouseout = Attribute[Global, Js](\"onmouseout\")(_.content)\n  def onmouseout_=[E <: ElementType](v: Js) = onmouseout.set(v)\n\n  implicit def onchange = Attribute[Input, Js](\"onchange\")(_.content)\n  def onchange_=[E <: ElementType](v: Js) = onchange.set(v)\n\n  implicit def onblur = Attribute[Input, Js](\"onblur\")(_.content)\n  def onblur_=[E <: ElementType](v: Js) = onblur.set(v)\n\n  implicit def title = Attribute[Global, String](\"title\")(identity)\n  def title_=[E <: ElementType](v: String) = title.set[E](v)\n\n  implicit def alt = Attribute[Img with Area with Input, String](\"alt\")(identity)\n  def alt_=[E <: ElementType](v: String) = alt.set[E](v)\n\n  implicit def href = Attribute[Base with Link with A with Area, PathLink](\"href\")(_.link)\n  def href_=[E <: ElementType, L: Linkable](v: L) = href.set[E](implicitly[Linkable[L]].link(v))\n\n  implicit def name =\n    Attribute[\n        Meta with Iframe with Object with Param with Map with Form with Fieldset with Input with Button with Select with Textarea with Output,\n        Symbol](\"name\")(_.name)\n  def name_=[E <: ElementType](v: Symbol) = name.set[E](v)\n\n  implicit def selected = Attribute[Option, Boolean](\"selected\") { v =>\n    if (v) \"selected\" else null\n  }\n  def selected_=[E <: ElementType](v: Boolean) = selected.set[E](v)\n\n  implicit def cols = Attribute[Textarea, Int](\"cols\")(_.toString)\n  def cols_=[E <: ElementType](v: Int) = cols.set[E](v)\n\n  implicit def rows = Attribute[Textarea, Int](\"rows\")(_.toString)\n  def rows_=[E <: ElementType](v: Int) = rows.set[E](v)\n\n  implicit def colspan = Attribute[Td with Th, Int](\"colspan\")(_.toString)\n  def colspan_=[E <: ElementType](v: Int) = colspan.set[E](v)\n\n  implicit def rowspan = Attribute[Td with Th, Int](\"rowspan\")(_.toString)\n  def rowspan_=[E <: ElementType](v: Int) = rowspan.set[E](v)\n\n  implicit def wrap = Attribute[Textarea, Boolean](\"wrap\") { v =>\n    if (v) \"wrap\" else null\n  }\n  def wrap_=[E <: ElementType](v: Boolean) = wrap.set[E](v)\n\n  implicit def open = Attribute[Details, Boolean](\"open\") { v =>\n    if (v) \"open\" else null\n  }\n  def open_=[E <: ElementType](v: Boolean) = open.set[E](v)\n\n  implicit def max = Attribute[Progress with Meter with Input, Double](\"max\")(_.toString)\n  def max_=[E <: ElementType](v: Double) = max.set[E](v)\n\n  implicit def min = Attribute[Meter with Input, Double](\"min\")(_.toString)\n  def min_=[E <: ElementType](v: Double) = min.set[E](v)\n\n  implicit def low = Attribute[Meter, Double](\"low\")(_.toString)\n  def low_=[E <: ElementType](v: Double) = low.set[E](v)\n\n  implicit def high = Attribute[Meter, Double](\"high\")(_.toString)\n  def high_=[E <: ElementType](v: Double) = high.set[E](v)\n\n  implicit def optimum = Attribute[Meter, Double](\"optimum\")(_.toString)\n  def optimum_=[E <: ElementType](v: Double) = optimum.set[E](v)\n\n  implicit def span = Attribute[Col, Int](\"span\")(_.toString)\n  def span_=[E <: ElementType](v: Int) = span.set[E](v)\n\n  class HttpEquiv(val name: String)\n  case object contentType extends HttpEquiv(\"content-type\")\n  case object defaultStyle extends HttpEquiv(\"default-style\")\n  case object refresh extends HttpEquiv(\"refresh\")\n  implicit def httpEquiv = Attribute[Meta, HttpEquiv](\"httpEquiv\", \"http-equiv\")(_.name)\n  def httpEquiv_=[E <: ElementType](v: HttpEquiv) = httpEquiv.set[E](v)\n\n  implicit def charset = Attribute[Meta with Script, Encoding](\"charset\")(_.name)\n  def charset_=[E <: ElementType](v: Encoding) = charset.set[E](v)\n\n  implicit def content = Attribute[Meta, String](\"content\")(identity)\n  def content_=[E <: ElementType](v: String) = content.set[E](v)\n\n  implicit def manifest = Attribute[Html, HttpUrl](\"manifest\")(_.toString)\n  def manifest_=[E <: ElementType](v: HttpUrl) = manifest.set[E](v)\n\n  implicit def target =\n    Attribute[Base with Link with A with Area with Form with Input with Button, Symbol](\"target\")(_.name)\n  def target_=[E <: ElementType](v: Symbol) = target.set[E](v)\n\n  sealed class Rel(val name: String)\n  case object alternate extends Rel(\"alternate\")\n  case object author extends Rel(\"author\")\n  case object bookmark extends Rel(\"bookmark\")\n  case object help extends Rel(\"help\")\n  case object license extends Rel(\"license\")\n  case object next extends Rel(\"next\")\n  case object nofollow extends Rel(\"nofollow\")\n  case object noreferrer extends Rel(\"noreferrer\")\n  case object prefetch extends Rel(\"prefetch\")\n  case object prev extends Rel(\"prev\")\n  case object search extends Rel(\"search\")\n  case object stylesheet extends Rel(\"stylesheet\")\n  case object tag extends Rel(\"tag\")\n  implicit def rel = Attribute[Link with A with Area, Rel](\"rel\")(_.name)\n  def rel_=[E <: ElementType](v: Rel) = rel.set[E](v)\n\n  // FIXME: Provide &, | and ! operators to write media expressions, and implement all values\n  trait MediaExpr\n  sealed class Media(val name: String) extends MediaExpr { override def toString = name }\n  sealed class Device(val name: String) extends MediaExpr { override def toString = name }\n  case object all extends Device(\"all\")\n  case object aural extends Device(\"aural\")\n  case object braille extends Device(\"braille\")\n  case object handheld extends Device(\"handheld\")\n  case object projection extends Device(\"projection\")\n  case object print extends Device(\"print\")\n  case object screen extends Device(\"screen\")\n  case object tty extends Device(\"tty\")\n  case object tv extends Device(\"tv\")\n  implicit def media = Attribute[Link with Style with A with Source with Area, MediaExpr](\"media\")(_.toString)\n  def media_=[E <: ElementType](v: MediaExpr) = media.set[E](v)\n\n  implicit def style = Attribute[Global, Css](\"style\")(_.content)\n  def style_=[E <: ElementType](v: Css) = style.set[E](v)\n\n  implicit def src =\n    Attribute[Script with Img with Iframe with Embed with Video with Audio with Source with Input, PathLink](\"src\")(\n        _.toString)\n  def src_=[E <: ElementType, L: Linkable](v: L) = src.set[E](implicitly[Linkable[L]].link(v))\n\n  implicit def value =\n    Attribute[Li with Progress with Meter with Param with Input with Button with Option, String](\"value\")(identity)\n  def value_=[E <: ElementType](v: String) = value.set[E](v)\n\n  implicit def typ =\n    Attribute[\n        Link with Style with Script with A with Embed with Object with Source with Area with Input with Button with Command with Bb with Menu,\n        String](\"typ\", \"type\")(identity)\n  def typ_=[E <: ElementType](v: String) = typ.set[E](v)\n\n  implicit def action = Attribute[Form with Input with Button, PathLink](\"action\")(_.link)\n  def action_=[E <: ElementType, L: Linkable](v: L) = action.set(implicitly[Linkable[L]].link(v))\n\n  implicit def method = Attribute[Form with Input with Button, String](\"method\")(identity)\n  def method_=[E <: ElementType](v: String) = method.set(v)\n\n  implicit def enctype = Attribute[Form with Input with Button, String](\"enctype\")(identity)\n  def enctype_=[E <: ElementType](v: String) = enctype.set(v)\n\n  implicit def checked = Attribute[Input, Boolean](\"checked\")(v => if (v) \"checked\" else null)\n  def checked_=[E <: ElementType](v: Boolean) = checked.set(v)\n\n  implicit def maxlength = Attribute[Input with Textarea, Int](\"maxlength\")(_.toString)\n  def maxlength_=[E <: ElementType](v: Int) = maxlength.set(v)\n\n  implicit def hreflang = Attribute[Link, Symbol](\"hreflang\")(_.name)\n  def hreflang_=[E <: ElementType](v: Symbol) = hreflang.set(v)\n\n  implicit def sizes = Attribute[Link, String](\"sizes\")(identity)\n  def sizes_=[E <: ElementType](v: String) = sizes.set(v)\n\n  implicit def scoped = Attribute[Style, Boolean](\"scoped\")(v => if (v) \"scoped\" else null)\n  def scoped_=[E <: ElementType](v: Boolean) = scoped.set(v)\n\n  implicit def async = Attribute[Script, Boolean](\"async\")(v => if (v) \"async\" else null)\n  def async_=[E <: ElementType](v: Boolean) = async.set(v)\n\n  implicit def defer = Attribute[Script, Boolean](\"defer\")(v => if (v) \"defer\" else null)\n  def defer_=[E <: ElementType](v: Boolean) = defer.set(v)\n\n  implicit def onbeforeunload = Attribute[Body, Js](\"onbeforeunload\")(_.content)\n  def onbeforeunload_=[E <: ElementType](v: Js) = onbeforeunload.set(v)\n\n  implicit def onerror = Attribute[Body, Js](\"onerror\")(_.content)\n  def onerror_=[E <: ElementType](v: Js) = onerror.set(v)\n\n  implicit def onhashchange = Attribute[Body, Js](\"onhashchange\")(_.content)\n  def onhashchange_=[E <: ElementType](v: Js) = onhashchange.set(v)\n\n  implicit def onmessage = Attribute[Body, Js](\"onmessage\")(_.content)\n  def onmessage_=[E <: ElementType](v: Js) = onmessage.set(v)\n\n  implicit def onoffline = Attribute[Body, Js](\"onoffline\")(_.content)\n  def onoffline_=[E <: ElementType](v: Js) = onoffline.set(v)\n\n  implicit def onpopstate = Attribute[Body, Js](\"onpopstate\")(_.content)\n  def onpopstate_=[E <: ElementType](v: Js) = onpopstate.set(v)\n\n  implicit def onresize = Attribute[Body, Js](\"onresize\")(_.content)\n  def onresize_=[E <: ElementType](v: Js) = onresize.set(v)\n\n  implicit def onstorage = Attribute[Body, Js](\"onstorage\")(_.content)\n  def onstorage_=[E <: ElementType](v: Js) = onstorage.set(v)\n\n  implicit def onunload = Attribute[Body, Js](\"onunload\")(_.content)\n  def onunload_=[E <: ElementType](v: Js) = onunload.set(v)\n\n  implicit def reversed = Attribute[Ol, Boolean](\"reversed\")(v => if (v) \"reversed\" else null)\n  def reversed_=[E <: ElementType](v: Boolean) = reversed.set(v)\n\n  implicit def start = Attribute[Ol, Int](\"start\")(_.toString)\n  def start_=[E <: ElementType](v: Int) = start.set(v)\n\n  implicit def ping = Attribute[Link with Area, PathLink](\"ping\")(_.link)\n  def ping_=[E <: ElementType, L: Linkable](v: L) = ping.set(implicitly[Linkable[L]].link(v))\n\n  implicit def cite = Attribute[Blockquote with Q with Edit, PathLink](\"cite\")(_.link)\n  def cite_=[E <: ElementType, L: Linkable](v: L) = cite.set(implicitly[Linkable[L]].link(v))\n\n  implicit def datetime = Attribute[Time with Edit, String](\"datetime\")(identity)\n  def datetime_=[E <: ElementType](v: String) = datetime.set(v)\n\n  implicit def dir = Attribute[Global, Symbol](\"dir\")(_.name)\n  def dir_=[E <: ElementType](v: Symbol) = dir.set(v)\n\n  implicit def usemap = Attribute[Img with Object, String](\"usemap\")(identity)\n  def usemap_=[E <: ElementType](v: String) = usemap.set(v)\n\n  implicit def ismap = Attribute[Img, Boolean](\"ismap\")(v => if (v) \"ismap\" else null)\n  def ismap_=[E <: ElementType](v: Boolean) = ismap.set(v)\n\n  implicit def width =\n    Attribute[Img with Iframe with Embed with Object with Video with Canvas with Input, Int](\"width\")(_.toString)\n  def width_=[E <: ElementType](v: Int) = width.set(v)\n\n  implicit def height =\n    Attribute[Img with Iframe with Embed with Object with Video with Canvas with Input, Int](\"height\")(_.toString)\n  def height_=[E <: ElementType](v: Int) = height.set(v)\n\n  implicit def sandbox = Attribute[Iframe, Boolean](\"sandbox\")(v => if (v) \"sandbox\" else null)\n  def sandbox_=[E <: ElementType](v: Boolean) = sandbox.set(v)\n\n  implicit def seamless = Attribute[Iframe, Boolean](\"seamless\")(v => if (v) \"seamless\" else null)\n  def seamless_=[E <: ElementType](v: Boolean) = seamless.set(v)\n\n  implicit def poster = Attribute[Video, PathLink](\"poster\")(_.link)\n  def poster_=[E <: ElementType, L: Linkable](v: L) = poster.set(implicitly[Linkable[L]].link(v))\n\n  implicit def data = dynamic[Object, String](\"data\")(identity)\n  def data_=[E <: ElementType](v: String) = data.set(v)\n\n  implicit def autobuffer = Attribute[Video with Audio, Boolean](\"autobuffer\")(v => if (v) \"autobuffer\" else null)\n  def autobuffer_=[E <: ElementType](v: Boolean) = autobuffer.set(v)\n\n  implicit def autoplay = Attribute[Video with Audio, Boolean](\"autoplay\")(v => if (v) \"autoplay\" else null)\n  def autoplay_=[E <: ElementType](v: Boolean) = autoplay.set(v)\n\n  implicit def loop = Attribute[Video with Audio, Boolean](\"loop\")(v => if (v) \"loop\" else null)\n  def loop_=[E <: ElementType](v: Boolean) = loop.set(v)\n\n  implicit def controls = Attribute[Video with Audio, Boolean](\"controls\")(v => if (v) \"controls\" else null)\n  def controls_=[E <: ElementType](v: Boolean) = controls.set(v)\n\n  implicit def coords = Attribute[Area, String](\"coords\")(identity)\n  def coords_=[E <: ElementType](v: String) = coords.set(v)\n\n  implicit def shape = Attribute[Area, String](\"shape\")(identity)\n  def shape_=[E <: ElementType](v: String) = shape.set(v)\n\n  implicit def headers = Attribute[Td with Th, Symbol](\"headers\")(_.name)\n  def headers_=[E <: ElementType](v: Symbol) = headers.set(v)\n\n  implicit def scope = Attribute[Th, Symbol](\"scope\")(_.name)\n  def scope_=[E <: ElementType](v: Symbol) = scope.set(v)\n\n  implicit def acceptCharset = Attribute[Form, String](\"accept-charset\")(identity)\n  def acceptCharset_=[E <: ElementType](v: String) = acceptCharset.set(v)\n\n  implicit def autocomplete = Attribute[Form with Input, Boolean](\"autocomplete\")(v => if (v) \"on\" else \"off\")\n  def autocomplete_=[E <: ElementType](v: Boolean) = autocomplete.set(v)\n\n  implicit def novalidate =\n    Attribute[Form with Input with Button, Boolean](\"novalidate\")(v => if (v) \"novalidate\" else null)\n  def novalidate_=[E <: ElementType](v: Boolean) = novalidate.set(v)\n\n  implicit def label = Attribute[Option with Command with Menu, String](\"label\")(identity)\n  def label_=[E <: ElementType](v: String) = label.set(v)\n\n  implicit def forName = Attribute[Option with Command with Menu, Symbol](\"forName\")(_.name)\n  def forName_=[E <: ElementType](v: Symbol) = forName.set(v)\n\n  implicit def `for` = Attribute[Label, Symbol](\"for\")(_.name)\n  def for_=[E <: ElementType](v: Symbol) = `for`.set(v)\n\n  implicit def accept = Attribute[Input with Menu, String](\"accept\")(identity)\n  def accept_=[E <: ElementType](v: String) = accept.set(v)\n\n  implicit def autofocus =\n    Attribute[Input with Button with Select with Textarea, Boolean](\"autofocus\")(v => if (v) \"autofocus\" else null)\n  def autofocus_=[E <: ElementType](v: Boolean) = autofocus.set(v)\n\n  implicit def list = Attribute[Input, Symbol](\"list\")(_.name)\n  def list_=[E <: ElementType](v: Symbol) = list.set(v)\n\n  implicit def multiple = Attribute[Input with Select, Boolean](\"multiple\")(v => if (v) \"multiple\" else null)\n  def multiple_=[E <: ElementType](v: Boolean) = multiple.set(v)\n\n  implicit def pattern = Attribute[Input, String](\"pattern\")(identity)\n  def pattern_=[E <: ElementType](v: String) = pattern.set(v)\n\n  implicit def placeholder = Attribute[Input, String](\"placeholder\")(identity)\n  def placeholder_=[E <: ElementType](v: String) = placeholder.set(v)\n\n  implicit def readonly = Attribute[Input with Textarea, Boolean](\"readonly\")(v => if (v) \"readonly\" else null)\n  def readonly_=[E <: ElementType](v: Boolean) = readonly.set(v)\n\n  implicit def required = Attribute[Input with Textarea, Boolean](\"required\")(v => if (v) \"required\" else null)\n  def required_=[E <: ElementType](v: Boolean) = required.set(v)\n\n  implicit def size = Attribute[Input with Select, Int](\"size\")(_.toString)\n  def size_=[E <: ElementType](v: Int) = size.set(v)\n\n  implicit def step = Attribute[Input, Int](\"step\")(_.toString)\n  def step_=[E <: ElementType](v: Int) = step.set(v)\n\n  implicit def icon = Attribute[Command, PathLink](\"icon\")(_.link)\n  def icon_=[E <: ElementType, L: Linkable](v: L) = icon.set(implicitly[Linkable[L]].link(v))\n\n  implicit def radiogroup = Attribute[Command, Symbol](\"radiogroup\")(_.name)\n  def radiogroup_=[E <: ElementType](v: Symbol) = radiogroup.set(v)\n\n  implicit def default = Attribute[Command, String](\"default\")(identity)\n  def default_=[E <: ElementType](v: String) = default.set(v)\n\n  case class TypeOption(typeName: String) extends AnyVal {\n    override implicit def toString = typeName\n  }\n\n  val hidden = TypeOption(\"hidden\")\n  val text = TypeOption(\"text\")\n  val button = TypeOption(\"button\")\n  val tel = TypeOption(\"tel\")\n  val url = TypeOption(\"url\")\n  val email = TypeOption(\"email\")\n  val password = TypeOption(\"password\")\n  val date = TypeOption(\"date\")\n  val month = TypeOption(\"month\")\n  val week = TypeOption(\"week\")\n  val datetimeLocal = TypeOption(\"datetime-local\")\n  val time = TypeOption(\"time\")\n  val number = TypeOption(\"number\")\n  val range = TypeOption(\"range\")\n  val color = TypeOption(\"color\")\n  val checkbox = TypeOption(\"checkbox\")\n  val radio = TypeOption(\"radio\")\n  val file = TypeOption(\"file\")\n  val submit = TypeOption(\"submit\")\n  val image = TypeOption(\"image\")\n  val reset = TypeOption(\"reset\")\n\n}\n"
  },
  {
    "path": "html/shared/src/test/scala/rapture/html/tests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.html\n\nimport rapture.uri._\nimport rapture.net._\nimport rapture.js._\n\nimport dynamicCssReferencing._\n\nobject Tests {\n\n  import htmlSyntax._\n\n  def `Div can contain P` = Div(P)\n\n  def `Html can contain Head` = Html(Head)\n\n  def `Html can contain Body` = Html(Body)\n\n  def `Table can contain Tbody/Thead` = Table(Thead, Tbody)\n\n  def `Tbody can contain Tr` = Tbody(Tr, Tr, Tr)\n\n  def `Tr can contain Th/Tr` = Tr(Th, Td, Td, Td)\n\n  def `Div with id can contain P` = Div(id = 'foo)(P)\n\n  def `Html with id can contain Head` = Html(id = 'foo)(Head)\n\n  def `Html with id can contain Body` = Html(id = 'foo)(Body)\n\n  def `Table with id can contain Tbody/Thead` = Table(id = 'foo)(Thead, Tbody)\n\n  def `Tbody with id can contain Tr` = Tbody(id = 'foo)(Tr, Tr, Tr)\n\n  def `Tr with id can contain Th/Tr` = Tr(id = 'foo)(Th, Td, Td, Td)\n \n  def `Img has src attribute` = Img(src = ^ / \"foo.jpg\")\n\n  def `Link has hreflang attribute` = Link(hreflang = 'en)\n\n  def `Link has sizes attribute` = Link(sizes = \"16x16\")\n\n  def `Style has scoped attribute` = Style(scoped = true)\n\n  def `Script has async attribute` = Script(async = true)\n\n  def `Script has defer attribute` = Script(defer = true)\n\n  def `Body has onbeforeunload attribute` = Body(onbeforeunload = js\"foo()\")\n\n  def `Body has onerror attribute` = Body(onerror = js\"foo()\")\n\n  def `Body has onhashchange attribute` = Body(onhashchange = js\"foo()\")\n\n  def `Body has onmessage attribute` = Body(onmessage = js\"foo()\")\n\n  def `Body has onoffline attribute` = Body(onoffline = js\"foo()\")\n\n  def `Body has onpopstate attribute` = Body(onpopstate = js\"foo()\")\n\n  def `Body has onresize attribute` = Body(onresize = js\"foo()\")\n\n  def `Body has onstorage attribute` = Body(onstorage = js\"foo()\")\n\n  def `Body has onunload attribute` = Body(onunload = js\"foo()\")\n\n  def `Ol has reversed attribute` = Ol(reversed = true)\n\n  def `Ol has start attribute` = Ol(start = 10)\n\n  def `Link has ping attribute` = Link(ping = uri\"http://foo/bar\")\n\n  def `Blockquote has cite attribute` = Blockquote(cite = uri\"http://foo/bar\")\n\n  def `Time has datetime attribute` = Time(datetime = \"2008-02-14\")\n\n  def `P has dir attribute` = P(dir = 'rtl)\n\n  def `Img has alt attribute` = Img(alt = \"foo\")\n\n  def `Img has usemap attribute` = Img(usemap = \"#foo\")\n\n  def `Img has ismap attribute` = Img(ismap = true)\n\n  def `Iframe has width attribute` = Iframe(width = 200)\n\n  def `Iframe has height attribute` = Iframe(height = 300)\n\n  def `Iframe has sandbox attribute` = Iframe(sandbox = true)\n\n  def `Iframe has seamless attribute` = Iframe(seamless = true)\n\n  def `Object has data attribute` = Object(data = \"foo.bar\")\n\n  def `Video has poster attribute` = Video(poster = ^ / \"foo.bar\")\n\n  def `Video has autobuffer attribute` = Video(autobuffer = true)\n\n  def `Video has autoplay attribute` = Video(autoplay = true)\n\n  def `Video has loop attribute` = Video(loop = true)\n\n  def `Video has controls attribute` = Video(controls = true)\n\n  def `Area has coords attribute` = Area(coords = \"124,58,8\")\n\n  def `Area has shape attribute` = Area(shape = \"124,58,8\")\n\n  def `Td has headers attribute` = Td(headers = 'foo)\n\n  def `Th has scope attribute` = Th(scope = 'foo)\n\n  def `Form has accept-charset attribute` = Form(acceptCharset = \"ISO-8859-1\")\n\n  def `Input has autocomplete attribute` = Input(autocomplete = true)\n\n  def `Form has novalidate attribute` = Form(novalidate = true)\n\n  def `Command has label attribute` = Command(label = \"foo\")\n\n  def `Command has forName attribute` = Command(forName = 'foo)\n\n  def `Input has accept attribute` = Input(accept = \"image/*\")\n\n  def `Input has autofocus attribute` = Input(autofocus = true)\n\n  def `Input has list attribute` = Input(list = 'foo)\n\n  def `Input has multiple attribute` = Input(multiple = true)\n\n  def `Input has pattern attribute` = Input(pattern = \"[A-Za-z]{3}\")\n\n  def `Input has placeholder attribute` = Input(placeholder = \"foo\")\n\n  def `Input has readonly attribute` = Input(readonly = true)\n\n  def `Input has required attribute` = Input(required = true)\n\n  def `Input has size attribute` = Input(size = 20)\n\n  def `Input has step attribute` = Input(step = 2)\n\n  def `Command has icon attribute` = Command(icon = ^ / \"foo.jpg\")\n\n  def `Command has radiogroup attribute` = Command(radiogroup = 'foo)\n\n  def `Command has default attribute` = Command(default = \"foo\")\n\n  def `Label has for attribute` = Label(`for` = 'foo)\n\n  def `Fieldset can contain Legend` = Fieldset(Legend(\"foo\"))\n\n  //def `Should fail` = Html(src = \"foo\")\n\n  def `Get Tds` = Table(Tbody(Tr(Td, Td, Td), Tr(Td, Td, Td)))\n\n}\n"
  },
  {
    "path": "http/shared/src/main/scala/rapture/http/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\nimport rapture.mime._\nimport rapture.codec._\nimport rapture.uri._\n\nobject requestExtractors {\n\n  /** A standard implementaiton of a response which confirms cross-domain access corntrol */\n  def accessControlAllowOrigin(domain: String)(implicit enc: Encoding): Response =\n    StreamResponse(\n        200,\n        (\"Access-Control-Allow-Origin\" -> domain) :: (\"Access-Control-Allow-Credentials\" -> \"true\") :: Response.NoCache,\n        MimeTypes.`application/xml`,\n        v => ())(enc)\n\n  /** Method for creating new HTTP header extractors for requests */\n  def withHttpHeader(h: String) = new HttpHeader(h)\n\n  class HasParam(p: Symbol) {\n    def unapply(r: HttpRequest): Option[Boolean] = Some(r.exists(p))\n  }\n\n  class GetParam(p: Symbol) { def unapply(r: HttpRequest): Option[String] = r.param(p) }\n\n  class GetCookie(p: Symbol) {\n    def unapply(r: HttpRequest): Option[String] = r.cookie(p)\n  }\n\n  object & {\n    def unapply(r: HttpRequest): Option[(HttpRequest, HttpRequest)] = Some((r, r))\n  }\n\n  class HasCookie(p: Symbol) {\n    def unapply(r: HttpRequest): Option[Boolean] =\n      Some(r.cookie(p).isDefined)\n  }\n\n  /** Method for producing new cookie extractors for requests */\n  def getCookie(c: Symbol) = new GetCookie(c)\n  def hasCookie(c: Symbol) = new HasCookie(c)\n\n  object AsInt {\n    def unapply(s: String): Option[Int] =\n      try Some(s.toInt)\n      catch { case e: Exception => None }\n  }\n\n  /** Extract the path from the request */\n  object Path { def unapply(r: HttpRequest): Option[RootedPath] = Some(r.path) }\n\n  /** Defines a pattern matching construct to be used to chain together constraints on requests */\n  object ~ { def unapply(r: HttpRequest) = Some((r, r)) }\n\n  /** Method for creating new parameter extractors for requests */\n  def getParam(p: Symbol) = new GetParam(p)\n  def hasParam(p: Symbol) = new HasParam(p)\n\n  class HttpHeader(p: String) { def unapply(r: HttpRequest): Option[String] = r.headers.get(p).flatMap(_.headOption) }\n\n}\n"
  },
  {
    "path": "http/shared/src/main/scala/rapture/http/forms.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\nimport scala.language.higherKinds\n\nimport rapture.core._\nimport rapture.mime._\nimport rapture.uri._\nimport rapture.net._\nimport rapture.dom._\nimport rapture.html._\nimport rapture.css._, dynamicCssReferencing._\n\nimport scala.collection.mutable.ListBuffer\n\nobject Forms extends Widgets with Parsers {\n\n  class BasicForm(val name: Symbol,\n                  val params: Map[String, String] = Map(),\n                  val uploads: Map[String, Array[Byte]] = Map()) { form =>\n\n    type Field[T] <: BasicField[T]\n\n    val formName = name.name\n    protected val fields = new ListBuffer[Field[_]]\n\n    def submitted = params.contains(formName + \"_submit\")\n    def complete = submitted\n    def save() = fields.foreach(_.save())\n\n    trait BasicField[T] {\n      def name: Symbol\n      def fieldName: String = name.name\n      def paramValue: Option[String] = form.params.get(fieldName)\n\n      def value: Option[T] =\n        if (parser.submitted(stringValue)) Some(parser.parse(stringValue, dataValue)) else None\n\n      def dataValue: Option[Array[Byte]] = form.uploads.get(fieldName)\n\n      def stringValue: Option[String] =\n        if (form.submitted) paramValue else if (cell == null) None else parser.serialize(cell())\n\n      def fieldValue: String = stringValue.getOrElse(\"\")\n      def apply(): T = value.get\n      def parser: FieldParser[T]\n      def cell: Cell[T]\n      def save(): Unit = value foreach { c =>\n        if (cell == null) () else cell.update(c)\n      }\n\n      override def toString = s\"${fieldName}: value=${value}\"\n    }\n  }\n\n  trait FieldLabels {\n    type FormField[T] <: LabelledField\n    trait LabelledField { def label: String }\n  }\n\n  trait FormValidation {\n    this: (BasicForm with FormValidation) =>\n\n    def validated = fields.forall(_.validated)\n    def showValidation = submitted && !validated\n\n    abstract override def complete = submitted && validated\n\n    type Field[T] <: ValidatedField[T]\n    trait ValidatedField[T] {\n      this: BasicField[T] =>\n      lazy val validationIssues: List[String] = if (!submitted) Nil else validator(stringValue)\n      def validated: Boolean = validationIssues.isEmpty\n      def validator: Option[String] => List[String]\n      def required: Boolean\n\n      override def toString =\n        s\"${fieldName}: value=${value}, validated=${validated}, required=${required}, validator=${validator}, parser=${parser}, cell=${cell}, paramValue=${paramValue}\"\n    }\n\n    // String validators\n\n    // FIXME: Reformat these lines\n    val validUrl: Option[String] => List[String] = {\n      case None => Nil\n      case Some(s) =>\n        if (s.matches(\"\\\\b(https?|ftp)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#\" +\n                  \"/%=~_|]\")) Nil\n        else List(\"Please enter a valid URL\")\n    }\n\n    val validInteger: Option[String] => List[String] = {\n      case None => Nil\n      case Some(s) => if (s.matches(\"^-?[1-9][0-9]*$\")) Nil else List(\"Please enter a valid number\")\n    }\n\n    val validPhoneNumber: Option[String] => List[String] = {\n      case Some(s) =>\n        if (s.matches(\"\"\"^[+\\- ()0-9]*$\"\"\")) Nil\n        else\n          List(\n              \"Please enter a valid tele\" +\n                \"phone number\")\n      case None => Nil\n    }\n\n    val validTwitterHandle: Option[String] => List[String] = {\n      case Some(s) =>\n        if (s.matches(\"|[a-zA-Z0-9_]{1,15}\")) Nil\n        else List(\"Please enter a valid Twitter handle, or leave this field blank.\")\n      case None => Nil\n    }\n\n    val validEmailAddress: Option[String] => List[String] = {\n      case Some(s) =>\n        if (s.matches(\"\"\"^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2}[a-z]*)$\"\"\")) Nil\n        else List(\"Please enter a valid email address\")\n      case None => Nil\n    }\n\n    val optValidEmailAddress: Option[String] => List[String] = {\n      case Some(s) =>\n        if (s.matches(\"\"\"^([_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-\"+\n        \"9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4}))?$\"\"\")) Nil\n        else\n          List(\n              \"Please enter a valid email addre\" +\n                \"ss\")\n      case None => Nil\n    }\n\n    val validDateTime: Option[String] => List[String] = {\n      case Some(s) =>\n        if (s.matches(\"[0-9][0-9]\\\\/[0-9][0-9]\\\\/[0-9][0-9] [0-9][0-\" +\n                  \"9]:[0-9][0-9]:[0-9][0-9]\")) Nil\n        else\n          List(\n              \"Please enter a valid date, in the format DD/MM\" +\n                \"/YY hh:mm:ss.\")\n      case None => Nil\n    }\n\n    def notEmpty(msg: String = \"Value is required and can't be empty.\"): Option[String] => List[String] = {\n      case Some(s) => if (s.isEmpty) List(msg) else Nil\n      case None => Nil\n    }\n\n    def minimumLength(length: Int): Option[String] => List[String] = {\n      case Some(s) => if (s.length < 8) List(s\"The password must be at least $length characters long\") else Nil\n      case None => Nil\n    }\n\n    val isSlug: Option[String] => List[String] = {\n      case Some(s) =>\n        if (!s.matches(\"[a-z0-9]*\"))\n          List(\n              \"Value can only contain lower-case alphanum\" +\n                \"eric characters.\")\n        else Nil\n      case None => Nil\n    }\n\n    val isChecked: Option[String] => List[String] = {\n      case Some(s) => Nil\n      case None => List(\"You must check this field to continue.\")\n    }\n\n    def notDuplicate(xs: List[String]): Option[String] => List[String] = {\n      case Some(s) =>\n        if (xs contains s)\n          List(\n              \"This value is not unique. Please choose something di\" +\n                \"fferent.\")\n        else Nil\n      case None => Nil\n    }\n  }\n\n  trait FormHelp {\n    this: BasicForm =>\n    type Field[T] <: HelpField[T]\n    trait HelpField[T] extends BasicField[T] { def help: String }\n  }\n\n  trait Preprocessing {\n    this: BasicForm =>\n\n    type Field[T] <: PreprocessedField[T]\n\n    trait PreprocessedField[T] extends BasicField[T] {\n      def processString(s: String): String\n      override def stringValue = super.stringValue.map(processString)\n    }\n  }\n\n  /** Adds renderability functionality to a form.  */\n  trait RenderableForm {\n    this: (BasicForm with RenderableForm) =>\n    type Field[T] <: RenderableField[T]\n    type RenderType\n    type FormPart\n    type RenderedForm\n    val formParts = new ListBuffer[FormPart]\n\n    def wrap[T, F <: Field[T], W <: Widget](field: F, widget: W)(implicit renderer: Renderer[T, F, W]): FormPart\n\n    def content(fp: FormPart) = formParts += fp\n\n    def render: RenderedForm\n\n    // asInstanceOf[F] is here as an indirect consequence of compiler bug SI-6443\n    trait RenderableField[T] {\n      this: Field[T] =>\n      def as[F <: Field[T], W <: Widget](w: W)(implicit renderer: Renderer[T, F, W]): this.type = {\n        formParts += wrap[T, F, W](this.asInstanceOf[F], w)(renderer)\n        fields += this\n        this\n      }\n    }\n\n    trait Renderer[T, -F <: RenderableField[T], -W <: Widget] {\n      def render(f: F, w: W): RenderType\n      def hideLabel: Boolean = false\n    }\n  }\n\n  object WebForm {\n    implicit class FormExtras[F <: Forms.WebForm[_]](f: F) {\n      def show[T: HttpHandler](p1: F => T) = new {\n        def andThen[S: HttpHandler](p2: F => S): Response =\n          if (f.complete) {\n            f.save()\n            ?[HttpHandler[S]].response(p2(f))\n          } else ?[HttpHandler[T]].response(p1(f))\n      }\n    }\n  }\n\n  abstract class WebForm[L](name: Symbol,\n                            params: Map[String, String] = Map(),\n                            uploads: Map[String, Array[Byte]] = Map(),\n                            val postMethod: HttpMethods.FormMethod = HttpMethods.Post,\n                            val formAction: L = ^)(implicit actionLinkableParam: Linkable[L])\n      extends BasicForm(name, params, uploads)\n      with RenderableForm\n      with FieldLabels\n      with Preprocessing\n      with FormValidation\n      with FormHelp {\n\n    implicit protected def actionLinkable: Linkable[L] = actionLinkableParam\n\n    def encoding: MimeTypes.MimeType =\n      if (fields.exists(_.needsMultipart)) MimeTypes.`multipart/form-data`\n      else MimeTypes.`application/x-www-form-urlencoded`\n\n    class Field[T](val name: Symbol,\n                   val label: String,\n                   val cell: Cell[T],\n                   val parser: FieldParser[T],\n                   process: String => String,\n                   validate: Option[String] => List[String],\n                   val required: Boolean,\n                   val help: String,\n                   val needsMultipart: Boolean = false)\n        extends BasicField[T]\n        with RenderableField[T]\n        with LabelledField\n        with PreprocessedField[T]\n        with ValidatedField[T]\n        with HelpField[T] {\n      def processString(s: String) = process(s)\n      def validator = validate\n    }\n\n    def field[T: FieldParser](name: Symbol,\n                              label: String,\n                              cell: Cell[T] = null,\n                              process: (String => String) = identity[String],\n                              validate: Option[String] => List[String] = { s =>\n                                Nil\n                              },\n                              required: Boolean = false,\n                              help: String = \"\") =\n      new Field[T](name,\n                   label,\n                   cell,\n                   ?[FieldParser[T]],\n                   process,\n                   validate,\n                   required,\n                   help,\n                   ?[FieldParser[T]].needsMultipart)\n\n    import htmlSyntax._\n\n    type RenderType = DomNode[_ <: ElementType, Html5.Phrasing, _ <: AttributeType]\n\n    implicit val stringRenderer = new Renderer[String, Field[String], StringInput] {\n      def render(f: Field[String], w: StringInput): RenderType =\n        Input(htmlSyntax.name = f.name, typ = \"text\", value = f.fieldValue)\n    }\n\n    implicit val passwordRenderer = new Renderer[String, Field[String], PasswordInput] {\n      def render(f: Field[String], w: PasswordInput): RenderType =\n        Input(htmlSyntax.name = f.name, typ = \"password\", value = f.fieldValue)\n    }\n\n    implicit val uploadRenderer = new Renderer[Array[Byte], Field[Array[Byte]], FileUploader] {\n      def render(f: Field[Array[Byte]], w: FileUploader): RenderType =\n        Input(htmlSyntax.name = f.name, typ = \"file\", value = f.fieldValue)\n    }\n\n    implicit val checkboxRenderer = new Renderer[Boolean, Field[Boolean], Checkbox] {\n      override def hideLabel = true\n      def render(f: Field[Boolean], w: Checkbox): RenderType =\n        Label(\n            Input(typ = \"checkbox\",\n                  htmlSyntax.value = \"1\",\n                  htmlSyntax.name = f.name,\n                  checked = f.value.getOrElse(false)),\n            \" \" + f.label\n        )\n    }\n\n    implicit val textareaRenderer = new Renderer[String, Field[String], TextArea] {\n      def render(f: Field[String], w: TextArea): RenderType =\n        Textarea(htmlSyntax.name = f.name, maxlength = w.maxLength.getOrElse(-1))(TextNode(f.fieldValue))\n    }\n\n    implicit def dropdownRenderer[T, Q] = new Renderer[T, Field[T], Dropdown[Q]] {\n      def render(f: Field[T], w: Dropdown[Q]): RenderType =\n        Select(htmlSyntax.name = f.name)(\n            w.options.map { opt =>\n              Option(value = w.id(opt))(TextNode(w.description(opt)))\n            }: _*\n        )\n    }\n\n    implicit def radioListRenderer[T, Q] = new Renderer[T, Field[T], RadioList[Q]] {\n      def render(f: Field[T], w: RadioList[Q]): RenderType =\n        Span(style = css\"display:inline-block\")(\n            w.options.flatMap { opt =>\n              List(\n                  Span(\n                      Input(typ = \"radio\",\n                            htmlSyntax.name = f.name,\n                            value = w.id(opt),\n                            checked = w.id(opt) == f.fieldValue),\n                      \" \" + w.description(opt),\n                      Br\n                  )\n              )\n            }: _*\n        )\n    }\n\n    implicit val hiddenRenderer = new Renderer[String, Field[String], Hidden] {\n      def render(f: Field[String], w: Hidden): RenderType =\n        Input(typ = \"hidden\", htmlSyntax.name = f.name, htmlSyntax.value = f.fieldValue)\n    }\n  }\n\n  class BootstrapForm[L: Linkable](name: Symbol,\n                                   params: Map[String, String],\n                                   uploads: Map[String, Array[Byte]] = Map(),\n                                   postMethod: HttpMethods.FormMethod = HttpMethods.Post,\n                                   formAction: L = ^)\n      extends WebForm[L](name, params, uploads, postMethod, formAction)\n      with FormValidation {\n    import htmlSyntax._\n\n    type FormPart = DomNode[_ <: ElementType, Html5.Flow, _ <: AttributeType]\n    type RenderedForm = HtmlElement[Html5.Flow]\n\n    def hideLabels = false\n\n    def wrap[T, F <: Field[T], W <: Widget](field: F, widget: W)(implicit renderer: Renderer[T, F, W]): FormPart =\n      Div(cls = List.strap(\"control-group\", field.validationIssues.headOption.map(x => \"error\")))(\n          Label(cls = \"control-label\" /*, forName = field.name.name*/ )(TextNode(field.label)),\n          Div(cls = 'controls)(\n              renderer.render(field, widget),\n              Div(\n                  Div,\n                  field.validationIssues.map { i =>\n                    Span(cls = \"help-inline\")(i + \" \")\n                  }: _*\n              )\n          )\n      )\n\n    def render: RenderedForm =\n      Form(enctype = encoding.toString, cls = 'form, action = formAction, method = postMethod.toString)(\n          Fieldset(\n              formParts.head,\n              List.strap(\n                  formParts.tail.toList,\n                  submitRow\n              ): _*\n          )\n      )\n\n    def submitRow =\n      Div(\n          Input(htmlSyntax.name = Symbol(formName + \"_submit\"),\n                typ = \"submit\",\n                cls = List(\"btn\", \"btn-primary\"),\n                value = submitButtonText))\n\n    def submitButtonText = \"Save\"\n  }\n\n  trait TabularLayout[L] {\n    this: (WebForm[L] with TabularLayout[L]) =>\n\n    import htmlSyntax._\n\n    type FormPart = List[HtmlElement[Html5.TrItems]]\n    type RenderedForm = HtmlElement[Html5.Flow]\n\n    def hideLabels = false\n\n    def wrap[T, F <: Field[T], W <: Widget](field: F, widget: W)(implicit renderer: Renderer[T, F, W]): FormPart = {\n      List.strap(\n          field.validationIssues.map { err =>\n            Tr(Td(colspan = 3)(\"\"), Td(cls = 'validation)(err))\n          },\n          Tr(Td,\n             List.strap(\n                 if (hideLabels) Nil\n                 else if (renderer.hideLabel) List(Td(\"\"), Td(\"\"))\n                 else\n                   List(\n                       Td(field.label),\n                       Td(if (field.required) \"*\" else \"\")\n                   ),\n                 Td(renderer.render(field, widget))\n             ): _*)\n      )\n    }\n\n    def render: RenderedForm = {\n      val fps = formParts.flatten\n      Form(enctype = encoding.toString, action = formAction, method = postMethod.toString)(\n          Table(\n              Tbody(\n                  fps.head,\n                  List.strap(\n                      fps.tail.toList,\n                      submitRow\n                  ): _*\n              )\n          )\n      )\n    }\n\n    def submitButtonText = \"Save\"\n\n    def submitRow =\n      if (hideLabels) Tr(Td, Td(submitButton))\n      else\n        Tr(\n            Td,\n            Td,\n            Td,\n            Td(submitButton)\n        )\n\n    def submitButton: HtmlElement[Html5.Flow] =\n      Input(htmlSyntax.name = Symbol(formName + \"_submit\"), value = submitButtonText, typ = \"submit\")\n\n  }\n}\n\ntrait Parsers {\n  @annotation.implicitNotFound(\n      \"Unable to use values of type ${Value} in form fields without a corresponding FieldParser.\")\n  trait FieldParser[Value] {\n    def parse(value: Option[String], data: Option[Array[Byte]] = None): Value\n    def serialize(value: Value): Option[String]\n    def submitted(value: Option[String]): Boolean = value.isDefined\n    def needsMultipart: Boolean = false\n  }\n\n  implicit val StringParser = new FieldParser[String] {\n    def parse(s: Option[String], data: Option[Array[Byte]] = None) = s.getOrElse(\"\")\n    def serialize(s: String): Option[String] = Some(s)\n  }\n\n  implicit val IntParser = new FieldParser[Int] {\n    def parse(s: Option[String], data: Option[Array[Byte]] = None): Int = s.get.toInt\n    def serialize(value: Int) = Some(value.toString)\n  }\n\n  implicit val BooleanParser = new FieldParser[Boolean] {\n    def parse(s: Option[String], data: Option[Array[Byte]] = None) = s.isDefined\n    def serialize(value: Boolean) = if (value) Some(\"\") else None\n    override def submitted(value: Option[String]): Boolean = true\n  }\n\n  implicit val DataParser = new FieldParser[Array[Byte]] {\n    def parse(s: Option[String], data: Option[Array[Byte]] = None) = data.getOrElse(Array[Byte]())\n    def serialize(value: Array[Byte]) = Some(\"\")\n    override def needsMultipart: Boolean = true\n  }\n\n  def enumParser(enum: Enumeration) = new FieldParser[enum.Value] {\n    def parse(s: Option[String], data: Option[Array[Byte]] = None) = enum(s.get.toInt)\n    def serialize(value: enum.Value) = Some(value.id.toString)\n  }\n\n}\n"
  },
  {
    "path": "http/shared/src/main/scala/rapture/http/handlers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\nimport scala.xml._\n\nimport scala.concurrent._\n\nimport rapture.io._\nimport rapture.core._\nimport rapture.time._\nimport rapture.json._\nimport rapture.uri._\nimport rapture.mime._\nimport rapture.fs._\nimport rapture.html._\nimport rapture.dom._\nimport rapture.codec._\n\ntrait HttpHandler_1 {\n  implicit val linkRedirectHandler = new HttpHandler[PathLink] {\n    def response(link: PathLink) = RedirectResponse(Nil, link.toString)\n  }\n}\n\ntrait HttpHandler[-T] { httpHandler =>\n  def response(t: T): Response\n  def contraMap[S](fn: S => T): HttpHandler[S] = new HttpHandler[S] {\n    def response(t: S) = httpHandler.response(fn(t))\n  }\n}\n\nobject extensionBasedMimeTypes {\n  implicit def handler[T: Linkable](implicit reader: Reader[T, Byte]): HttpHandler[T] = new HttpHandler[T] {\n    def response(in: T) = {\n      val input = reader.input(in)\n      val parts = implicitly[Linkable[T]].link(in).link.split(\"\\\\.\").to[List]\n      val extension = if (parts.length < 2) Nil else List(parts.last)\n      val mime = extension.flatMap(MimeTypes.extension).headOption.getOrElse(MimeTypes.`application/octet-stream`)\n      ByteStreamResponse(200, Response.NoCache, mime, { os =>\n        input > os\n        os.close()\n      })\n    }\n  }\n}\n\nobject HttpHandler extends HttpHandler_1 {\n\n  implicit def charInputHandler(implicit enc: Encoding, mimeType: MimeTypes.MimeType) = new HttpHandler[Input[Char]] {\n    def response(in: Input[Char]) =\n      StreamResponse(200, Response.NoCache, mimeType, { os =>\n        in > os\n        os.close()\n      })\n  }\n\n  implicit val StringInputHandler = new HttpHandler[Input[String]] {\n    import encodings.`UTF-8`._\n    def response(in: Input[String]) =\n      StreamResponse(200, Response.NoCache, MimeTypes.`text/plain`, { os =>\n        var ln = in.read()\n        while (ln != None) {\n          (ln + \"\\n\").input > os\n          ln = in.read()\n        }\n        os.close()\n      })\n  }\n\n  implicit def xmlHandler(implicit enc: Encoding) = new HttpHandler[Seq[Node]] {\n    def response(t: Seq[Node]) =\n      StreamResponse(200, Response.NoCache, MimeTypes.`application/xml`, { os =>\n        (\"<?xml version=\\\"1.0\\\" encoding=\\\"\" + enc.name + \"\\\"?>\\n\").input > os\n        t.toString.input > os\n        os.close()\n      })\n  }\n\n  implicit def htmlDocHandler(implicit f: DomFormatter[String]): HttpHandler[HtmlDoc] = new HttpHandler[HtmlDoc] {\n    def response(htmlDoc: HtmlDoc) =\n      StreamResponse(200, Response.NoCache, MimeTypes.`text/html`, { out =>\n        (htmlDoc.doctype.toString + \"\\n\").input > out\n        htmlDoc.html.format.input > out\n        out.close()\n      })(encodings.`UTF-8`())\n  }\n\n  /*implicit def csvHandler(implicit enc: Encoding) = new HttpHandler[Csv] {\n    def response(csv: Csv) = StreamResponse(200, List(\"Pragma\" -> \"public\",\n        \"Content-Disposition\" -> \"attachment;filename=data.csv\",\n        \"Expires\" -> \"Sat, 6 May 1995 12:00:00 GMT\",\n        \"Cache-Control\" -> \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\"\n        ),\n        MimeTypes.`text/csv`, { os =>\n      csv.toString.input > os\n      os.close()\n    })\n  }*/\n\n  /*implicit def cssHandler(implicit enc: Encoding) = new HttpHandler[HtmlCss.Stylesheet] {\n    def response(css: HtmlCss.Stylesheet) = StreamResponse(200, Response.NoCache,\n        MimeTypes.`text/css`, { os =>\n      css.toString.input > os\n      os.close()\n    })\n  }*/\n\n  implicit def stringHandler(implicit enc: Encoding) = new HttpHandler[String] {\n    def response(t: String) =\n      StreamResponse(200, Response.NoCache, MimeTypes.`text/plain`, { os =>\n        t.input > os\n        os.close()\n      })\n  }\n\n  implicit def byteInputHandleri(implicit mimeType: MimeTypes.MimeType) = new HttpHandler[Input[Byte]] {\n    def response(in: Input[Byte]) =\n      ByteStreamResponse(200, Response.NoCache, mimeType, { os =>\n        in > os\n        os.close()\n      })\n  }\n\n  implicit def fileHandler = new HttpHandler[FsUrl] {\n    def response(file: FsUrl) =\n      FileResponse(200,\n                   Response.NoCache,\n                   file.extension.toList.flatMap(MimeTypes.extension).headOption.getOrElse(MimeTypes.`text/plain`),\n                   file)\n  }\n\n  implicit def cacheHandler[T](implicit h: HttpHandler[T]): HttpHandler[Cached[T]] = new HttpHandler[Cached[T]] {\n    def response(resp: Cached[T]) = {\n      val r = h.response(resp.toCache)\n      val dateFormat = DateFormat(\"EEE, d MMM yyyy\")\n      val timeFormat = TimeFormat(\"HH:mm:ss z\")\n      val lastModified = List(\"Last-modified\" -> resp.lastModified.format(dateFormat, timeFormat))\n      r match {\n        case BufferResponse(code, headers, contentType, buffers) =>\n          BufferResponse(code, lastModified, contentType, buffers)\n        case sr @ StreamResponse(code, headers, contentType, send) =>\n          StreamResponse(code, lastModified, contentType, send)(sr.encoding)\n        case ByteStreamResponse(code, headers, contentType, send) =>\n          ByteStreamResponse(code, lastModified, contentType, send)\n        case ErrorResponse(code, headers, message, detail) =>\n          ErrorResponse(code, lastModified, message, detail)\n        case FileResponse(code, headers, contentType, file) =>\n          FileResponse(code, lastModified, contentType, file)\n        case RedirectResponse(headers, location) =>\n          RedirectResponse(lastModified, location)\n      }\n    }\n  }\n\n  implicit def attachmentHandler[T](implicit h: HttpHandler[T]): HttpHandler[Attachment[T]] =\n    new HttpHandler[Attachment[T]] {\n      def response(resp: Attachment[T]) = {\n        val r = h.response(resp.original)\n        val headers = (\"Content-Disposition\" -> (\"attachment; filename=\" + resp.filename)) :: r.headers.toList\n        r match {\n          case BufferResponse(code, headers, contentType, buffers) =>\n            BufferResponse(code, headers, contentType, buffers)\n          case sr @ StreamResponse(code, headers, contentType, send) =>\n            StreamResponse(code, headers, contentType, send)(sr.encoding)\n          case ByteStreamResponse(code, headers, contentType, send) =>\n            ByteStreamResponse(code, headers, contentType, send)\n          case ErrorResponse(code, headers, message, detail) =>\n            ErrorResponse(code, headers, message, detail)\n          case FileResponse(code, headers, contentType, file) =>\n            FileResponse(code, headers, contentType, file)\n          case RedirectResponse(headers, location) =>\n            RedirectResponse(headers, location)\n        }\n      }\n    }\n\n  implicit def futureHandler[T](implicit h: HttpHandler[T], ec: ExecutionContext): HttpHandler[Future[T]] =\n    new HttpHandler[Future[T]] {\n      def response(future: Future[T]) = h.response(Await.result(future, duration.Duration.Inf))\n    }\n\n  implicit val nullHandler = new HttpHandler[Response] { def response(r: Response) = r }\n\n  implicit def jsonHandler(implicit enc: Encoding) = new HttpHandler[Json] {\n    def response(t: Json) =\n      StreamResponse(200, Response.NoCache, MimeTypes.`application/json`, { os =>\n        t.toString.input > os\n        os.close()\n      })\n  }\n\n  /*implicit def pageHandler(implicit enc: Encoding) = new HttpHandler[Layout.Page] {\n    def response(page: Layout.Page) = StreamResponse(page.httpStatus, Response.NoCache,\n        MimeTypes.`text/html`, { os =>\n      page.stream > os\n    })\n  }*/\n}\n"
  },
  {
    "path": "http/shared/src/main/scala/rapture/http/http.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\nimport rapture.core._\n\ntrait `HttpServer.listen` extends MethodConstraint\ntrait `HttpServer#stop` extends MethodConstraint\n\ntrait HttpBackend {\n  def startListening(port: Int)(handler: HttpRequest => Response): Unit\n  def stopListening(): Unit\n}\n\ncase class ListenException(msg: String) extends RuntimeException\n\ncase class Listening(port: Int)\n\ncase class PortListenException(port: Int)\n\nobject HttpServer {\n  def listen(port: Int = 80)(handler: HttpRequest => Response)(implicit backend: HttpBackend,\n                                                               mode: Mode[`HttpServer.listen`]): HttpServer = {\n    val httpServer = new HttpServer(port) {\n      protected def handle(r: HttpRequest) = handler(r)\n    }\n    httpServer.start()\n    httpServer\n  }\n}\n\n/** This trait provides a nice interface to the HTTP server */\nabstract class HttpServer(val serverPort: Int = 80)(implicit httpBackend: HttpBackend) {\n\n  private[HttpServer] def start()(implicit mode: Mode[_]): mode.Wrap[Listening, ListenException] = mode.wrap {\n    httpBackend.startListening(serverPort)(handle)\n    Listening(serverPort)\n  }\n\n  def stop()(implicit mode: Mode[`HttpServer#stop`]): mode.Wrap[Unit, ListenException] =\n    mode.wrap(httpBackend.stopListening())\n\n  protected def handle(r: HttpRequest): Response\n\n  def notFound(r: HttpRequest): Response =\n    ErrorResponse(404, Nil, \"Not found\", \"The requested resource could not be found\")\n\n  def error(r: HttpRequest, e: Throwable): Response =\n    ErrorResponse(500, Nil, \"An unexpected error has occurred\", \"Unknown error\")\n}\n"
  },
  {
    "path": "http/shared/src/main/scala/rapture/http/page.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\n/*import rapture.io._\nimport rapture.core._\nimport rapture.net._\nimport rapture.mime._\nimport rapture.uri._\nimport rapture.html._\n\nimport htmlSyntax._\n\nobject Layout {\n\n  import MimeTypes._\n\n  trait PageMetadata { page: Page =>\n    override def metas: List[Element[Metadata]] =\n      (metaData.toList map { case (k, v) => Meta(htmlSyntax.name = k, htmlSyntax.content = v)() }) :::\n          page.metas\n    \n    def metaData: collection.Map[Symbol, String] = collection.Map(\n      'description = metaDescription,\n      'keywords = metaKeywords.mkString(\",\"),\n      'author = metaAuthor\n    )\n\n    def metaDescription: String\n    def metaKeywords: List[String]\n    def metaAuthor: String\n  }\n\n  trait JQueryUi extends Page { this: JQuery =>\n    def jQueryUiLocation = Http / \"ajax.googleapis.com\" / \"ajax\" / \"libs\" / \"jqueryui\" / \"1.8.23\" /\n        \"jquery-ui.min.js\"\n    \n    override def scripts: List[Element[Metadata]] =\n      Script(scriptType = `text/javascript`, src = PathLink(jQueryUiLocation.schemeSpecificPart)) :: super.scripts\n  }\n\n  trait JQuery extends Page {\n\n    def jQueryLocation: HttpUrl = Http / \"ajax.googleapis.com\" / \"ajax\" / \"libs\" / \"jquery\" / \"1.7.2\" / \"jquery.min.js\"\n\n    override def scripts: List[Element[Metadata]] =\n      Script(scriptType = `text/javascript`, src = PathLink(jQueryLocation.schemeSpecificPart)) :: super.scripts\n  }\n\n  abstract class Page { page =>\n\n    def httpStatus = 200\n\n    def doctype = \"<!DOCTYPE html>\"\n\n    def stylesheets: List[Stylesheet] = Nil\n    case class Stylesheet(link: PathLink)\n\n    def lang: String = \"en\"\n    def title: String\n\n    def links: List[Element[Metadata]] =\n      stylesheets map { ss => Link(rel = \"stylesheet\", href = ss.link)() }\n    \n    def scripts: List[Element[Metadata]] = Nil\n    def styles: List[Element[Metadata]] = Nil\n    def metas: List[Element[Metadata]] = Nil\n\n    def head =\n      Title(page.title) :: styles.reverse ::: links.reverse ::: scripts.reverse ::: metas\n\n    def body: List[Element[Flow]]\n\n    def document =\n      Html(htmlSyntax.lang = page.lang)(\n        Head(page.head: _*),\n        Body(page.body: _*)\n      )\n\n    def stream: Input[Char] = {\n      val sb = new StringBuilder\n      sb.append(doctype)\n      sb.append(document.toString)\n      sb.toString.input[Char]\n    }\n  }\n  \n  trait Bootstrap extends Page {\n   \n    def bootstrapLocation = Http / \"twitter.github.com\" / \"bootstrap\" / \"1.4.0\" / \"bootstrap.min.css\"\n\n    override def links: List[Element[Metadata]] =\n      Link(rel = \"stylesheet\", href = bootstrapLocation)() :: super.links\n\n  }\n\n  import Forms._\n   \n  trait TinyMce extends Page {\n\n    def tinyMceLocation: PathLink\n\n    override def scripts: List[Element[Metadata]] =\n      Script(scriptType = `text/javascript`, src = tinyMceLocation)() :: super.links\n \n  }\n  \n  trait TinyMceForm { this: WebForm =>\n\n    implicit val tinyMceEditorRenderer =\n      new Renderer[String, Field[String], HtmlEditor] {\n        def render(f: Field[String], w: HtmlEditor) =\n          Textarea(style = width(100.percent), htmlSyntax.name = f.name, cls = \"mceEditorCustom\")(raw(f.fieldValue))\n      }\n  }\n  \n}*/\n"
  },
  {
    "path": "http/shared/src/main/scala/rapture/http/request.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\nimport java.io._\nimport rapture.io._\nimport rapture.mime._\nimport rapture.uri._\nimport rapture.time._\nimport rapture.net._\n\nimport scala.collection.mutable.ListBuffer\n\nobject HttpRequest {\n  sealed trait QueryParam { def name: String }\n  case class StringQueryParam(name: String, value: String) extends QueryParam\n  case class FileQueryParam(name: String, localFile: File)(val clientFilename: String,\n                                                           val contentType: MimeTypes.MimeType)\n      extends QueryParam\n\n}\n\n/** Represents an HTTP request. */\nabstract class HttpRequest {\n\n  /** The length of incoming data, e.g. for POST or PUT. */\n  def contentLength: Int\n\n  /** The part of the URI following the ?, or the empty string. */\n  def queryString: String\n\n  /** The HTTP method, e.g. GET or POST, etc. */\n  def requestMethod: HttpMethods.Method\n\n  /** The virtual path, i.e. the part of the URL following the hostname, not\n    *  including any query parameters. Always starts with a slash. */\n  def scriptName: String\n\n  /** If true, indicates that this is a secure connection. */\n  def https: Boolean\n\n  /** The name the web server thinks this (virtual) server is called, e.g.\n    *  www.example.com. */\n  def serverName: String\n\n  /** The port the web server says the request was made to. */\n  def serverPort: Int\n\n  /** The requested URL, without any query parameters, e.g.\n    *  http://www.example.com:8080/basePath/servicePath/remainder. */\n  def url: String\n\n  /** The application base path used in this request, relative to the domain\n    * root. Conventionally has a leading slash only, unless it's empty. */\n  def basePathString: String\n\n  /** The service path requested, relative to the base path. Conventionally\n    *  has a leading slash only, unless it's empty. */\n  def servicePathString: String\n\n  /** The remainder of the URL following the service path, without any query\n    *  parameters. Conventionally has a leading slash only, unless it's empty. */\n  def remainderString: String\n\n  /** Array of all query and POST parameters in order. */\n  def parameters: Map[String, String]\n\n  def fileUploads: Map[String, Array[Byte]]\n\n  /** Request headers. */\n  def headers: Map[String, Seq[String]]\n\n  /** Body PUT or POSTed */\n  def body: String\n\n  /** The time the request arrived */\n  val time: Long = System.currentTimeMillis\n\n  /** The path of the script */\n  lazy val path: RootedPath = RootedPath.parse(servicePathString + remainderString).get\n\n  protected var streamRead = false\n\n  lazy val remainder: List[String] = remainderString.split(\"\\\\/\").toList\n\n  def onComplete(block: => Unit) = completionTasks += (() => block)\n\n  val completionTasks: ListBuffer[() => Unit] = new ListBuffer\n\n  /** Checks for the existence of a named request param. */\n  def exists(k: Symbol): Boolean = parameters.contains(k.name)\n\n  /** Gets a named request param (which must exist). */\n  def apply(k: String): String = parameters.get(k) match {\n    case Some(v) => v\n    case None => throw new Exception(\"Missing parameter: \" + k)\n  }\n\n  /** Gets a named request param or returns the default. */\n  def param(k: Symbol, default: String): String = parameters.get(k.name) match {\n    case Some(v) => v\n    case None => default\n  }\n\n  /** Gets a named request param which may not exist. */\n  def param(k: Symbol): Option[String] = parameters.get(k.name)\n\n  /** Gets the value of a cookie from the request */\n  def cookie(c: Symbol): Option[String] = cookies.get(c.name)\n\n  private lazy val cookies: scala.collection.immutable.Map[String, String] = {\n    var cs = scala.collection.immutable.Map[String, String]()\n    headers.get(\"cookie\") match {\n      case Some(Seq(v)) =>\n        val vs = v.split(\"; ?\")\n        for (v <- vs) {\n          val kv = v.split(\"=\", 2)\n          if (kv.length == 2) cs = cs + (kv(0).urlDecode -> kv(1).urlDecode)\n        }\n      case _ => ()\n    }\n    cs\n  }\n\n  val responseCookies: ListBuffer[(String, String, String, String, Option[Long], Boolean)] =\n    new ListBuffer[(String, String, String, String, Option[Long], Boolean)]\n\n  def setCookie(name: Symbol,\n                value: String,\n                domain: String = serverName,\n                path: RootedPath = ^,\n                expiry: Option[DateTime] = None,\n                secure: Boolean = false) =\n    responseCookies += ((name.name, value, domain, path.toString, expiry.map(_.toLong), secure))\n}\n"
  },
  {
    "path": "http/shared/src/main/scala/rapture/http/response.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\nimport rapture.core._\n\nimport java.nio._\n\nimport rapture.io._\nimport rapture.mime._\nimport rapture.codec._\nimport rapture.fs._\nimport rapture.time._\n\n/** A collection of standard response-related objects. */\nobject Response {\n  val NotModified = ErrorResponse(304, Nil, \"Not Modified\", \"Resource is unchanged.\")\n  val Forbidden = ErrorResponse(403, Nil, \"Forbidden\", \"Access to the requested resource is denied.\")\n  val NotFound = ErrorResponse(404, Nil, \"Not Found\", \"The requested resource could not be located.\")\n\n  val NoCache = List(\n      \"Expires\" -> \"Sat, 6 May 1995 12:00:00 GMT\",\n      \"Cache-Control\" -> \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\",\n      \"Pragma\" -> \"no-cache\"\n  )\n\n  implicit def handled[T: HttpHandler](t: T): Response = ?[HttpHandler[T]].response(t)\n}\n\n/** Basic definition for a response */\nsealed trait Response {\n  def code: Int\n  def headers: Seq[(String, String)]\n}\n\ncase class BufferResponse(code: Int,\n                          headers: Seq[(String, String)],\n                          contentType: MimeTypes.MimeType,\n                          buffers: Array[ByteBuffer])\n    extends Response\ncase class StreamResponse(code: Int,\n                          headers: Seq[(String, String)],\n                          contentType: MimeTypes.MimeType,\n                          send: Output[Char] => Unit)(implicit enc: Encoding)\n    extends Response {\n  def encoding = enc\n}\ncase class ByteStreamResponse(code: Int,\n                              headers: Seq[(String, String)],\n                              contentType: MimeTypes.MimeType,\n                              send: Output[Byte] => Unit)\n    extends Response\ncase class ErrorResponse(code: Int, headers: Seq[(String, String)], message: String, detail: String) extends Response\ncase class FileResponse(code: Int, headers: Seq[(String, String)], contentType: MimeTypes.MimeType, file: FsUrl)\n    extends Response\ncase class RedirectResponse(headers: Seq[(String, String)], location: String) extends Response {\n  final def code = 302\n}\n\ncase class Cached[T](toCache: T, lastModified: DateTime)\ncase class Attachment[T](original: T, filename: String)\n"
  },
  {
    "path": "http/shared/src/main/scala/rapture/http/widgets.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\ntrait Widgets {\n  trait Widget\n\n  case class Dropdown[T](options: List[T])(val id: T => String = (t: Any) => t.toString,\n                                           val description: T => String = (t: Any) => t.toString)\n      extends Widget\n\n  case class RadioList[T](options: List[T])(val id: T => String = (t: Any) => t.toString,\n                                            val description: T => String = (t: Any) => t.toString)\n      extends Widget\n\n  case class TextArea(width: Int = 8, height: Int = 80, maxLength: Option[Int] = None) extends Widget\n  case class HtmlEditor() extends Widget\n  case class StringInput() extends Widget\n  case class PasswordInput() extends Widget\n  case class FileUploader() extends Widget\n  case class Checkbox() extends Widget\n  case class Hidden() extends Widget\n}\n"
  },
  {
    "path": "http-jetty/shared/src/main/scala/rapture/http-jetty/http.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\npackage httpBackends {\n  object jetty {\n    implicit val implicitHttpServer = new HttpBackend {\n      import org.eclipse.jetty.server.Server\n      import org.eclipse.jetty.servlet.ServletContextHandler\n      import org.eclipse.jetty.servlet.ServletHolder\n\n      private var server: Option[Server] = None\n\n      class HttpServletWrapper(fn: HttpRequest => Response) extends ServletWrapper {\n        def handle(r: HttpRequest) = fn(r)\n      }\n\n      def startListening(port: Int)(handler: HttpRequest => Response): Unit = {\n        import org.eclipse.jetty.util.log.Logger\n        object NoLogging extends Logger {\n          override def getName = \"no\"\n          override def warn(msg: String, args: AnyRef*) = ()\n          override def warn(thrown: Throwable) = ()\n          override def warn(msg: String, thrown: Throwable) = ()\n          override def info(msg: String, args: AnyRef*) = ()\n          override def info(thrown: Throwable) = ()\n          override def info(msg: String, thrown: Throwable) = ()\n          override def isDebugEnabled(): Boolean = false\n          override def setDebugEnabled(enabled: Boolean) = ()\n          override def debug(msg: String, args: AnyRef*) = ()\n          override def debug(thrown: Throwable) = ()\n          override def debug(msg: String, thrown: Throwable) = ()\n          override def getLogger(name: String): Logger = this\n          override def ignore(thrown: Throwable) = ()\n        }\n        org.eclipse.jetty.util.log.Log.setLog(NoLogging)\n        server = Some(new Server(port))\n        val sch = new ServletContextHandler(server.get, \"/\", true, false)\n        val httpServlet = new HttpServletWrapper(handler)\n        sch.addServlet(new ServletHolder(httpServlet), \"/\")\n        server.foreach(_.start())\n      }\n\n      def stopListening(): Unit = server.foreach(_.stop())\n    }\n  }\n}\n"
  },
  {
    "path": "http-jetty/shared/src/main/scala/rapture/http-jetty/servlet.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\nimport rapture.core._\nimport rapture.mime._\nimport rapture.codec._\nimport rapture.io._\nimport rapture.net.{Cookie => _, _}\n\nimport scala.collection.mutable.{Map => _, _}\n\nimport javax.servlet.http._\nimport java.nio.ByteBuffer\nimport java.io._\n\nclass JettyHttpRequest(req: HttpServletRequest, resp: HttpServletResponse) extends HttpRequest {\n  def contentType = {\n    val ct = Option(req.getContentType) getOrElse \"application/x-www-form-urlencoded\"\n    val ct2 = ct.split(\";\").head\n    MimeTypes.unapply(ct2).getOrElse(MimeTypes.MimeType(ct2))\n  }\n\n  def contentLength = req.getContentLength\n  def queryString = req.getQueryString\n  def requestMethod = HttpMethods.method(req.getMethod)\n  def scriptName = req.getRequestURI\n  def https = req.isSecure\n  def serverName = req.getServerName\n  def serverPort = req.getServerPort\n  lazy val url = req.getRequestURL.toString\n  def basePathString = req.getContextPath\n  def servicePathString = req.getServletPath\n  def remainderString = Option(req.getPathInfo).getOrElse(\"\")\n\n  def uploadSizeLimit = 50 * 1024 * 1024\n  private var uploadsValue: Map[String, Array[Byte]] = Map[String, Array[Byte]]()\n\n  def fileUploads: Map[String, Array[Byte]] = uploadsValue\n\n  private def stripQuotes(s: String) = if (s.startsWith(\"\\\"\")) s.substring(1, s.length - 1) else s\n\n  val parameters = contentType match {\n    case MimeTypes.`multipart/form-data` =>\n      val params = new HashMap[String, String]\n      val ct = headers(\"Content-Type\").head.split(\"; *\")\n      val boundary = ct.find(_.startsWith(\"boundary=\")).get.substring(9)\n      val mpr = new MultipartReader(boundary, req.getInputStream, uploadSizeLimit)\n      while (mpr.ready()) {\n        mpr.read() foreach { m =>\n          if (m.filename.isDefined) {\n            uploadsValue += stripQuotes(m.name.get) -> m.data\n            params(stripQuotes(m.name.get)) = stripQuotes(m.filename.get)\n          } else\n            params(stripQuotes(m.name.get)) = new String(m.data, Option(req.getCharacterEncoding).getOrElse(\"ASCII\"))\n        }\n      }\n      params.toMap\n\n    case MimeTypes.`application/x-www-form-urlencoded` =>\n      val params = new HashMap[String, String]\n      val enum = req.getParameterNames\n      while (enum.hasMoreElements) {\n        val name = enum.nextElement.asInstanceOf[String]\n        for (value <- req.getParameterValues(name))\n          params(name) = value\n      }\n      params.toMap\n\n    case _ =>\n      Map.empty[String, String]\n  }\n\n  private val input = {\n    val in = req.getInputStream\n    import encodings.`UTF-8`._\n    InputBuilder.inputStreamCharBuilder.input(in)\n  }\n\n  lazy val body =\n    if (streamRead) throw new Exception(\"Stream has already been read\")\n    else {\n      streamRead = true\n      input.slurp()\n    }\n\n  private def enumToList(e: java.util.Enumeration[_], list: List[String] = Nil): List[String] =\n    if (e.hasMoreElements) enumToList(e, e.nextElement.asInstanceOf[String] :: list) else list\n\n  lazy val headers = enumToList(req.getHeaderNames).map { h =>\n    h -> enumToList(req.getHeaders(h))\n  }.toMap\n\n}\n\nabstract class ServletWrapper extends HttpServlet { wrapper =>\n  def handle(req: HttpRequest): Response\n\n  override def service(req: HttpServletRequest, resp: HttpServletResponse) = {\n    val t0 = System.currentTimeMillis\n    val vReq = try {\n      new JettyHttpRequest(req, resp)\n    } catch {\n      case e: Exception =>\n        throw e\n    }\n\n    val vResp = handle(vReq)\n\n    vReq.completionTasks.foreach(_ ())\n\n    resp.setStatus(vResp.code)\n    for ((n, v) <- vResp.headers) resp.addHeader(n, v)\n    for (rc <- vReq.responseCookies) {\n      val c = new Cookie(rc._1, rc._2)\n      c.setDomain(rc._3)\n      c.setMaxAge(rc._5 match {\n        case Some(t) => (t / 1000).toInt\n        case None => -1\n      })\n      c.setPath(rc._4)\n      c.setSecure(rc._6)\n      resp.addCookie(c)\n    }\n\n    val r = try {\n      vResp match {\n        case BufferResponse(_, _, ct, buffers) =>\n          resp.setContentType(ct.name)\n          val out = resp.getOutputStream\n          var spare: ByteBuffer = null\n          for (b <- buffers) {\n            if (b.hasArray) out.write(b.array, b.arrayOffset, b.limit)\n            else {\n              if (spare == null) spare = ByteBuffer.allocate(65536)\n              while (b.hasRemaining) {\n                spare.clear()\n                spare.put(b)\n                out.write(spare.array, 0, spare.position)\n              }\n            }\n          }\n          out.flush()\n\n        case sr @ StreamResponse(_, _, ct, send) =>\n          val enc = encodings.`UTF-8`\n          resp.setContentType(ct.name + \"; charset=\" + enc.name)\n          val w = new BufferedWriter(new OutputStreamWriter(resp.getOutputStream(), enc.name))\n          ensuring(new CharOutput(w))(send)\n\n        case sr @ ByteStreamResponse(_, _, ct, send) =>\n          resp.setContentType(ct.name)\n          val w = resp.getOutputStream()\n          ensuring(new ByteOutput(w))(send)\n\n        case ErrorResponse(code, _, message, _) =>\n          resp.sendError(code, message)\n\n        case FileResponse(_, _, ct, file) =>\n          resp.setContentType(ct.name)\n          resp.setContentLength(file.length.toInt)\n          val out = new ByteOutput(resp.getOutputStream)\n          file > out\n          out.flush()\n\n        case RedirectResponse(_, location) =>\n          resp.sendRedirect(location)\n      }\n    } catch {\n      case e: Exception =>\n        throw e\n    } finally {}\n    r\n  }\n}\n"
  },
  {
    "path": "http-json/shared/src/main/scala/rapture/http-json/handler.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.http\n\nimport rapture.json._\nimport rapture.data._\nimport rapture.mime._\nimport rapture.io._\nimport rapture.net._\nimport rapture.codec._, encodings.`UTF-8`._\n\npackage object jsonInterop {\n  implicit def jsonHttpHandler(implicit formatter: Formatter[JsonAst] { type Out = String }): HttpHandler[Json] =\n    new HttpHandler[Json] {\n      def response(j: Json): Response =\n        StreamResponse(200, Response.NoCache, MimeTypes.`application/json`, { os =>\n          Json.format(j).input[Char] > os\n          os.close()\n        })\n    }\n\n  implicit def jsonPostType(implicit formatter: Formatter[JsonAst] { type Out = String }): PostType[Json] =\n    new PostType[Json] {\n      def contentType = Some(MimeTypes.`application/json`)\n      def sender(content: Json): Input[Byte] =\n        Json.format(content).input[Byte]\n    }\n}\n"
  },
  {
    "path": "i18n/shared/src/main/scala/rapture/i18n/i18n.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.i18n\n\nimport scala.reflect.runtime.universe._\nimport language.implicitConversions\nimport scala.annotation._\nimport rapture.core._\nimport language.experimental.macros\nimport language.implicitConversions\n\nobject Locale {\n  implicit def upcastLocale[From <: Language, ToLang <: From](loc: Locale[From]): Locale[ToLang] =\n    loc.asInstanceOf[Locale[ToLang]]\n}\ncase class Locale[L <: Language: TypeTag]() {\n  val typeTag: TypeTag[L] = implicitly[TypeTag[L]]\n  val name = typeTag.tpe.toString.split(\"\\\\.\").last.toLowerCase\n  def from[T, L2 <: L](i18n: I18n[T, L2]) = i18n(typeTag)\n\n  def |[L2 <: Language](locale: Locale[L2]): LocaleParser[L with L2] =\n    new LocaleParser[L with L2](Map(name -> this, locale.name -> locale))\n\n  override def toString = name\n\n  implicit val defaultLanguage: DefaultLanguage[L] = DefaultLanguage[L](typeTag)\n}\n\ncase class LocaleException(locale: String) extends Exception(s\"Locale '$locale' not recognised.\")\n\nclass LocaleParser[L <: Language](val locales: Map[String, Locale[_ >: L <: Language]]) {\n  def |[L2 <: Language](locale: Locale[L2]) = new LocaleParser[L with L2](locales + (locale.name -> locale))\n\n  def parse(s: String)(implicit mode: Mode[_]): mode.Wrap[Locale[L], LocaleException] = mode.wrap {\n    locales.get(s.toLowerCase) match {\n      case Some(loc) => loc.asInstanceOf[Locale[L]]\n      case None => mode.exception(LocaleException(s))\n    }\n  }\n\n  override def toString = locales.keys.mkString(\"|\")\n}\n\nobject I18n {\n\n  implicit def upcast[ToLang <: Language, FromLang <: Language](from: I18n[String, FromLang]): I18n[String, ToLang] = macro Macros\n    .missingTranslationsMacro[ToLang, FromLang]\n\n  implicit def convertToType[T, L <: Language, L2 >: L <: Language: DefaultLanguage](i18n: I18n[T, L]): T =\n    i18n.map(implicitly[DefaultLanguage[L2]].tag.tpe)\n\n  class `I18n.apply`[L <: Language]() {\n    def apply[T](value: T)(implicit tt: TypeTag[L]) = {\n      new I18n[T, L](parentsOrSelf(tt.tpe).map(_ -> value).toMap)\n    }\n  }\n\n  def apply[L <: Language] = new `I18n.apply`[L]()\n}\n\n@implicitNotFound(\"This I18nString already includes the language ${Lang}.\")\nprivate[i18n] trait RequireLanguage[Lang]\nprivate[i18n] object RequireLanguage { implicit def requireLanguage: RequireLanguage[Language] = null }\n\nclass I18n[T, Languages <: Language](private val map: Map[Type, T]) {\n  def apply[Lang >: Languages](implicit tt: TypeTag[Lang]): T = map(tt.tpe)\n\n  final def &[L >: Languages <: Language, Lang2 <: L](s2: I18n[T, Lang2])(\n      implicit ev: RequireLanguage[L]): I18n[T, Languages with Lang2] =\n    new I18n[T, Languages with Lang2](map ++ s2.map)\n\n  override def toString = {\n    val langs = map.keys.map(_.toString.takeRight(2).toLowerCase).mkString(\"&\")\n    val content: Option[T] = map.get(implicitly[TypeTag[En]].tpe)\n    lazy val first: Option[T] = map.headOption.flatMap { case (k, v) => map.get(k) }\n    val value = content.orElse(first).map(_.toString).getOrElse(\"\") match {\n      case string: String => string\n      case other => s\"\"\"\"$other\"\"\"\"\n    }\n    s\"$langs:$value\"\n  }\n\n  override def hashCode = map.hashCode ^ 248327829\n\n  override def equals(that: Any) = that match {\n    case that: I18n[_, _] => map == that.map\n    case _ => false\n  }\n}\n\nobject I18nStringParam {\n  implicit def stringToStringParam[L <: Language](s: String): I18nStringParam[L] =\n    new I18nStringParam[L](new I18n[String, L](Map()) {\n      override def apply[Lang >: L](implicit tt: TypeTag[Lang]) = s\n    })\n\n  implicit def toI18nStringParam[L <: Language](s: I18n[String, L]): I18nStringParam[L] =\n    I18nStringParam(s)\n}\ncase class I18nStringParam[+L <: Language](i18n: I18n[String, L @annotation.unchecked.uncheckedVariance])\n    extends AnyVal\n\ntrait LanguageBundle[Langs <: Language] {\n  type IString = I18n[String, Langs]\n}\n"
  },
  {
    "path": "i18n/shared/src/main/scala/rapture/i18n/languages.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.i18n\n\nimport annotation.unchecked._\nimport scala.reflect.runtime.universe._\n\nobject languages {\n  object aa extends Locale[Aa]()\n  object ab extends Locale[Ab]()\n  object ae extends Locale[Ae]()\n  object af extends Locale[Af]()\n  object ak extends Locale[Ak]()\n  object am extends Locale[Am]()\n  object an extends Locale[An]()\n  object ar extends Locale[Ar]()\n  object as extends Locale[As]()\n  object av extends Locale[Av]()\n  object ay extends Locale[Ay]()\n  object az extends Locale[Az]()\n  object ba extends Locale[Ba]()\n  object be extends Locale[Be]()\n  object bg extends Locale[Bg]()\n  object bh extends Locale[Bh]()\n  object bi extends Locale[Bi]()\n  object bm extends Locale[Bm]()\n  object bn extends Locale[Bn]()\n  object bo extends Locale[Bo]()\n  object br extends Locale[Br]()\n  object bs extends Locale[Bs]()\n  object ca extends Locale[Ca]()\n  object ce extends Locale[Ce]()\n  object ch extends Locale[Ch]()\n  object co extends Locale[Co]()\n  object cr extends Locale[Cr]()\n  object cs extends Locale[Cs]()\n  object cu extends Locale[Cu]()\n  object cv extends Locale[Cv]()\n  object cy extends Locale[Cy]()\n  object da extends Locale[Da]()\n  object de extends Locale[De]()\n  object dv extends Locale[Dv]()\n  object dz extends Locale[Dz]()\n  object ee extends Locale[Ee]()\n  object el extends Locale[El]()\n  object en extends Locale[En]()\n  object eo extends Locale[Eo]()\n  object es extends Locale[Es]()\n  object et extends Locale[Et]()\n  object eu extends Locale[Eu]()\n  object fa extends Locale[Fa]()\n  object ff extends Locale[Ff]()\n  object fi extends Locale[Fi]()\n  object fj extends Locale[Fj]()\n  object fo extends Locale[Fo]()\n  object fr extends Locale[Fr]()\n  object fy extends Locale[Fy]()\n  object ga extends Locale[Ga]()\n  object gd extends Locale[Gd]()\n  object gl extends Locale[Gl]()\n  object gn extends Locale[Gn]()\n  object gu extends Locale[Gu]()\n  object gv extends Locale[Gv]()\n  object ha extends Locale[Ha]()\n  object he extends Locale[He]()\n  object hi extends Locale[Hi]()\n  object ho extends Locale[Ho]()\n  object hr extends Locale[Hr]()\n  object ht extends Locale[Ht]()\n  object hu extends Locale[Hu]()\n  object hy extends Locale[Hy]()\n  object hz extends Locale[Hz]()\n  object ia extends Locale[Ia]()\n  object id extends Locale[Id]()\n  object ie extends Locale[Ie]()\n  object ig extends Locale[Ig]()\n  object ii extends Locale[Ii]()\n  object ik extends Locale[Ik]()\n  object io extends Locale[Io]()\n  object is extends Locale[Is]()\n  object it extends Locale[It]()\n  object iu extends Locale[Iu]()\n  object ja extends Locale[Ja]()\n  object jv extends Locale[Jv]()\n  object ka extends Locale[Ka]()\n  object kg extends Locale[Kg]()\n  object ki extends Locale[Ki]()\n  object kj extends Locale[Kj]()\n  object kk extends Locale[Kk]()\n  object kl extends Locale[Kl]()\n  object km extends Locale[Km]()\n  object kn extends Locale[Kn]()\n  object ko extends Locale[Ko]()\n  object kr extends Locale[Kr]()\n  object ks extends Locale[Ks]()\n  object ku extends Locale[Ku]()\n  object kv extends Locale[Kv]()\n  object kw extends Locale[Kw]()\n  object ky extends Locale[Ky]()\n  object la extends Locale[La]()\n  object lb extends Locale[Lb]()\n  object lg extends Locale[Lg]()\n  object li extends Locale[Li]()\n  object ln extends Locale[Ln]()\n  object lo extends Locale[Lo]()\n  object lt extends Locale[Lt]()\n  object lu extends Locale[Lu]()\n  object lv extends Locale[Lv]()\n  object mg extends Locale[Mg]()\n  object mh extends Locale[Mh]()\n  object mi extends Locale[Mi]()\n  object mk extends Locale[Mk]()\n  object ml extends Locale[Ml]()\n  object mn extends Locale[Mn]()\n  object mr extends Locale[Mr]()\n  object ms extends Locale[Ms]()\n  object mt extends Locale[Mt]()\n  object my extends Locale[My]()\n  object na extends Locale[Na]()\n  object nb extends Locale[Nb]()\n  object nd extends Locale[Nd]()\n  object ne extends Locale[Ne]()\n  object ng extends Locale[Ng]()\n  object nl extends Locale[Nl]()\n  object nn extends Locale[Nn]()\n  object no extends Locale[No]()\n  object nr extends Locale[Nr]()\n  object nv extends Locale[Nv]()\n  object ny extends Locale[Ny]()\n  object oc extends Locale[Oc]()\n  object oj extends Locale[Oj]()\n  object om extends Locale[Om]()\n  object or extends Locale[Or]()\n  object os extends Locale[Os]()\n  object pa extends Locale[Pa]()\n  object pi extends Locale[Pi]()\n  object pl extends Locale[Pl]()\n  object ps extends Locale[Ps]()\n  object pt extends Locale[Pt]()\n  object qu extends Locale[Qu]()\n  object rm extends Locale[Rm]()\n  object rn extends Locale[Rn]()\n  object ro extends Locale[Ro]()\n  object ru extends Locale[Ru]()\n  object rw extends Locale[Rw]()\n  object sa extends Locale[Sa]()\n  object sc extends Locale[Sc]()\n  object sd extends Locale[Sd]()\n  object se extends Locale[Se]()\n  object sg extends Locale[Sg]()\n  object si extends Locale[Si]()\n  object sk extends Locale[Sk]()\n  object sl extends Locale[Sl]()\n  object sm extends Locale[Sm]()\n  object sn extends Locale[Sn]()\n  object so extends Locale[So]()\n  object sq extends Locale[Sq]()\n  object sr extends Locale[Sr]()\n  object ss extends Locale[Ss]()\n  object st extends Locale[St]()\n  object su extends Locale[Su]()\n  object sv extends Locale[Sv]()\n  object sw extends Locale[Sw]()\n  object ta extends Locale[Ta]()\n  object te extends Locale[Te]()\n  object tg extends Locale[Tg]()\n  object th extends Locale[Th]()\n  object ti extends Locale[Ti]()\n  object tk extends Locale[Tk]()\n  object tl extends Locale[Tl]()\n  object tn extends Locale[Tn]()\n  object to extends Locale[To]()\n  object tr extends Locale[Tr]()\n  object ts extends Locale[Ts]()\n  object tt extends Locale[Tt]()\n  object tw extends Locale[Tw]()\n  object ty extends Locale[Ty]()\n  object ug extends Locale[Ug]()\n  object uk extends Locale[Uk]()\n  object ur extends Locale[Ur]()\n  object uz extends Locale[Uz]()\n  object ve extends Locale[Ve]()\n  object vi extends Locale[Vi]()\n  object vo extends Locale[Vo]()\n  object wa extends Locale[Wa]()\n  object wo extends Locale[Wo]()\n  object xh extends Locale[Xh]()\n  object yi extends Locale[Yi]()\n  object yo extends Locale[Yo]()\n  object za extends Locale[Za]()\n  object zh extends Locale[Zh]()\n  object zu extends Locale[Zu]()\n}\n\ncase class DefaultLanguage[-L <: Language](tag: TypeTag[L @uncheckedVariance])\n\ntrait Language\nfinal class Aa extends Language\nfinal class Ab extends Language\nfinal class Ae extends Language\nfinal class Af extends Language\nfinal class Ak extends Language\nfinal class Am extends Language\nfinal class An extends Language\nfinal class Ar extends Language\nfinal class As extends Language\nfinal class Av extends Language\nfinal class Ay extends Language\nfinal class Az extends Language\nfinal class Ba extends Language\nfinal class Be extends Language\nfinal class Bg extends Language\nfinal class Bh extends Language\nfinal class Bi extends Language\nfinal class Bm extends Language\nfinal class Bn extends Language\nfinal class Bo extends Language\nfinal class Br extends Language\nfinal class Bs extends Language\nfinal class Ca extends Language\nfinal class Ce extends Language\nfinal class Ch extends Language\nfinal class Co extends Language\nfinal class Cr extends Language\nfinal class Cs extends Language\nfinal class Cu extends Language\nfinal class Cv extends Language\nfinal class Cy extends Language\nfinal class Da extends Language\nfinal class De extends Language\nfinal class Dv extends Language\nfinal class Dz extends Language\nfinal class Ee extends Language\nfinal class El extends Language\nfinal class En extends Language\nfinal class Eo extends Language\nfinal class Es extends Language\nfinal class Et extends Language\nfinal class Eu extends Language\nfinal class Fa extends Language\nfinal class Ff extends Language\nfinal class Fi extends Language\nfinal class Fj extends Language\nfinal class Fo extends Language\nfinal class Fr extends Language\nfinal class Fy extends Language\nfinal class Ga extends Language\nfinal class Gd extends Language\nfinal class Gl extends Language\nfinal class Gn extends Language\nfinal class Gu extends Language\nfinal class Gv extends Language\nfinal class Ha extends Language\nfinal class He extends Language\nfinal class Hi extends Language\nfinal class Ho extends Language\nfinal class Hr extends Language\nfinal class Ht extends Language\nfinal class Hu extends Language\nfinal class Hy extends Language\nfinal class Hz extends Language\nfinal class Ia extends Language\nfinal class Id extends Language\nfinal class Ie extends Language\nfinal class Ig extends Language\nfinal class Ii extends Language\nfinal class Ik extends Language\nfinal class Io extends Language\nfinal class Is extends Language\nfinal class It extends Language\nfinal class Iu extends Language\nfinal class Ja extends Language\nfinal class Jv extends Language\nfinal class Ka extends Language\nfinal class Kg extends Language\nfinal class Ki extends Language\nfinal class Kj extends Language\nfinal class Kk extends Language\nfinal class Kl extends Language\nfinal class Km extends Language\nfinal class Kn extends Language\nfinal class Ko extends Language\nfinal class Kr extends Language\nfinal class Ks extends Language\nfinal class Ku extends Language\nfinal class Kv extends Language\nfinal class Kw extends Language\nfinal class Ky extends Language\nfinal class La extends Language\nfinal class Lb extends Language\nfinal class Lg extends Language\nfinal class Li extends Language\nfinal class Ln extends Language\nfinal class Lo extends Language\nfinal class Lt extends Language\nfinal class Lu extends Language\nfinal class Lv extends Language\nfinal class Mg extends Language\nfinal class Mh extends Language\nfinal class Mi extends Language\nfinal class Mk extends Language\nfinal class Ml extends Language\nfinal class Mn extends Language\nfinal class Mr extends Language\nfinal class Ms extends Language\nfinal class Mt extends Language\nfinal class My extends Language\nfinal class Na extends Language\nfinal class Nb extends Language\nfinal class Nd extends Language\nfinal class Ne extends Language\nfinal class Ng extends Language\nfinal class Nl extends Language\nfinal class Nn extends Language\nfinal class No extends Language\nfinal class Nr extends Language\nfinal class Nv extends Language\nfinal class Ny extends Language\nfinal class Oc extends Language\nfinal class Oj extends Language\nfinal class Om extends Language\nfinal class Or extends Language\nfinal class Os extends Language\nfinal class Pa extends Language\nfinal class Pi extends Language\nfinal class Pl extends Language\nfinal class Ps extends Language\nfinal class Pt extends Language\nfinal class Qu extends Language\nfinal class Rm extends Language\nfinal class Rn extends Language\nfinal class Ro extends Language\nfinal class Ru extends Language\nfinal class Rw extends Language\nfinal class Sa extends Language\nfinal class Sc extends Language\nfinal class Sd extends Language\nfinal class Se extends Language\nfinal class Sg extends Language\nfinal class Si extends Language\nfinal class Sk extends Language\nfinal class Sl extends Language\nfinal class Sm extends Language\nfinal class Sn extends Language\nfinal class So extends Language\nfinal class Sq extends Language\nfinal class Sr extends Language\nfinal class Ss extends Language\nfinal class St extends Language\nfinal class Su extends Language\nfinal class Sv extends Language\nfinal class Sw extends Language\nfinal class Ta extends Language\nfinal class Te extends Language\nfinal class Tg extends Language\nfinal class Th extends Language\nfinal class Ti extends Language\nfinal class Tk extends Language\nfinal class Tl extends Language\nfinal class Tn extends Language\nfinal class To extends Language\nfinal class Tr extends Language\nfinal class Ts extends Language\nfinal class Tt extends Language\nfinal class Tw extends Language\nfinal class Ty extends Language\nfinal class Ug extends Language\nfinal class Uk extends Language\nfinal class Ur extends Language\nfinal class Uz extends Language\nfinal class Ve extends Language\nfinal class Vi extends Language\nfinal class Vo extends Language\nfinal class Wa extends Language\nfinal class Wo extends Language\nfinal class Xh extends Language\nfinal class Yi extends Language\nfinal class Yo extends Language\nfinal class Za extends Language\nfinal class Zh extends Language\nfinal class Zu extends Language\n"
  },
  {
    "path": "i18n/shared/src/main/scala/rapture/i18n/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.i18n\n\nimport rapture.base._\n\n\nimport language.implicitConversions\nimport scala.reflect.runtime.universe._\n\nobject `package` {\n\n  def parentsOrSelf(t: Type): List[Type] = t match {\n    case RefinedType(parents, _) => parents\n    case other => other :: Nil\n  }\n\n  implicit def i18nStringToString[L <: Language](msg: I18n[String, L])\n      (implicit locale: Locale[_ >: L]): String = locale.from(msg)\n  \n  implicit class I18nEnrichedStringContext(sc: StringContext) {\n    \n    private def context[L <: Language: TypeTag](sc: StringContext, params: List[I18nStringParam[L]]):\n        I18n[String, L] =\n      new I18n[String, L](parentsOrSelf(implicitly[TypeTag[L]].tpe).map(_ -> sc.parts.zip(params.map(_.i18n.apply[L]) :+ \"\").map {\n        case (a, b) => a+b\n      }.mkString).toMap)\n\n    def aa(params: I18nStringParam[Aa]*): I18n[String, Aa] = context[Aa](sc, params.toList)\n    def ab(params: I18nStringParam[Ab]*): I18n[String, Ab] = context[Ab](sc, params.toList)\n    def ae(params: I18nStringParam[Ae]*): I18n[String, Ae] = context[Ae](sc, params.toList)\n    def af(params: I18nStringParam[Af]*): I18n[String, Af] = context[Af](sc, params.toList)\n    def ak(params: I18nStringParam[Ak]*): I18n[String, Ak] = context[Ak](sc, params.toList)\n    def am(params: I18nStringParam[Am]*): I18n[String, Am] = context[Am](sc, params.toList)\n    def an(params: I18nStringParam[An]*): I18n[String, An] = context[An](sc, params.toList)\n    def ar(params: I18nStringParam[Ar]*): I18n[String, Ar] = context[Ar](sc, params.toList)\n    def as(params: I18nStringParam[As]*): I18n[String, As] = context[As](sc, params.toList)\n    def av(params: I18nStringParam[Av]*): I18n[String, Av] = context[Av](sc, params.toList)\n    def ay(params: I18nStringParam[Ay]*): I18n[String, Ay] = context[Ay](sc, params.toList)\n    def az(params: I18nStringParam[Az]*): I18n[String, Az] = context[Az](sc, params.toList)\n    def ba(params: I18nStringParam[Ba]*): I18n[String, Ba] = context[Ba](sc, params.toList)\n    def be(params: I18nStringParam[Be]*): I18n[String, Be] = context[Be](sc, params.toList)\n    def bg(params: I18nStringParam[Bg]*): I18n[String, Bg] = context[Bg](sc, params.toList)\n    def bh(params: I18nStringParam[Bh]*): I18n[String, Bh] = context[Bh](sc, params.toList)\n    def bi(params: I18nStringParam[Bi]*): I18n[String, Bi] = context[Bi](sc, params.toList)\n    def bm(params: I18nStringParam[Bm]*): I18n[String, Bm] = context[Bm](sc, params.toList)\n    def bn(params: I18nStringParam[Bn]*): I18n[String, Bn] = context[Bn](sc, params.toList)\n    def bo(params: I18nStringParam[Bo]*): I18n[String, Bo] = context[Bo](sc, params.toList)\n    def br(params: I18nStringParam[Br]*): I18n[String, Br] = context[Br](sc, params.toList)\n    def bs(params: I18nStringParam[Bs]*): I18n[String, Bs] = context[Bs](sc, params.toList)\n    def ca(params: I18nStringParam[Ca]*): I18n[String, Ca] = context[Ca](sc, params.toList)\n    def ce(params: I18nStringParam[Ce]*): I18n[String, Ce] = context[Ce](sc, params.toList)\n    def ch(params: I18nStringParam[Ch]*): I18n[String, Ch] = context[Ch](sc, params.toList)\n    def co(params: I18nStringParam[Co]*): I18n[String, Co] = context[Co](sc, params.toList)\n    def cr(params: I18nStringParam[Cr]*): I18n[String, Cr] = context[Cr](sc, params.toList)\n    def cs(params: I18nStringParam[Cs]*): I18n[String, Cs] = context[Cs](sc, params.toList)\n    def cu(params: I18nStringParam[Cu]*): I18n[String, Cu] = context[Cu](sc, params.toList)\n    def cv(params: I18nStringParam[Cv]*): I18n[String, Cv] = context[Cv](sc, params.toList)\n    def cy(params: I18nStringParam[Cy]*): I18n[String, Cy] = context[Cy](sc, params.toList)\n    def da(params: I18nStringParam[Da]*): I18n[String, Da] = context[Da](sc, params.toList)\n    def de(params: I18nStringParam[De]*): I18n[String, De] = context[De](sc, params.toList)\n    def dv(params: I18nStringParam[Dv]*): I18n[String, Dv] = context[Dv](sc, params.toList)\n    def dz(params: I18nStringParam[Dz]*): I18n[String, Dz] = context[Dz](sc, params.toList)\n    def ee(params: I18nStringParam[Ee]*): I18n[String, Ee] = context[Ee](sc, params.toList)\n    def el(params: I18nStringParam[El]*): I18n[String, El] = context[El](sc, params.toList)\n    def en(params: I18nStringParam[En]*): I18n[String, En] = context[En](sc, params.toList)\n    def eo(params: I18nStringParam[Eo]*): I18n[String, Eo] = context[Eo](sc, params.toList)\n    def es(params: I18nStringParam[Es]*): I18n[String, Es] = context[Es](sc, params.toList)\n    def et(params: I18nStringParam[Et]*): I18n[String, Et] = context[Et](sc, params.toList)\n    def eu(params: I18nStringParam[Eu]*): I18n[String, Eu] = context[Eu](sc, params.toList)\n    def fa(params: I18nStringParam[Fa]*): I18n[String, Fa] = context[Fa](sc, params.toList)\n    def ff(params: I18nStringParam[Ff]*): I18n[String, Ff] = context[Ff](sc, params.toList)\n    def fi(params: I18nStringParam[Fi]*): I18n[String, Fi] = context[Fi](sc, params.toList)\n    def fj(params: I18nStringParam[Fj]*): I18n[String, Fj] = context[Fj](sc, params.toList)\n    def fo(params: I18nStringParam[Fo]*): I18n[String, Fo] = context[Fo](sc, params.toList)\n    def fr(params: I18nStringParam[Fr]*): I18n[String, Fr] = context[Fr](sc, params.toList)\n    def fy(params: I18nStringParam[Fy]*): I18n[String, Fy] = context[Fy](sc, params.toList)\n    def ga(params: I18nStringParam[Ga]*): I18n[String, Ga] = context[Ga](sc, params.toList)\n    def gd(params: I18nStringParam[Gd]*): I18n[String, Gd] = context[Gd](sc, params.toList)\n    def gl(params: I18nStringParam[Gl]*): I18n[String, Gl] = context[Gl](sc, params.toList)\n    def gn(params: I18nStringParam[Gn]*): I18n[String, Gn] = context[Gn](sc, params.toList)\n    def gu(params: I18nStringParam[Gu]*): I18n[String, Gu] = context[Gu](sc, params.toList)\n    def gv(params: I18nStringParam[Gv]*): I18n[String, Gv] = context[Gv](sc, params.toList)\n    def ha(params: I18nStringParam[Ha]*): I18n[String, Ha] = context[Ha](sc, params.toList)\n    def he(params: I18nStringParam[He]*): I18n[String, He] = context[He](sc, params.toList)\n    def hi(params: I18nStringParam[Hi]*): I18n[String, Hi] = context[Hi](sc, params.toList)\n    def ho(params: I18nStringParam[Ho]*): I18n[String, Ho] = context[Ho](sc, params.toList)\n    def hr(params: I18nStringParam[Hr]*): I18n[String, Hr] = context[Hr](sc, params.toList)\n    def ht(params: I18nStringParam[Ht]*): I18n[String, Ht] = context[Ht](sc, params.toList)\n    def hu(params: I18nStringParam[Hu]*): I18n[String, Hu] = context[Hu](sc, params.toList)\n    def hy(params: I18nStringParam[Hy]*): I18n[String, Hy] = context[Hy](sc, params.toList)\n    def hz(params: I18nStringParam[Hz]*): I18n[String, Hz] = context[Hz](sc, params.toList)\n    def ia(params: I18nStringParam[Ia]*): I18n[String, Ia] = context[Ia](sc, params.toList)\n    def id(params: I18nStringParam[Id]*): I18n[String, Id] = context[Id](sc, params.toList)\n    def ie(params: I18nStringParam[Ie]*): I18n[String, Ie] = context[Ie](sc, params.toList)\n    def ig(params: I18nStringParam[Ig]*): I18n[String, Ig] = context[Ig](sc, params.toList)\n    def ii(params: I18nStringParam[Ii]*): I18n[String, Ii] = context[Ii](sc, params.toList)\n    def ik(params: I18nStringParam[Ik]*): I18n[String, Ik] = context[Ik](sc, params.toList)\n    def io(params: I18nStringParam[Io]*): I18n[String, Io] = context[Io](sc, params.toList)\n    def is(params: I18nStringParam[Is]*): I18n[String, Is] = context[Is](sc, params.toList)\n    def it(params: I18nStringParam[It]*): I18n[String, It] = context[It](sc, params.toList)\n    def iu(params: I18nStringParam[Iu]*): I18n[String, Iu] = context[Iu](sc, params.toList)\n    def ja(params: I18nStringParam[Ja]*): I18n[String, Ja] = context[Ja](sc, params.toList)\n    def jv(params: I18nStringParam[Jv]*): I18n[String, Jv] = context[Jv](sc, params.toList)\n    def ka(params: I18nStringParam[Ka]*): I18n[String, Ka] = context[Ka](sc, params.toList)\n    def kg(params: I18nStringParam[Kg]*): I18n[String, Kg] = context[Kg](sc, params.toList)\n    def ki(params: I18nStringParam[Ki]*): I18n[String, Ki] = context[Ki](sc, params.toList)\n    def kj(params: I18nStringParam[Kj]*): I18n[String, Kj] = context[Kj](sc, params.toList)\n    def kk(params: I18nStringParam[Kk]*): I18n[String, Kk] = context[Kk](sc, params.toList)\n    def kl(params: I18nStringParam[Kl]*): I18n[String, Kl] = context[Kl](sc, params.toList)\n    def km(params: I18nStringParam[Km]*): I18n[String, Km] = context[Km](sc, params.toList)\n    def kn(params: I18nStringParam[Kn]*): I18n[String, Kn] = context[Kn](sc, params.toList)\n    def ko(params: I18nStringParam[Ko]*): I18n[String, Ko] = context[Ko](sc, params.toList)\n    def kr(params: I18nStringParam[Kr]*): I18n[String, Kr] = context[Kr](sc, params.toList)\n    def ks(params: I18nStringParam[Ks]*): I18n[String, Ks] = context[Ks](sc, params.toList)\n    def ku(params: I18nStringParam[Ku]*): I18n[String, Ku] = context[Ku](sc, params.toList)\n    def kv(params: I18nStringParam[Kv]*): I18n[String, Kv] = context[Kv](sc, params.toList)\n    def kw(params: I18nStringParam[Kw]*): I18n[String, Kw] = context[Kw](sc, params.toList)\n    def ky(params: I18nStringParam[Ky]*): I18n[String, Ky] = context[Ky](sc, params.toList)\n    def la(params: I18nStringParam[La]*): I18n[String, La] = context[La](sc, params.toList)\n    def lb(params: I18nStringParam[Lb]*): I18n[String, Lb] = context[Lb](sc, params.toList)\n    def lg(params: I18nStringParam[Lg]*): I18n[String, Lg] = context[Lg](sc, params.toList)\n    def li(params: I18nStringParam[Li]*): I18n[String, Li] = context[Li](sc, params.toList)\n    def ln(params: I18nStringParam[Ln]*): I18n[String, Ln] = context[Ln](sc, params.toList)\n    def lo(params: I18nStringParam[Lo]*): I18n[String, Lo] = context[Lo](sc, params.toList)\n    def lt(params: I18nStringParam[Lt]*): I18n[String, Lt] = context[Lt](sc, params.toList)\n    def lu(params: I18nStringParam[Lu]*): I18n[String, Lu] = context[Lu](sc, params.toList)\n    def lv(params: I18nStringParam[Lv]*): I18n[String, Lv] = context[Lv](sc, params.toList)\n    def mg(params: I18nStringParam[Mg]*): I18n[String, Mg] = context[Mg](sc, params.toList)\n    def mh(params: I18nStringParam[Mh]*): I18n[String, Mh] = context[Mh](sc, params.toList)\n    def mi(params: I18nStringParam[Mi]*): I18n[String, Mi] = context[Mi](sc, params.toList)\n    def mk(params: I18nStringParam[Mk]*): I18n[String, Mk] = context[Mk](sc, params.toList)\n    def ml(params: I18nStringParam[Ml]*): I18n[String, Ml] = context[Ml](sc, params.toList)\n    def mn(params: I18nStringParam[Mn]*): I18n[String, Mn] = context[Mn](sc, params.toList)\n    def mr(params: I18nStringParam[Mr]*): I18n[String, Mr] = context[Mr](sc, params.toList)\n    def ms(params: I18nStringParam[Ms]*): I18n[String, Ms] = context[Ms](sc, params.toList)\n    def mt(params: I18nStringParam[Mt]*): I18n[String, Mt] = context[Mt](sc, params.toList)\n    def my(params: I18nStringParam[My]*): I18n[String, My] = context[My](sc, params.toList)\n    def na(params: I18nStringParam[Na]*): I18n[String, Na] = context[Na](sc, params.toList)\n    def nb(params: I18nStringParam[Nb]*): I18n[String, Nb] = context[Nb](sc, params.toList)\n    def nd(params: I18nStringParam[Nd]*): I18n[String, Nd] = context[Nd](sc, params.toList)\n    def ne(params: I18nStringParam[Ne]*): I18n[String, Ne] = context[Ne](sc, params.toList)\n    def ng(params: I18nStringParam[Ng]*): I18n[String, Ng] = context[Ng](sc, params.toList)\n    def nl(params: I18nStringParam[Nl]*): I18n[String, Nl] = context[Nl](sc, params.toList)\n    def nn(params: I18nStringParam[Nn]*): I18n[String, Nn] = context[Nn](sc, params.toList)\n    def no(params: I18nStringParam[No]*): I18n[String, No] = context[No](sc, params.toList)\n    def nr(params: I18nStringParam[Nr]*): I18n[String, Nr] = context[Nr](sc, params.toList)\n    def nv(params: I18nStringParam[Nv]*): I18n[String, Nv] = context[Nv](sc, params.toList)\n    def ny(params: I18nStringParam[Ny]*): I18n[String, Ny] = context[Ny](sc, params.toList)\n    def oc(params: I18nStringParam[Oc]*): I18n[String, Oc] = context[Oc](sc, params.toList)\n    def oj(params: I18nStringParam[Oj]*): I18n[String, Oj] = context[Oj](sc, params.toList)\n    def om(params: I18nStringParam[Om]*): I18n[String, Om] = context[Om](sc, params.toList)\n    def or(params: I18nStringParam[Or]*): I18n[String, Or] = context[Or](sc, params.toList)\n    def os(params: I18nStringParam[Os]*): I18n[String, Os] = context[Os](sc, params.toList)\n    def pa(params: I18nStringParam[Pa]*): I18n[String, Pa] = context[Pa](sc, params.toList)\n    def pi(params: I18nStringParam[Pi]*): I18n[String, Pi] = context[Pi](sc, params.toList)\n    def pl(params: I18nStringParam[Pl]*): I18n[String, Pl] = context[Pl](sc, params.toList)\n    def ps(params: I18nStringParam[Ps]*): I18n[String, Ps] = context[Ps](sc, params.toList)\n    def pt(params: I18nStringParam[Pt]*): I18n[String, Pt] = context[Pt](sc, params.toList)\n    def qu(params: I18nStringParam[Qu]*): I18n[String, Qu] = context[Qu](sc, params.toList)\n    def rm(params: I18nStringParam[Rm]*): I18n[String, Rm] = context[Rm](sc, params.toList)\n    def rn(params: I18nStringParam[Rn]*): I18n[String, Rn] = context[Rn](sc, params.toList)\n    def ro(params: I18nStringParam[Ro]*): I18n[String, Ro] = context[Ro](sc, params.toList)\n    def ru(params: I18nStringParam[Ru]*): I18n[String, Ru] = context[Ru](sc, params.toList)\n    def rw(params: I18nStringParam[Rw]*): I18n[String, Rw] = context[Rw](sc, params.toList)\n    def sa(params: I18nStringParam[Sa]*): I18n[String, Sa] = context[Sa](sc, params.toList)\n    def sc(params: I18nStringParam[Sc]*): I18n[String, Sc] = context[Sc](sc, params.toList)\n    def sd(params: I18nStringParam[Sd]*): I18n[String, Sd] = context[Sd](sc, params.toList)\n    def se(params: I18nStringParam[Se]*): I18n[String, Se] = context[Se](sc, params.toList)\n    def sg(params: I18nStringParam[Sg]*): I18n[String, Sg] = context[Sg](sc, params.toList)\n    def si(params: I18nStringParam[Si]*): I18n[String, Si] = context[Si](sc, params.toList)\n    def sk(params: I18nStringParam[Sk]*): I18n[String, Sk] = context[Sk](sc, params.toList)\n    def sl(params: I18nStringParam[Sl]*): I18n[String, Sl] = context[Sl](sc, params.toList)\n    def sm(params: I18nStringParam[Sm]*): I18n[String, Sm] = context[Sm](sc, params.toList)\n    def sn(params: I18nStringParam[Sn]*): I18n[String, Sn] = context[Sn](sc, params.toList)\n    def so(params: I18nStringParam[So]*): I18n[String, So] = context[So](sc, params.toList)\n    def sq(params: I18nStringParam[Sq]*): I18n[String, Sq] = context[Sq](sc, params.toList)\n    def sr(params: I18nStringParam[Sr]*): I18n[String, Sr] = context[Sr](sc, params.toList)\n    def ss(params: I18nStringParam[Ss]*): I18n[String, Ss] = context[Ss](sc, params.toList)\n    def st(params: I18nStringParam[St]*): I18n[String, St] = context[St](sc, params.toList)\n    def su(params: I18nStringParam[Su]*): I18n[String, Su] = context[Su](sc, params.toList)\n    def sv(params: I18nStringParam[Sv]*): I18n[String, Sv] = context[Sv](sc, params.toList)\n    def sw(params: I18nStringParam[Sw]*): I18n[String, Sw] = context[Sw](sc, params.toList)\n    def ta(params: I18nStringParam[Ta]*): I18n[String, Ta] = context[Ta](sc, params.toList)\n    def te(params: I18nStringParam[Te]*): I18n[String, Te] = context[Te](sc, params.toList)\n    def tg(params: I18nStringParam[Tg]*): I18n[String, Tg] = context[Tg](sc, params.toList)\n    def th(params: I18nStringParam[Th]*): I18n[String, Th] = context[Th](sc, params.toList)\n    def ti(params: I18nStringParam[Ti]*): I18n[String, Ti] = context[Ti](sc, params.toList)\n    def tk(params: I18nStringParam[Tk]*): I18n[String, Tk] = context[Tk](sc, params.toList)\n    def tl(params: I18nStringParam[Tl]*): I18n[String, Tl] = context[Tl](sc, params.toList)\n    def tn(params: I18nStringParam[Tn]*): I18n[String, Tn] = context[Tn](sc, params.toList)\n    def to(params: I18nStringParam[To]*): I18n[String, To] = context[To](sc, params.toList)\n    def tr(params: I18nStringParam[Tr]*): I18n[String, Tr] = context[Tr](sc, params.toList)\n    def ts(params: I18nStringParam[Ts]*): I18n[String, Ts] = context[Ts](sc, params.toList)\n    def tt(params: I18nStringParam[Tt]*): I18n[String, Tt] = context[Tt](sc, params.toList)\n    def tw(params: I18nStringParam[Tw]*): I18n[String, Tw] = context[Tw](sc, params.toList)\n    def ty(params: I18nStringParam[Ty]*): I18n[String, Ty] = context[Ty](sc, params.toList)\n    def ug(params: I18nStringParam[Ug]*): I18n[String, Ug] = context[Ug](sc, params.toList)\n    def uk(params: I18nStringParam[Uk]*): I18n[String, Uk] = context[Uk](sc, params.toList)\n    def ur(params: I18nStringParam[Ur]*): I18n[String, Ur] = context[Ur](sc, params.toList)\n    def uz(params: I18nStringParam[Uz]*): I18n[String, Uz] = context[Uz](sc, params.toList)\n    def ve(params: I18nStringParam[Ve]*): I18n[String, Ve] = context[Ve](sc, params.toList)\n    def vi(params: I18nStringParam[Vi]*): I18n[String, Vi] = context[Vi](sc, params.toList)\n    def vo(params: I18nStringParam[Vo]*): I18n[String, Vo] = context[Vo](sc, params.toList)\n    def wa(params: I18nStringParam[Wa]*): I18n[String, Wa] = context[Wa](sc, params.toList)\n    def wo(params: I18nStringParam[Wo]*): I18n[String, Wo] = context[Wo](sc, params.toList)\n    def xh(params: I18nStringParam[Xh]*): I18n[String, Xh] = context[Xh](sc, params.toList)\n    def yi(params: I18nStringParam[Yi]*): I18n[String, Yi] = context[Yi](sc, params.toList)\n    def yo(params: I18nStringParam[Yo]*): I18n[String, Yo] = context[Yo](sc, params.toList)\n    def za(params: I18nStringParam[Za]*): I18n[String, Za] = context[Za](sc, params.toList)\n    def zh(params: I18nStringParam[Zh]*): I18n[String, Zh] = context[Zh](sc, params.toList)\n    def zu(params: I18nStringParam[Zu]*): I18n[String, Zu] = context[Zu](sc, params.toList)\n  }\n\n}\n\nobject Macros {\n  \n  def missingTranslationsMacro[ToLang <: Language: c.WeakTypeTag, FromLang <: Language: c.WeakTypeTag](c:\n      BlackboxContext)(from: c.Expr[I18n[String, FromLang]]): c.Expr[I18n[String, ToLang]] = {\n    \n    import c.universe._\n    import compatibility._\n\n    val fromLangs = (normalize(c)(weakTypeOf[FromLang]) match {\n      case rt: RefinedType => rt.parents\n      case typ: Type => List(typ)\n    }).map(_.toString.split(\"\\\\.\").last.toLowerCase).to[Set]\n\n    val toLangs = (normalize(c)(weakTypeOf[ToLang]) match {\n      case rt: RefinedType => rt.parents\n      case typ: Type => List(typ)\n    }).map(_.toString.split(\"\\\\.\").last.toLowerCase).to[Set]\n\n    val missing = toLangs -- fromLangs\n\n    def langs(tree: Tree): Map[String, String] = tree match {\n      case Apply(Select(Apply(Select(Select(Select(id1, id2), id3), id4), List(Apply(_, List(Literal(Constant(\n          str: String)))))), lang), _) if id1.toString == \"rapture\" && id2.toString == \"i18n\" &&\n          id3.toString == \"package\" && id4.toString == \"I18nEnrichedStringContext\" =>\n        \n        Map(lang.toString -> str)\n      \n      case Apply(app: Apply, _) =>\n        langs(app)\n      \n      case Apply(TypeApply(Select(q, id6), _), List(app)) if id6.toString == \"$bar\" =>\n        langs(q) ++ langs(app)\n    }\n\n    if(!missing.isEmpty)\n      c.abort(c.enclosingPosition, s\"\"\"Some language translations were not provided: ${missing.mkString(\", \")}\"\"\")\n    else\n      reify(from.splice.asInstanceOf[I18n[String, ToLang]])\n  }\n}\n"
  },
  {
    "path": "i18n/shared/src/test/scala/rapture/i18n/tests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.i18n.test\n\nimport rapture.i18n._\nimport rapture.test._\nimport rapture.core._\n\nclass TestRun extends Programme {\n  include(I18nTests)\n}\n\nobject I18nTests extends TestSuite {\n\n  import languages._\n\n  val `Create basic English string` = test {\n    val greetingEn: I18n[String, En] = en\"Hello world\"\n    greetingEn[En]\n  } returns \"Hello world\"\n\n  val `Create basic French string` = test {\n    val greetingFr: I18n[String, Fr] = fr\"Bonjour le monde\"\n    greetingFr[Fr]\n  } returns \"Bonjour le monde\"\n  \n  val `Create combined internationalized strings, getting English` = test {\n    val greeting = en\"Hello world\" & fr\"Bonjour le monde\"\n    greeting[En]\n  } returns \"Hello world\"\n\n  val `Create combined internationalized strings, getting French` = test {\n    val greeting = en\"Hello world\" & fr\"Bonjour le monde\"\n    greeting[Fr]\n  } returns \"Bonjour le monde\"\n\n  val `Check providing surplus language definitions allowed` = test {\n    val greeting = en\"Hello world\" & fr\"Bonjour le monde\"\n    val en: I18n[String, En] = greeting\n    val fr: I18n[String, Fr] = greeting\n    val both: I18n[String, En with Fr] = greeting\n  }.returns(())\n\n  val `Check internationalized substitution` = test {\n    val greeting = en\"Hello world\" & fr\"Bonjour le monde\"\n    val msg = en\"In English, we say '$greeting'\"\n    msg[En]\n  } returns \"In English, we say 'Hello world'\"\n\n  val `Check internationalized substitution (French)` = test {\n    val greeting = en\"Hello world\" & fr\"Bonjour le monde\"\n    val msg = fr\"En français, on dit '$greeting'\"\n    msg[Fr]\n  } returns \"En français, on dit 'Bonjour le monde'\"\n\n  val `Substitute ordinary string` = test {\n    val lang = \"Scala\"\n    val msg = en\"I speak $lang.\" & fr\"Je parle $lang.\" & de\"Ich spreche $lang.\"\n    msg[De]\n  } returns \"Ich spreche Scala.\"\n\n\n  object MyMessages extends LanguageBundle[En with Fr] {\n    val greeting: IString = en\"Hello world\" & fr\"Bonjour le monde\"\n  }\n\n  val `Test message bundle` = test {\n    MyMessages.greeting[En]\n  } returns \"Hello world\"\n\n  val `Test message bundle (French)` = test {\n    MyMessages.greeting[Fr]\n  } returns \"Bonjour le monde\"\n\n  val `Use default language` = test {\n    import languages.fr._\n    val str: String = MyMessages.greeting\n    str\n  } returns \"Bonjour le monde\"\n\n  val `Adding existing language does not compile` = test {\n    typeMismatch {\n      import deferTypeErrors._\n      en\"a\" & fr\"b\" & en\"c\"\n    }\n  } returns true\n\n  val `Adding existing language does not compile (2)` = test {\n    typeMismatch {\n      import deferTypeErrors._\n      (en\"a\" & fr\"b\") & (de\"c\" & en\"d\")\n    }\n  } returns true\n\n  val `Get language string using runtime value` = test {\n    val msg = en\"Hello\" & fr\"Bonjour\"\n    val langs = en | fr\n    implicit val loc = langs.parse(\"FR\")\n    msg: String\n  } returns \"Bonjour\"\n\n  val `Get language string from subset using runtime value` = test {\n    typeMismatch {\n      import deferTypeErrors._\n      val msg = en\"Hello\" & fr\"Bonjour\"\n      val langs = en | fr | de\n      implicit val loc = langs.parse(\"FR\")\n      msg: String\n    }\n  } returns true\n\n  val `Get language string from superset using runtime value` = test {\n    val msg = en\"Hello\" & fr\"Bonjour\" & de\"Hallo\"\n    val langs = en | fr\n    implicit val loc = langs.parse(\"FR\")\n    msg: String\n  } returns \"Bonjour\"\n\n  val `Get both parent languages from a refined-type i18n` = test {\n    val msg = I18n[En with Fr](\"biscuit\")\n    (msg[En], msg[Fr])\n  } returns ((\"biscuit\", \"biscuit\"))\n\n  val `Refined-type i18n can be combined like others` = test {\n    val msg = I18n[En with Fr](\"biscuit\") & de\"german biscuit\"\n    (msg[En], msg[Fr], msg[De])\n  } returns ((\"biscuit\", \"biscuit\", \"german biscuit\"))\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/contenttype.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\n\nimport rapture.mime._\n\nobject extensionBasedMimeTypes {\n\n  def apply[Res: HasResourceName](): HasContentType[Res] = hasContentTypeImplicit[Res]\n  \n  implicit def hasContentTypeImplicit[Res: HasResourceName]: HasContentType[Res] =\n    new HasContentType[Res] {\n      def contentType(res: Res): MimeTypes.MimeType = res.resourceExtension.flatMap { ext =>\n        MimeTypes.extension(ext).headOption\n      }.getOrElse(MimeTypes.`application/octet-stream`)\n    }\n}\n\ntrait HasContentType[Res] {\n  def contentType(res: Res): MimeTypes.MimeType\n}\n\nobject HasContentType {\n  class Capability[Res](res: Res) {\n    def contentType(implicit hasContentType: HasContentType[Res]): MimeTypes.MimeType =\n      hasContentType.contentType(res)\n  }\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/copy.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\nimport rapture.core._\n\ntrait Copyable_1 {\n  implicit def streamableCopyable[SrcType, DestType](implicit reader: Reader[SrcType, Byte],\n                                                     writer: Writer[DestType, Byte]): Copyable[SrcType, DestType] =\n    new Copyable[SrcType, DestType] {\n      def copy(src: SrcType, dest: DestType): Copyable.Summary = {\n        val bytes = reader.input(src) > writer.output(dest)\n        Copyable.StreamSummary(bytes)\n      }\n    }\n}\n\nobject Copyable extends Copyable_1 {\n\n  trait Summary\n\n  case class StreamSummary(bytes: Long) extends Summary {\n    override def toString = s\"streamed $bytes bytes\"\n  }\n\n  class Capability[SrcType](from: SrcType) {\n    def copyTo[DestType](to: DestType)(implicit mode: Mode[`Copyable#copyTo`],\n                                       copyable: Copyable[SrcType, DestType]): mode.Wrap[Summary, Exception] =\n      mode.wrap(?[Copyable[SrcType, DestType]].copy(from, to))\n  }\n}\n\ntrait Copyable[-SrcType, -DestType] {\n  def copy(from: SrcType, to: DestType): Copyable.Summary\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/delete.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\nimport rapture.core._\n\ntrait Deleter[Res] {\n  def delete(res: Res): Unit\n}\n\nobject Deletable {\n\n  case class Summary(deleted: Int) {\n    override def toString = s\"$deleted file(s) deleted\"\n  }\n\n  class Capability[Res](res: Res) {\n    def delete()(implicit mode: Mode[`Deletable#delete`], deleter: Deleter[Res]): mode.Wrap[Summary, Exception] =\n      mode wrap {\n        deleter.delete(res)\n        Summary(1)\n      }\n  }\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/guid.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\nimport rapture.core._\n\nobject Guid {\n  private val GuidPattern = \"\"\"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$\"\"\".r\n  def generate() = Guid(java.util.UUID.randomUUID().toString)\n}\n\ncase class Guid(id: String) {\n  override def toString = id\n  def apply() = id\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/io.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\n\nimport rapture.core._\n\nimport java.io._\n\nimport language.reflectiveCalls\n\nobject javaResources {\n\n  type StructuralReadable = { def getInputStream(): InputStream }\n  type StructuralWritable = { def getOutputStream(): OutputStream }\n\n  implicit val structuralReader = new JavaInputStreamReader[StructuralReadable](_.getInputStream())\n\n  implicit val structuralWriter = new JavaOutputStreamWriter[StructuralWritable](_.getOutputStream())\n\n  implicit val javaFileReader = new JavaInputStreamReader[java.io.File](new java.io.FileInputStream(_))\n\n  implicit val javaNioPathReader = new JavaInputStreamReader[java.nio.file.Path](java.nio.file.Files.newInputStream(_))\n\n  implicit val javaFileWriter = new JavaOutputStreamWriter[java.io.File](new java.io.FileOutputStream(_))\n\n  implicit val javaFileAppender = new JavaOutputAppender[java.io.File](f => alloc[java.io.FileOutputStream](f, true))\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/move.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\nimport rapture.core._\n\nobject Movable {\n  case class Summary(streamed: Option[Long]) {\n    override def toString = streamed match {\n      case None => \"moved file\"\n      case Some(b) => s\"streamed, deleted $b bytes\"\n    }\n  }\n\n  class Capability[FromType](from: FromType) {\n    def moveTo[ToType](to: ToType)(implicit mode: Mode[`Movable#moveTo`],\n                                   movable: Movable[FromType, ToType]): mode.Wrap[Summary, Exception] =\n      mode.wrap(?[Movable[FromType, ToType]].move(from, to))\n  }\n}\n\ntrait Movable[FromType, ToType] {\n  def move(from: FromType, to: ToType): Movable.Summary\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/multipart.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\nimport rapture.core._\nimport rapture.mime._\n\nimport scala.collection.mutable.ListBuffer\n\ncase class Multipart(data: Array[Byte], headers: Map[String, String]) {\n  def contentType: Option[MimeTypes.MimeType] =\n    headers.get(\"Content-Type\") map {\n      case MimeTypes(t) => t\n      case t => MimeTypes.MimeType(t)\n    }\n\n  lazy val contentDisposition: Option[(String, Map[String, String])] =\n    headers.get(\"Content-Disposition\") flatMap { v =>\n      v.split(\"; *\").to[List] match {\n        case h :: t =>\n          val m = t\n            .map({ a =>\n              val b = a.split(\"=\")\n              b(0) -> b(1)\n            })\n            .toMap\n          Some(h -> m)\n        case _ => None\n      }\n    }\n\n  def filename: Option[String] = contentDisposition flatMap { case (_, m) => m.get(\"filename\") }\n\n  def name: Option[String] = contentDisposition flatMap { case (_, m) => m.get(\"name\") }\n\n  def disposition: Option[String] = contentDisposition.map(_._1)\n\n}\n\nclass MultipartReader(boundary: String, in: java.io.InputStream, val sizeLimit: Int = 160) extends Input[Multipart] {\n\n  private val bnd = (\"--\" + boundary).getBytes(\"ASCII\")\n\n  private var finished = false\n  private var cued = next()\n\n  def close(): Unit = in.close()\n  def ready(): Boolean = cued.isDefined\n  def read(): Option[Multipart] = {\n    val r = cued\n    cued = next()\n    r\n  }\n\n  private def next(): Option[Multipart] = {\n\n    var buf: Array[Byte] = null\n    var count = -1\n    val bufs = alloc[ListBuffer[Array[Byte]]]()\n\n    var headers: Map[String, String] = Map()\n    var dataStart = 0\n    var boundmatch: Int = 0\n\n    while (!finished) {\n      var cur = in.read()\n\n      if (buf != null && dataStart == 0 && (buf(count % 65536) == 10 && cur == 13 ||\n              buf(count % 65536) == 13 && cur == 10)) {\n        // do nothing\n      } else if (buf != null && dataStart == 0 && (cur == 10 || cur == 13 &&\n                     buf(count % 65536) == cur)) {\n        dataStart = count + 1\n        val next = in.read().toByte\n        if (next != 10 && next != 13) {\n          count += 1\n          buf(count % 65536) = next\n        }\n        headers = alloc[String](buf.slice(1, dataStart), \"ISO-8859-1\")\n          .split(\"\\r\")\n          .map({ h =>\n            val i = h.indexOf(':')\n            h.substring(0, i) -> h.substring(i + 2, h.length)\n          })\n          .toMap\n      } else {\n        count += 1\n\n        if (cur == -1) {\n          finished = true\n          return None\n        }\n\n        if (count % 65536 == 0) {\n          if (count > sizeLimit) throw alloc[RuntimeException](\"Upload size limit exceeded.\")\n          buf = alloc(65536)\n          bufs += buf\n        }\n\n        buf(count % 65536) = cur.toByte\n\n        boundmatch = if (buf(count % 65536) == bnd(boundmatch)) boundmatch + 1 else 0\n\n        if (boundmatch == bnd.length) {\n          val dataEnd = count - boundmatch - 1\n          val size = dataEnd - dataStart\n\n          if (size >= 0) {\n            val res: Array[Byte] = alloc(size)\n            var done = 0\n            var i = 0\n            var offset = dataStart\n            while (done < size) {\n              val chunk = List(65536 - offset, size - done).min\n              System.arraycopy(bufs(i), offset, res, done, chunk)\n              done += chunk\n              offset = 0\n              i += 1\n            }\n\n            return Some(Multipart(res, headers))\n          } else {\n            count = -1\n            bufs.clear()\n            buf = null\n            boundmatch = 0\n            dataStart = 0\n          }\n        }\n      }\n    }\n    None\n  }\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/name.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\n\nimport rapture.uri._\n\ntrait HasResourceName[Res] {\n  def resourceName(res: Res): String\n  def resourceExtension(res: Res): Option[String] = {\n    val parts = resourceName(res).split(\"\\\\.\")\n    if(parts.length > 1) Some(parts.last) else None\n  }\n}\n\nobject HasResourceName {\n  \n  implicit val classpathHasResourceName: HasResourceName[ClasspathUrl] = new HasResourceName[ClasspathUrl] {\n    def resourceName(classpathUrl: ClasspathUrl): String = classpathUrl.elements.last\n  }\n\n  class Capability[Res](res: Res) {\n    def resourceName(implicit hasResourceName: HasResourceName[Res]): String =\n      hasResourceName.resourceName(res)\n    \n    def resourceExtension(implicit hasResourceName: HasResourceName[Res]): Option[String] =\n      hasResourceName.resourceExtension(res)\n  }\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\n\nimport rapture.core._\nimport rapture.uri._\nimport java.io._\n\nimport scala.language.implicitConversions\n\ntrait `Appendable#appendOutput` extends MethodConstraint\ntrait `Readable#input` extends MethodConstraint\ntrait `Readable#redirectTo` extends MethodConstraint\ntrait `Readable#appendTo` extends MethodConstraint\ntrait `Writable#output` extends MethodConstraint\ntrait `Sizable#size` extends MethodConstraint\ntrait `Slurpable#slurp` extends MethodConstraint\ntrait `Copyable#copyTo` extends MethodConstraint\ntrait `Movable#moveTo` extends MethodConstraint\ntrait `Deletable#delete` extends MethodConstraint\n\nobject `package` {\n\n  /** Views an `Input[Byte]` as a `java.io.InputStream` */\n  implicit def inputStreamUnwrapper(is: Input[Byte]): InputStream =\n    new InputStream { def read() = is.read().map(_.toInt).getOrElse(-1) }\n\n  implicit def classpathStreamByteReader(implicit cl: ClassLoader): JavaInputStreamReader[ClasspathUrl] =\n    ClasspathStream.classpathStreamByteReader\n\n  def ensuring[Res, Strm: Closable](create: Strm)(body: Strm => Res): Res = Utils.ensuring[Res, Strm](create)(body)\n\n  implicit def stringMethods(s: String): StringMethods = alloc(s)\n  implicit def copyable[Res](res: Res): Copyable.Capability[Res] = alloc(res)\n  implicit def appendable[Res](res: Res): Appendable.Capability[Res] = alloc(res)\n  implicit def readable[Res](res: Res): Readable.Capability[Res] = alloc(res)\n  implicit def deletable[Res](res: Res): Deletable.Capability[Res] = alloc(res)\n  implicit def slurpable[Res](res: Res): Slurpable.Capability[Res] = alloc(res)\n  implicit def writable[Res](res: Res): Writable.Capability[Res] = alloc(res)\n  implicit def movable[Res](res: Res): Movable.Capability[Res] = alloc(res)\n  implicit def sizable[Res](res: Res): Sizable.Capability[Res] = alloc(res)\n  implicit def hasResourceName[Res](res: Res): HasResourceName.Capability[Res] = alloc(res)\n  implicit def hasContentType[Res](res: Res): HasContentType.Capability[Res] = alloc(res)\n\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/size.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\nimport rapture.core._\n\nimport scala.reflect._\n\nobject Sizable {\n  class Capability[Res](res: Res) {\n\n    /** Returns the size in bytes of this resource */\n    def size[Data](implicit mode: Mode[`Sizable#size`], sizable: Sizable[Res, Data]): mode.Wrap[Long, Exception] =\n      mode wrap sizable.size(res)\n  }\n\n  implicit def charSizable[Res, Data: ClassTag](implicit reader: Reader[Res, Data]): Sizable[Res, Data] =\n    new Sizable[Res, Data] {\n      private def accumulator() = new Accumulator[Data, Long] with Output[Data] {\n        private var count = 0\n        def buffer: Long = count\n        def write(b: Data) = count += 1\n        def flush(): Unit = ()\n        def close(): Unit = ()\n      }\n\n      def size(res: Res): Long = {\n        val acc = accumulator()\n        res.handleInput[Data, Int](_ pumpTo acc)\n        acc.buffer\n      }\n    }\n}\n\ntrait Sizable[Res, Data] {\n  type ExceptionType <: Exception\n\n  /** Returns the number of units of the specified resource */\n  def size(res: Res): Long\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/slurp.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\n\nimport rapture.core._\nimport rapture.codec._\n\nimport scala.reflect._\n\nimport java.io._\n\ntrait AccumulatorBuilder_1 {\n  implicit val byteAccumulator: AccumulatorBuilder[Byte] { type Out = Bytes } = ByteAccumulator\n  implicit val stringAccumulator: AccumulatorBuilder[String] { type Out = String } = StringAccumulator\n}\n\nobject AccumulatorBuilder extends AccumulatorBuilder_1 {\n  implicit val charAccumulator: AccumulatorBuilder[Char] { type Out = String } = CharAccumulator\n}\n\n/** Interface for an accumulator which is a special kind of output which collects and stores all\n  * input in a buffer which can be retrieved afterwards.  No guarantees are made about input\n  * supplied after the buffer has been retrieved.\n  *\n  * @tparam Data The type of data to be accumulated\n  * @tparam Acc The type into which the data will be accumulated */\ntrait Accumulator[Data, +Acc] extends Output[Data] { def buffer: Acc }\n\n/** Defines a trait for creating new `Accumulator`s */\ntrait AccumulatorBuilder[T] {\n  type Out\n  def make(): Accumulator[T, Out]\n}\n\n/** Collects `Byte`s into an `Array[Byte]` */\nclass ByteArrayOutput extends {\n  private val baos: ByteArrayOutputStream = alloc()\n} with ByteOutput(baos) with Accumulator[Byte, Bytes] {\n  def buffer: Bytes = Bytes(baos.toByteArray)\n}\n\n/** Collects `String`s into another `String` */\nclass LinesOutput extends {\n  private val sw: StringWriter = alloc()\n} with LineOutput(sw) with Accumulator[String, String] {\n  def buffer: String = sw.toString\n}\n\n/** Type class object for creating an accumulator Bytes into an `Array` of `Byte`s */\nobject ByteAccumulator extends AccumulatorBuilder[Byte] {\n  type Out = Bytes\n  def make(): ByteArrayOutput = alloc()\n}\n\n/** Type class object for creating an accumulator of `String`s */\nobject StringAccumulator extends AccumulatorBuilder[String] {\n  type Out = String\n  def make(): LinesOutput = alloc()\n}\n\n/** Type class object for creating an accumulator of `Char`s into a `String` */\nobject CharAccumulator extends AccumulatorBuilder[Char] {\n  type Out = String\n  def make(): StringOutput = alloc()\n}\n\n/** Collects `Char`s into a `String` */\nclass StringOutput extends {\n  private val sw: StringWriter = alloc()\n} with CharOutput(sw) with Accumulator[Char, String] {\n  def buffer: String = sw.toString\n}\n\nobject Slurpable {\n  class Capability[Res](res: Res) {\n\n    def slurp[Data]()(implicit accumulatorBuilder: AccumulatorBuilder[Data],\n                      mode: Mode[`Slurpable#slurp`],\n                      sr: Reader[Res, Data],\n                      mf: ClassTag[Data]): mode.Wrap[accumulatorBuilder.Out, Exception] =\n      mode.wrap {\n        val c = accumulatorBuilder.make()\n        res.handleInput[Data, Int](_ pumpTo c)\n        c.close()\n        c.buffer\n      }\n  }\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/streams.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\nimport rapture.core._\nimport rapture.codec._\nimport rapture.mime._\n\nimport java.io._\nimport scala.reflect._\n\nimport language.higherKinds\n\ntrait Closable[-R] { def close(resource: R): Unit }\n\nobject Utils {\n\n  /** Safely closes a stream after processing */\n  def ensuring[Res, Strm: Closable](create: Strm)(blk: Strm => Res) = {\n    val stream = create\n    val result = try { blk(stream) } catch {\n      case e: Throwable =>\n        try { implicitly[Closable[Strm]].close(stream) } catch { case e2: Exception => () }\n        throw e\n    }\n\n    implicitly[Closable[Strm]].close(stream)\n\n    result\n  }\n}\n\ncase class StringIsInput(string: String) extends CharInput(alloc[StringReader](string))\n\ncase class ByteArrayInput(array: Array[Byte]) extends ByteInput(alloc[ByteArrayInputStream](array))\n\nobject InputBuilder {\n  implicit def stringInputBuilder(implicit encoding: Encoding): InputBuilder[InputStream, String] =\n    new InputBuilder[InputStream, String] {\n      def input(s: InputStream): Input[String] =\n        alloc[LineInput](alloc[InputStreamReader](s, encoding.name))\n    }\n\n  implicit def inputStreamCharBuilder(implicit encoding: Encoding): InputBuilder[InputStream, Char] =\n    new InputBuilder[InputStream, Char] {\n      def input(s: InputStream): Input[Char] =\n        alloc[CharInput](alloc[InputStreamReader](s, encoding.name))\n    }\n  implicit val buildInputStream: InputBuilder[InputStream, Byte] = InputStreamBuilder\n  implicit val buildReader: InputBuilder[java.io.Reader, Char] = ReaderBuilder\n  implicit val buildLineReader: InputBuilder[java.io.Reader, String] = LineReaderBuilder\n}\n\nobject Input {\n  implicit def inputClosable[T]: Closable[Input[T]] = new Closable[Input[T]] {\n    def close(in: Input[T]): Unit = in.close()\n  }\n}\n\ntrait InputBuilder[InputType, Data] {\n  def input(s: InputType): Input[Data]\n}\n\nobject OutputBuilder {\n  implicit val buildOutputStream: OutputBuilder[OutputStream, Byte] = OutputStreamBuilder\n  implicit val buildWriter: OutputBuilder[java.io.Writer, Char] = WriterBuilder\n\n  implicit def stringOutputBuilder(implicit encoding: Encoding): OutputBuilder[OutputStream, String] =\n    new OutputBuilder[OutputStream, String] {\n      def output(s: OutputStream): Output[String] =\n        new LineOutput(new OutputStreamWriter(s, encoding.name))\n    }\n\n  implicit def outputStreamCharBuilder(implicit encoding: Encoding): OutputBuilder[OutputStream, Char] =\n    new OutputBuilder[OutputStream, Char] {\n      def output(s: OutputStream): Output[Char] =\n        alloc[CharOutput](alloc[OutputStreamWriter](s, encoding.name))\n    }\n\n}\n\ntrait OutputBuilder[OutputType, Data] {\n  def output(s: OutputType): Output[Data]\n}\n\nobject AppenderBuilder {\n  implicit def buildAppender: AppenderBuilder[java.io.Writer, Char] =\n    new AppenderBuilder[java.io.Writer, Char] {\n      def appendOutput(s: java.io.Writer) = alloc[CharOutput](s)\n    }\n}\n\ntrait AppenderBuilder[OutputType, Data] { def appendOutput(s: OutputType): Output[Data] }\n\nobject Appendable {\n  class Capability[Res](res: Res) {\n    def appendOutput[Data](implicit sa: Appender[Res, Data], mode: Mode[`Appendable#appendOutput`]) =\n      sa.appendOutput(res)\n\n    def handleAppend[Data, Res2](body: Output[Data] => Res2)(implicit sw: Appender[Res, Data]): Res2 = {\n      ensuring(appendOutput[Data])(body)\n    }\n  }\n\n}\n\nobject Readable {\n  class Capability[Res](res: Res) {\n\n    def input[Data](implicit sr: Reader[Res, Data], mode: Mode[`Readable#input`]): mode.Wrap[Input[Data], Exception] =\n      mode.wrap(sr.input(res))\n\n    def redirectTo[Data, DestRes](dest: DestRes)(implicit sr: Reader[Res, Data],\n                                                 sw: Writer[DestRes, Data],\n                                                 mode: Mode[`Readable#redirectTo`],\n                                                 mf: ClassTag[Data]): mode.Wrap[Int, Exception] =\n      mode.wrap(handleInput[Data, Int] { in =>\n        writable(dest).handleOutput[Data, Int](in.pumpTo)\n      })\n\n    def >[Data, DestRes](dest: DestRes)(implicit sr: Reader[Res, Data],\n                                        sw: Writer[DestRes, Data],\n                                        mode: Mode[`Readable#redirectTo`],\n                                        mf: ClassTag[Data]): mode.Wrap[Int, Exception] =\n      redirectTo[Data, DestRes](dest)(sr, sw, mode, mf)\n\n    def pipeTo[Data, DestRes](\n        dest: DestRes)(implicit sr: Reader[Res, Data], sw: Writer[DestRes, Data], mf: ClassTag[Data]): DestRes = {\n      redirectTo(dest)\n      dest\n    }\n\n    def |[Data, DestRes](\n        dest: DestRes)(implicit sr: Reader[Res, Data], sw: Writer[DestRes, Data], mf: ClassTag[Data]): DestRes =\n      pipeTo(dest)(sr, sw, mf)\n\n    def >>[Data, DestRes](dest: DestRes)(implicit sr: Reader[Res, Data],\n                                         sw: Appender[DestRes, Data],\n                                         mode: Mode[`Readable#appendTo`],\n                                         mf: ClassTag[Data]): mode.Wrap[Int, Exception] =\n      mode.wrap(handleInput[Data, Int] { in =>\n        dest.handleAppend[Data, Int](in.pumpTo)\n      })\n\n    def >[Data](out: Output[Data])(implicit sr: Reader[Res, Data],\n                                   mode: Mode[`Readable#redirectTo`],\n                                   mf: ClassTag[Data]): mode.Wrap[Int, Exception] =\n      mode.wrap(handleInput[Data, Int](_ pumpTo out))\n\n    def handleInput[Data, Res2](body: Input[Data] => Res2)(implicit sr: Reader[Res, Data]): Res2 =\n      ensuring(input[Data])(body)\n  }\n}\n\nobject Writable {\n  class Capability[Res](res: Res) {\n\n    def output[Data](implicit sw: Writer[Res, Data],\n                     mode: Mode[`Writable#output`]): mode.Wrap[Output[Data], Exception] = mode.wrap(sw.output(res))\n\n    def handleOutput[Data, Res2](body: Output[Data] => Res2)(implicit sw: Writer[Res, Data]): Res2 =\n      ensuring(output[Data])(body)\n  }\n}\n\nobject Writer {\n  implicit def byteToLineWriters[T](implicit jisw: JavaOutputStreamWriter[T], encoding: Encoding): Writer[T, String] =\n    new Writer[T, String] {\n      def output(t: T): Output[String] = alloc[LineOutput](alloc[OutputStreamWriter](jisw.getOutputStream(t)))\n    }\n\n  implicit def byteToCharWriters[T](implicit jisw: JavaOutputStreamWriter[T], encoding: Encoding): Writer[T, Char] =\n    new Writer[T, Char] {\n      def output(t: T): Output[Char] = alloc[CharOutput](alloc[OutputStreamWriter](jisw.getOutputStream(t)))\n    }\n\n  implicit val stdoutWriter: JavaOutputStreamWriter[Stdout.type] =\n    new JavaOutputStreamWriter[Stdout.type](x => System.out, _ => ())\n\n  implicit val stderrWriter: Writer[Stderr.type, Byte] = new Writer[Stderr.type, Byte] {\n    def output(stderr: Stderr.type): Output[Byte] =\n      ?[OutputBuilder[OutputStream, Byte]].output(System.out)\n  }\n}\n\n@implicitNotFound(\n    msg = \"Cannot write $\"+\"{Data} data to $\"+\"{Resource} resources. Note that if you \" +\n        \"are working with Char data, you will require an implicit character encoding, e.g. \" +\n        \"import encodings.system._ or import encodings.`UTF-8`._.\")\ntrait Writer[-Resource, @specialized(Byte, Char) Data] {\n  def output(res: Resource): Output[Data]\n}\n\nobject Appender extends Appender_1 {\n\n  implicit def byteToCharAppenders[T](implicit jisw: JavaOutputAppender[T], encoding: Encoding): Appender[T, Char] =\n    new Appender[T, Char] {\n      def appendOutput(t: T): Output[Char] =\n        alloc[CharOutput](alloc[OutputStreamWriter](jisw.getOutputStream(t)))\n    }\n\n  implicit def byteToLineAppender[Res](implicit appender: Appender[Res, Byte], enc: Encoding) = {\n    new Appender[Res, String] {\n      def appendOutput(res: Res): Output[String] = new Output[String] {\n        private lazy val output = appender.appendOutput(res)\n        def close() = output.close()\n        def flush() = output.flush()\n        def write(s: String) = {\n          output.writeBlock((s + \"\\n\").getBytes(enc.name))\n          output.flush()\n        }\n      }\n    }\n  }\n\n  implicit val stdoutAppender: JavaOutputAppender[Stdout.type] =\n    new JavaOutputAppender[Stdout.type](x => System.out, _ => ())\n\n  implicit val stderrAppender: JavaOutputAppender[Stderr.type] =\n    new JavaOutputAppender[Stderr.type](x => System.err, _ => ())\n\n  implicit val stdoutCharAppender: Appender[Stdout.type, Char] =\n    byteToCharAppenders(stdoutAppender, encodings.system())\n\n  implicit val stderrCharAppender: Appender[Stderr.type, Char] =\n    byteToCharAppenders(stderrAppender, encodings.system())\n\n}\n\ntrait Appender_1 {\n  implicit def charToLineAppender[Res](implicit appender: Appender[Res, Char]) = {\n    new Appender[Res, String] {\n      def appendOutput(res: Res): Output[String] = new Output[String] {\n        private lazy val output = appender.appendOutput(res)\n        def close() = output.close()\n        def flush() = output.flush()\n        def write(s: String) = {\n          output.writeBlock((s + \"\\n\").to[Array])\n          output.flush()\n        }\n      }\n    }\n  }\n}\n\ntrait Appender[-Resource, Data] {\n  def appendOutput(res: Resource): Output[Data]\n}\n\ntrait TypedInput { thisInput: Input[_] =>\n  def mimeType: MimeTypes.MimeType\n}\n\ntrait Input[@specialized(Byte, Char) Data] extends Seq[Data] { thisInput =>\n\n  private var beingHandled = false\n\n  override def toString() = \"<input>\"\n\n  // FIXME: This just shouldn't be a Seq\n  def length: Int = throw alloc[Exception](\"Cannot calculate length of a stream\")\n\n  def apply(n: Int) = {\n    for (i <- 0 until n) read()\n    read().get\n  }\n\n  def typed(mime: MimeTypes.MimeType) = new Input[Data] with TypedInput {\n    def mimeType = mime\n    def ready() = thisInput.ready()\n    def close() = thisInput.close()\n    def read() = thisInput.read()\n  }\n\n  def iterator: Iterator[Data] = new Iterator[Data] {\n    private var nextVal: Option[Data] = read()\n    def hasNext = nextVal.isDefined\n    def next() = {\n      val x = nextVal.get\n      nextVal = read()\n      x\n    }\n  }\n\n  def ready(): Boolean\n\n  def read(): Option[Data]\n\n  def readBlock(array: Array[Data], offset: Int = 0, length: Int = -1): Int = {\n\n    val end = if (length < 0) array.length - offset else offset + length\n\n    read() match {\n      case None => -1\n      case Some(c) =>\n        array(offset) = c\n        var i = offset + 1\n        var continue = true\n        while (i < end && continue) {\n          read() match {\n            case None =>\n              continue = false\n            case Some(c) =>\n              array(i) = c\n              i += 1\n          }\n        }\n\n        i - offset\n    }\n  }\n\n  def close(): Unit\n\n  def pumpTo(out: Output[Data])(implicit mf: ClassTag[Data]): Int = {\n    val buf: Array[Data] = alloc(65536)\n    var len = readBlock(buf)\n    var count = 0\n    while (len >= 0) {\n      out.writeBlock(buf, length = len)\n      count += len\n      len = readBlock(buf)\n    }\n    count\n  }\n\n  def map[T](fn: Data => T): Input[T] = new Input[T] {\n    def read(): Option[T] = thisInput.read().map(fn)\n    def ready(): Boolean = thisInput.ready()\n    def close(): Unit = thisInput.close()\n  }\n\n  def flatMap[T](fn: Data => Seq[T]): Input[T] = new Input[T] {\n    private var buf: Seq[T] = Nil\n    private var cur = 0\n    private var avail = 0\n\n    def read(): Option[T] =\n      if (cur == avail) {\n        cur = 0\n        avail = 0\n        thisInput.read().map(fn) match {\n          case None => None\n          case Some(xs) =>\n            if (xs.isEmpty) read()\n            else if (xs.length == 1) xs.headOption\n            else {\n              avail = xs.length\n              cur += 1\n              buf = xs\n              xs.headOption\n            }\n        }\n      } else {\n        cur += 1\n        Some(buf(cur - 1))\n      }\n\n    def ready(): Boolean = cur < avail || thisInput.ready()\n\n    def close(): Unit = {\n      cur = 0\n      avail = 0\n      thisInput.close()\n    }\n  }\n\n  override def foreach[U](fn: Data => U): Unit = {\n    var next: Option[Data] = read()\n    while (next.isDefined) {\n      fn(next.get)\n      next = read()\n    }\n  }\n}\n\nobject Output {\n  implicit def outputClosable[T]: Closable[Output[T]] = new Closable[Output[T]] {\n    def close(out: Output[T]): Unit = out.close()\n  }\n}\n\ntrait Output[@specialized(Byte, Char) Data] {\n  private var beingHandled = false\n\n  def write(data: Data): Unit\n\n  def writeBlock(array: Array[Data], offset: Int = 0, length: Int = -1): Int = {\n\n    val end = if (length < 0) array.length - offset else offset + length\n    array.slice(offset, end).foreach(write)\n\n    end - offset\n  }\n\n  def flush(): Unit\n\n  def close(): Unit\n}\n\ntrait Reader_1 {\n  implicit def stringByteReader(implicit encoding: Encoding): Reader[String, Byte] =\n    new Reader[String, Byte] {\n      def input(s: String): Input[Byte] = ByteArrayInput(s.getBytes(encoding.name))\n    }\n\n  implicit val stringLineReader: Reader[String, String] = StringLineReader\n}\n\nobject Reader extends Reader_1 {\n\n  type ForBytes[-Resource] = Reader[Resource, Byte]\n  type ForChars[-Resource] = Reader[Resource, Char]\n\n  implicit def inputStreamReader[T, I[T] <: Input[T]]: Reader[I[T], T] =\n    new Reader[I[T], T] {\n      def input(in: I[T]): Input[T] = in\n    }\n\n  implicit def byteInputToCharReader(implicit encoding: Encoding): Reader[Input[Char], Byte] =\n    new Reader[Input[Char], Byte] {\n      def input(in: Input[Char]): Input[Byte] = new Input[Byte] {\n        private var cued: Array[Byte] = Array()\n        private var index = 0\n        def read(): Option[Byte] = {\n          if (index >= cued.length) {\n            // FIXME: Find a less stupid way of doing this\n            val next = in.read()\n            if (next.isEmpty) return None\n            cued = next.get.toString.getBytes(encoding.name)\n            index = 0\n          }\n          val next = cued(index)\n          index += 1\n          Some(next)\n        }\n        def ready(): Boolean = in.ready() || index < cued.length\n        def close(): Unit = in.close()\n      }\n    }\n\n  implicit def charInputToByteReader(implicit encoding: Encoding): Reader[Input[Byte], Char] =\n    new Reader[Input[Byte], Char] {\n      def input(in: Input[Byte]): Input[Char] = {\n        val javaInputStream = new InputStream {\n          def read(): Int = {\n            val r = in.read()\n            if (r.isDefined) r.get.toInt else -1\n          }\n        }\n        alloc[CharInput](alloc[InputStreamReader](javaInputStream, encoding.name))\n      }\n    }\n\n  implicit def byteToLineReaders[T](implicit jisr: JavaInputStreamReader[T], encoding: Encoding): Reader[T, String] =\n    new Reader[T, String] {\n      def input(t: T): Input[String] =\n        alloc[LineInput](alloc[InputStreamReader](jisr.getInputStream(t)))\n    }\n\n  implicit def byteToCharReaders[T](implicit jisr: JavaInputStreamReader[T], encoding: Encoding): Reader[T, Char] =\n    new Reader[T, Char] {\n      def input(t: T): Input[Char] =\n        alloc[CharInput](alloc[InputStreamReader](jisr.getInputStream(t)))\n    }\n\n  implicit def resourceBytes[Res](res: Res)(implicit sr: Reader[Res, Byte]): Bytes =\n    slurpable(res).slurp[Byte]\n\n  implicit val stringCharReader: Reader[String, Char] = StringCharReader\n  implicit val byteArrayReader: Reader[Array[Byte], Byte] = ByteArrayReader\n  implicit val bytesReader: Reader[Bytes, Byte] = BytesReader\n\n  implicit val stdinReader: Reader[Stdin.type, Byte] = new Reader[Stdin.type, Byte] {\n    def input(stdin: Stdin.type): Input[Byte] =\n      ?[InputBuilder[InputStream, Byte]].input(System.in)\n  }\n\n}\n\n@implicitNotFound(\n    msg = \"Cannot find implicit Reader for $\"+\"{Resource} resources. \" +\n        \"$\"+\"{Resource} resources can only be read if a Reader implicit exists within scope. \" +\n        \"Note that if you are working with Char data, you will require an implicit character \" +\n        \"encoding, e.g. import encodings.system._ or import encodings.`UTF-8`._.\")\ntrait Reader[-Resource, @specialized(Byte, Char) Data] {\n\n  def input(res: Resource): Input[Data]\n\n  def pump[DestResource](res: Resource, dest: DestResource)(implicit sw: Writer[DestResource, Data],\n                                                            mf: ClassTag[Data]): Int =\n    input(res) pumpTo sw.output(dest)\n}\n\nobject StringCharReader extends Reader[String, Char] {\n  def input(s: String): Input[Char] = StringIsInput(s)\n}\n\nobject StringLineReader extends Reader[String, String] {\n  def input(s: String): Input[String] = new Input[String] {\n    private val lines = s.split(\"\\n\")\n    private var cur = -1\n    def ready() = cur < lines.length\n    def close() = ()\n    def read() = {\n      cur += 1\n      if (ready()) Some(lines(cur)) else None\n    }\n  }\n}\n\nobject BytesReader extends Reader[Bytes, Byte] {\n  def input(s: Bytes): Input[Byte] = ByteArrayInput(s.bytes)\n}\n\nobject ByteArrayReader extends Reader[Array[Byte], Byte] {\n  def input(s: Array[Byte]): Input[Byte] = ByteArrayInput(s)\n}\n\nobject Stdin\nobject Stdout\nobject Stderr\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/strings.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\n\nimport rapture.core._\nimport rapture.codec._\nimport java.net._\n\nclass StringMethods(s: String) {\n  @inline def urlEncode(implicit encoding: Encoding = encodings.`UTF-8`()) =\n    URLEncoder.encode(s, encoding.name)\n  @inline def urlDecode(implicit encoding: Encoding = encodings.`UTF-8`()) =\n    URLDecoder.decode(s, encoding.name)\n}\n"
  },
  {
    "path": "io/shared/src/main/scala/rapture/io/wrappers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.io\nimport rapture.core._\nimport rapture.codec._\nimport rapture.uri._\n\nimport java.io._\n\n/** Type class object for creating an Input[Byte] from a Java InputStream */\nobject InputStreamBuilder extends InputBuilder[InputStream, Byte] {\n  def input(s: InputStream): Input[Byte] = alloc[ByteInput](s)\n}\n\n/** Type class object for creating an Output[Byte] from a Java Reader */\nobject OutputStreamBuilder extends OutputBuilder[OutputStream, Byte] {\n  def output(s: OutputStream): Output[Byte] = alloc[ByteOutput](s)\n}\n\nobject ClasspathStream {\n  def classpathStreamByteReader(implicit cl: ClassLoader) =\n    new JavaInputStreamReader[ClasspathUrl](url => cl.javaClassLoader.getResourceAsStream(url.uri.schemeSpecificPart))\n}\n\n/** Wraps a `java.io.Reader` as an `Input[Char]` */\nclass CharInput(in: java.io.Reader) extends Input[Char] {\n\n  private val bin = alloc[BufferedReader](in)\n\n  def ready() = bin.ready()\n\n  def read() = bin.read() match {\n    case -1 => None\n    case x => Some(x.toChar)\n  }\n\n  def close() = bin.close()\n\n  override def readBlock(array: Array[Char], offset: Int = 0, length: Int = -1): Int =\n    bin.read(array, offset, if (length == -1) array.length - offset else length)\n\n  override def toString() = \"<character input>\"\n}\n\n/** Wraps a `java.io.InputStream` as an `Input[Byte]` */\nclass ByteInput(in: InputStream) extends Input[Byte] {\n\n  private val bin = alloc[BufferedInputStream](in)\n\n  // FIXME: This might be really slow\n  def ready() = bin.available() > 0\n\n  def read() = bin.read() match {\n    case -1 => None\n    case x => Some(x.toByte)\n  }\n\n  override def readBlock(array: Array[Byte], offset: Int = 0, length: Int = -1): Int =\n    bin.read(array, offset, if (length == -1) array.length - offset else length)\n\n  def close() = in.close()\n\n  override def toString() = \"<byte input>\"\n}\n\n/** Wraps a `java.io.OutputStream` into an `Output[Byte]`\n  *\n  * @param out The `java.io.OutputStream` to be wrapped */\nclass ByteOutput(out: OutputStream, closer: OutputStream => Unit = _.close()) extends Output[Byte] {\n\n  private val bout = alloc[BufferedOutputStream](out)\n\n  def write(b: Byte) = bout.write(b)\n\n  def flush(): Unit = bout.flush()\n  def close(): Unit = bout.close()\n\n  override def toString() = \"<byte output>\"\n\n  override def writeBlock(array: Array[Byte], offset: Int = 0, length: Int = -1): Int = {\n    val len = if (length == -1) array.length - offset else length\n    bout.write(array, offset, len)\n    bout.flush()\n    len\n  }\n\n}\n\n/** Wraps a `java.io.Writer`\n  *\n  * @param out The `java.io.Writer` to be wrapped */\nclass CharOutput(out: java.io.Writer) extends Output[Char] {\n\n  private val bout = alloc[BufferedWriter](out)\n\n  def write(b: Char) = bout.write(b)\n  def flush(): Unit = bout.flush()\n  def close(): Unit = bout.close()\n  override def toString() = \"<character output>\"\n\n  override def writeBlock(array: Array[Char], offset: Int = 0, length: Int = -1): Int = {\n    val len = if (length == -1) array.length - offset else length\n    bout.write(array, offset, len)\n    bout.flush()\n    len\n  }\n\n}\n\n/** Wraps a `java.io.BufferedWriter` for providing line-by-line output of `String`s\n  *\n  * @param writer The `java.io.Writer` to be wrapped */\nclass LineOutput(writer: java.io.Writer) extends Output[String] {\n  def this(os: OutputStream, encoding: Encoding) =\n    this(new OutputStreamWriter(os, encoding.name))\n  private val out = alloc[BufferedWriter](writer)\n\n  def write(s: String) = {\n    out.write(s)\n    out.write(\"\\n\")\n  }\n\n  def flush(): Unit = out.flush()\n  def close(): Unit = out.close()\n  override def toString() = \"<string output>\"\n}\n\n/** Wraps a `java.io.Reader` as an `Input[String]`, where each String item read from the stream\n  * is a line of characters delimited by a newline.  This is roughly equivalent to a\n  * `java.io.BufferedReader`.\n  *\n  * @constructor takes the Java Reader to be wrapped\n  * @param reader The Java Reader instance being wrapped. */\nclass LineInput(reader: java.io.Reader) extends Input[String] {\n  def this(is: InputStream, encoding: Encoding) =\n    this(new InputStreamReader(is, encoding.name))\n  private val in = alloc[BufferedReader](reader)\n\n  def ready(): Boolean = in.ready()\n\n  /** Reads one line from the stream as a `String` */\n  def read() = Option(in.readLine)\n\n  /** Closes the input stream and underlying `BufferedReader` */\n  def close() = in.close()\n}\n\n/** Type class object for creating an Input[Char] from a Java Reader */\nobject ReaderBuilder extends InputBuilder[java.io.Reader, Char] {\n  def input(s: java.io.Reader): Input[Char] = alloc[CharInput](s)\n}\n\n/** Type class object for creating an Input[String] from a Java Reader */\nobject LineReaderBuilder extends InputBuilder[java.io.Reader, String] {\n  def input(s: java.io.Reader): Input[String] = alloc[LineInput](s)\n}\n\n/** Type class object for creating an Output[Char] from a Java Writer */\nobject WriterBuilder extends OutputBuilder[java.io.Writer, Char] {\n  def output(s: java.io.Writer): Output[Char] = alloc[CharOutput](s)\n}\n\nclass JavaOutputStreamWriter[T](val getOutputStream: T => OutputStream, val closer: OutputStream => Unit = _.close())\n    extends Writer[T, Byte] {\n  def output(t: T): Output[Byte] = alloc[ByteOutput](alloc[BufferedOutputStream](getOutputStream(t)), closer)\n}\n\nclass JavaOutputAppender[T](val getOutputStream: T => OutputStream, val closer: OutputStream => Unit = _.close())\n    extends Appender[T, Byte] {\n  def appendOutput(t: T): Output[Byte] = alloc[ByteOutput](alloc[BufferedOutputStream](getOutputStream(t)), closer)\n}\n\nclass JavaInputStreamReader[T](val getInputStream: T => InputStream) extends Reader[T, Byte] {\n  def input(t: T): Input[Byte] = alloc[ByteInput](alloc[BufferedInputStream](getInputStream(t)))\n}\n"
  },
  {
    "path": "java8-support/shared/src/main/scala/rapture/core/java8/time.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n\n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.core.java8\n\nimport java.time._\nimport java.time.format.DateTimeFormatter\nimport java.time.format.DateTimeFormatter._\n\nimport rapture.core.{StringParser, StringSerializer}\n\n\n\nprivate[java8] trait TimeSerializers {\n\n  implicit final def localDateSerializer: StringSerializer[LocalDate] = serializeLocalDate(ISO_LOCAL_DATE)\n  implicit final def localDateTimeSerializer: StringSerializer[LocalDateTime] = serializeLocalDateTime(ISO_LOCAL_DATE_TIME)\n  implicit final def localTimeSerializer: StringSerializer[LocalTime] = serializeLocalTime(ISO_LOCAL_TIME)\n  implicit final def zonedDateTimeSerializer: StringSerializer[ZonedDateTime] = serializeZonedDateTime(ISO_ZONED_DATE_TIME)\n  implicit final def offsetDateTimeSerializer: StringSerializer[OffsetDateTime] = serializeOffsetDateTime(ISO_OFFSET_DATE_TIME)\n  implicit final def offsetTimeSerializer: StringSerializer[OffsetTime] = serializeOffsetTime(ISO_OFFSET_TIME)\n\n  final def serializeLocalDate(formatter: DateTimeFormatter): StringSerializer[LocalDate] = {\n    StringSerializer(_.format(formatter))\n  }\n\n  final def serializeLocalDateTime(formatter: DateTimeFormatter): StringSerializer[LocalDateTime] = {\n    StringSerializer(_.format(formatter))\n  }\n\n  final def serializeLocalTime(formatter: DateTimeFormatter): StringSerializer[LocalTime] = {\n    StringSerializer(_.format(formatter))\n  }\n\n  final def serializeZonedDateTime(formatter: DateTimeFormatter): StringSerializer[ZonedDateTime] = {\n    StringSerializer(_.format(formatter))\n  }\n\n  final def serializeOffsetDateTime(formatter: DateTimeFormatter): StringSerializer[OffsetDateTime] = {\n    StringSerializer(_.format(formatter))\n  }\n\n  final def serializeOffsetTime(formatter: DateTimeFormatter): StringSerializer[OffsetTime] = {\n    StringSerializer(_.format(formatter))\n  }\n\n}\n\nprivate[java8] trait TimeStringParsers {\n\n  implicit final def localDateStringParser: StringParser[LocalDate] = parseLocalDate(ISO_LOCAL_DATE)\n  implicit final def localDateTimeStringParser: StringParser[LocalDateTime] = parseLocalDateTime(ISO_LOCAL_DATE_TIME)\n  implicit final def localTimeStringParser: StringParser[LocalTime] = parseLocalTime(ISO_LOCAL_TIME)\n  implicit final def zonedDateTimeStringParser: StringParser[ZonedDateTime] = parseZonedDateTime(ISO_ZONED_DATE_TIME)\n  implicit final def offsetDateTimeStringParser: StringParser[OffsetDateTime] = parseOffsetDateTime(ISO_OFFSET_DATE_TIME)\n  implicit final def offsetTimeStringParser: StringParser[OffsetTime] = parseOffsetTime(ISO_OFFSET_TIME)\n\n\n  final def parseLocalDate(formatter: DateTimeFormatter): StringParser[LocalDate] = {\n    StringParser(LocalDate.parse(_, formatter))\n  }\n\n\n  final def parseLocalDateTime(formatter: DateTimeFormatter): StringParser[LocalDateTime] = {\n    StringParser(LocalDateTime.parse(_, formatter))\n  }\n\n  final def parseLocalTime(formatter: DateTimeFormatter): StringParser[LocalTime] = {\n    StringParser(LocalTime.parse(_, formatter))\n  }\n\n  final def parseZonedDateTime(formatter: DateTimeFormatter): StringParser[ZonedDateTime] = {\n    StringParser(ZonedDateTime.parse(_, formatter))\n  }\n\n  final def parseOffsetDateTime(formatter: DateTimeFormatter): StringParser[OffsetDateTime] = {\n    StringParser(OffsetDateTime.parse(_, formatter))\n  }\n\n  final def parseOffsetTime(formatter: DateTimeFormatter): StringParser[OffsetTime] = {\n    StringParser(OffsetTime.parse(_, formatter))\n  }\n\n}\n\nobject time extends TimeSerializers with TimeStringParsers\n"
  },
  {
    "path": "js/shared/src/main/scala/rapture/js/context.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.js\n\nimport rapture.base._\nimport rapture.data._\n\nimport scala.language.experimental.macros\n\nprivate[js] object JsMacros {\n\n  def parseSource(s: List[String], stringsUsed: List[Boolean]): Option[(Int, Int, String)] =\n    try {\n      JsValidator.validate(s)\n      None\n    } catch {\n      case JsValidator.ValidationException(strNo, pos, msg) =>\n        Some((strNo, pos, s\"failed to parse Js literal: $msg\"))\n    }\n\n  def contextMacro(c: BlackboxContext)(exprs: c.Expr[ForcedConversion[Js]]*): c.Expr[Js] = {\n    import c.universe._\n    \n    c.prefix.tree match {\n      case Select(Apply(_, List(Apply(_, rawParts))), _) =>\n        val ys = rawParts\n        val text = rawParts map { case lit @ Literal(Constant(part: String)) => part }\n\n        val listExprs = c.Expr[List[ForcedConversion[Js]]](q\"_root_.scala.List(..${exprs.map(_.tree).to[List]})\")\n\n        val stringsUsed: List[Boolean] = listExprs.tree match {\n          case Apply(_, bs) =>\n            bs.map {\n              case Apply(Apply(TypeApply(Select(_, nme), _), _), _) => nme.toString == \"forceStringConversion\"\n            }\n        }\n\n        parseSource(text, stringsUsed) foreach {\n          case (n, offset, msg) =>\n            val oldPos = ys(n).asInstanceOf[Literal].pos\n            val newPos = oldPos.withPoint(oldPos.start + offset)\n            c.error(newPos, msg)\n        }\n\n        val listParts = c.Expr[List[ForcedConversion[Js]]](q\"_root_.scala.List(..$rawParts)\")\n\n        reify {\n          val sb = new StringBuilder\n          val textParts = listParts.splice.iterator\n          val expressions: Iterator[ForcedConversion[_]] = listExprs.splice.iterator\n\n          sb.append(textParts.next())\n\n          while (textParts.hasNext) {\n            sb.append(expressions.next.value)\n            sb.append(textParts.next)\n          }\n          Js(sb.toString)\n        }\n    }\n  }\n\n}\n\nprivate[js] class JsStrings(sc: StringContext) {\n  class JsContext() {\n    def apply(exprs: ForcedConversion[Js]*): Js = macro JsMacros.contextMacro\n  }\n  val js = new JsContext()\n}\n"
  },
  {
    "path": "js/shared/src/main/scala/rapture/js/js.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.js\n\ncase class Js(content: String) {\n  override def toString = s\"\"\"js${\"\\\"\" * 3}$content${\"\\\"\" * 3}\"\"\"\n}\n"
  },
  {
    "path": "js/shared/src/main/scala/rapture/js/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.js\n\nimport language.implicitConversions\n\nobject `package` {\n  implicit def jsStringContext(sc: StringContext): JsStrings = new JsStrings(sc)\n}\n"
  },
  {
    "path": "js/shared/src/main/scala/rapture/js/validator.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.js\n\nimport rapture.core._\n\nimport javax.script._\n\nprivate[js] object JsValidator {\n\n  case class ValidationException(strNo: Int, pos: Int, msg: String) extends Exception\n\n  def validate(parts: List[String]): Unit = {\n    val script = parts.mkString(\"null\")\n    val engine: Compilable = alloc[ScriptEngineManager]().getEngineByName(\"JavaScript\") match {\n      case e: Compilable => e\n    }\n\n    try engine.compile(script)\n    catch {\n      case e: ScriptException =>\n        val pos = script.split(\"\\n\").take(e.getLineNumber - 1).map(_.length + 1).sum + e.getColumnNumber\n        val Regex = \"<eval>:[0-9]+:[0-9]+ (.*)$\".r\n        println(\"pos = \" + pos)\n        val msg = e.getMessage.split(\"\\n\").head match { case Regex(m) => m }\n\n        throw ValidationException(0, pos, msg)\n    }\n  }\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nimport rapture.core._\nimport rapture.data._\n\n/** Represents a JSON ast implementation which is used throughout this library */\ntrait JsonAst extends DataAst {\n\n  def isScalar(any: Any) = isBoolean(any) || isNumber(any) || isString(any)\n\n  /** Extracts a `Boolean` from the parsed JSON. */\n  def getBoolean(boolean: Any): Boolean\n\n  def fromBoolean(boolean: Boolean): Any\n\n  /** Extracts a `String` from the parsed JSON. */\n  def getString(string: Any): String\n\n  def fromString(string: String): Any\n\n  /** Extracts a `Double` from the parsed JSON. */\n  def getDouble(number: Any): Double\n\n  def fromDouble(number: Double): Any\n\n  /** Extracts a `BigDecimal` from the parsed JSON. */\n  def getBigDecimal(number: Any): BigDecimal\n\n  def fromBigDecimal(number: BigDecimal): Any\n\n  /** Tests if the element represents a `Boolean` */\n  def isBoolean(any: Any): Boolean\n\n  /** Tests if the element represents a `String` */\n  def isString(any: Any): Boolean\n\n  /** Tests if the element represents a number */\n  def isNumber(any: Any): Boolean\n\n  /** Tests if the element represents a `null` */\n  def isNull(any: Any): Boolean\n\n  /** The value used to represent a `null` */\n  def nullValue: Any\n\n  /** Returns the DataType instance for the particular type. */\n  def getType(any: Any): DataTypes.DataType =\n    if (isBoolean(any)) DataTypes.Boolean\n    else if (isString(any)) DataTypes.String\n    else if (isNumber(any)) DataTypes.Number\n    else if (isObject(any)) DataTypes.Object\n    else if (isArray(any)) DataTypes.Array\n    else if (isNull(any)) DataTypes.Null\n    else throw MissingValueException()\n\n  def convert(v: Any, ast: DataAst): Any = {\n    val oldAst = ast.asInstanceOf[JsonAst]\n    if (oldAst.isString(v)) fromString(oldAst.getString(v))\n    else if (oldAst.isBoolean(v)) fromBoolean(oldAst.getBoolean(v))\n    else if (oldAst.isNumber(v)) fromDouble(oldAst.getDouble(v))\n    else if (oldAst.isArray(v)) fromArray(oldAst.getArray(v).map(convert(_, oldAst)))\n    else if (oldAst.isObject(v)) fromObject(oldAst.getObject(v).mapValues(convert(_, oldAst)))\n    else nullValue\n  }\n\n  protected def typeTest(pf: PartialFunction[Any, Unit])(v: Any) = pf.isDefinedAt(v)\n}\n\ntrait JsonBufferAst extends JsonAst with MutableDataAst\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/context.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nimport rapture.base._\nimport rapture.core._\nimport rapture.data._\n\nimport language.experimental.macros\n\nprivate[json] object JsonDataMacros extends DataContextMacros[Json, JsonAst] {\n\n  def dataCompanion(c: BlackboxContext): c.Expr[DataCompanion[Json, JsonAst]] = c.universe.reify(Json)\n\n  def parseSource(s: List[String], stringsUsed: List[Boolean]) =\n    try {\n      JsonValidator.validate(s, stringsUsed)\n      None\n    } catch {\n      case JsonValidator.ValidationException(strNo, pos, expected, found) =>\n        val f = if (found == '\\u0000') \"end of input\" else s\"'$found'\"\n        Some((strNo, pos, s\"failed to parse Json literal: expected $expected, but found $f\"))\n      case JsonValidator.DuplicateKeyException(strNo, pos, key) =>\n        Some((strNo, pos, s\"\"\"duplicate key found in Json literal: \"$key\"\"\"\"))\n      case JsonValidator.NonStringKeyException(strNo, pos) =>\n        Some((strNo, pos, s\"\"\"only Strings may be used as JSON object keys\"\"\"))\n    }\n\n  override def contextMacro(c: BlackboxContext)(exprs: c.Expr[ForcedConversion[Json]]*)(\n      parser: c.Expr[Parser[String, JsonAst]]): c.Expr[Json] =\n    super.contextMacro(c)(exprs: _*)(parser)\n\n}\n\nprivate[json] object JsonBufferDataMacros extends DataContextMacros[JsonBuffer, JsonBufferAst] {\n\n  def dataCompanion(c: BlackboxContext): c.Expr[DataCompanion[JsonBuffer, JsonBufferAst]] =\n    c.universe.reify(JsonBuffer)\n\n  def parseSource(s: List[String], stringsUsed: List[Boolean]) =\n    try {\n      JsonValidator.validate(s, stringsUsed)\n      None\n    } catch {\n      case JsonValidator.ValidationException(strNo, pos, expected, found) =>\n        val f = if (found == '\\u0000') \"end of input\" else s\"'$found'\"\n        Some((strNo, pos, s\"Failed to parse JsonBuffer literal: Expected $expected, but found $f.\"))\n    }\n\n  override def contextMacro(c: BlackboxContext)(exprs: c.Expr[ForcedConversion[JsonBuffer]]*)(\n      parser: c.Expr[Parser[String, JsonBufferAst]]): c.Expr[JsonBuffer] =\n    super.contextMacro(c)(exprs: _*)(parser)\n}\n\n/** Provides support for JSON literals, in the form json\" { } \" or json\"\"\" { } \"\"\".\n  * Interpolation is used to substitute variable names into the JSON, and to extract values\n  * from a JSON string. */\nprivate[json] class JsonStrings(sc: StringContext) {\n  class JsonContext() extends DataContext(Json, sc) {\n    def apply(exprs: ForcedConversion[Json]*)(implicit parser: Parser[String, JsonAst]): Json = macro JsonDataMacros.contextMacro\n  }\n  val json = new JsonContext()\n}\n\nprivate[json] class JsonBufferStrings(sc: StringContext) {\n  class JsonBufferContext() extends DataContext(JsonBuffer, sc) {\n    def apply(exprs: ForcedConversion[JsonBuffer]*)(implicit parser: Parser[String, JsonBufferAst]): JsonBuffer = macro JsonBufferDataMacros.contextMacro\n  }\n  val jsonBuffer = new JsonBufferContext()\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nimport rapture.core._\nimport rapture.data._\n\nimport scala.util._\n\nimport language.higherKinds\n\nprivate[json] case class JsonCastExtractor[T](ast: JsonAst, dataType: DataTypes.DataType)\n\nprivate[json] trait Extractors extends Extractors_1 {\n\n  implicit def optionExtractor[T](\n      implicit ext: Extractor[T, Json]): Extractor[Option[T], Json] { type Throws = Nothing } =\n    GeneralExtractors.optionExtractor[Json, T]\n\n  implicit def tryExtractor[T](implicit ext: Extractor[T, Json]): Extractor[Try[T], Json] { type Throws = Nothing } =\n    GeneralExtractors.tryExtractor[Json, T]\n\n  implicit def genSeqExtractor[T, Coll[_]](\n      implicit cbf: scala.collection.generic.CanBuildFrom[Nothing, T, Coll[T]],\n      ext: Extractor[T, Json]): Extractor[Coll[T], Json] { type Throws = ext.Throws } = {\n\n    GeneralExtractors.genSeqExtractor[T, Coll, Json]\n  }\n\n  implicit def mapExtractor[K, V](implicit ext: Extractor[V, Json],\n                                  ext2: StringParser[K]): Extractor[Map[K, V], Json] =\n    GeneralExtractors.mapExtractor[K, V, Json]\n\n}\n\nprivate[json] trait Extractors_1 extends Extractors_2 {\n\n  implicit def jsonExtractor(implicit ast: JsonAst): Extractor[Json, Json] { type Throws = DataGetException } =\n    new Extractor[Json, Json] {\n      type Throws = DataGetException\n      def extract(any: Json, dataAst: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Json, DataGetException] =\n        mode.wrap(mode.catching[DataGetException, Json](any.$wrap(any.$normalize)))\n    }\n\n  implicit val stringExtractor: Extractor[String, Json] { type Throws = DataGetException } =\n    new Extractor[String, Json] {\n      type Throws = DataGetException\n      def extract(any: Json, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[String, DataGetException] =\n        mode.wrap(mode.catching[DataGetException, String](any.$ast.getString(any.$normalize)))\n    }\n\n  implicit val nullExtractor: Extractor[Null, Json] { type Throws = DataGetException } = new Extractor[Null, Json] {\n    type Throws = DataGetException\n    override def extract(any: Json, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Null, this.Throws] = {\n      mode.wrap(\n          mode.catching[DataGetException, Null](\n              if (any.$ast.isNull(any.$normalize)) null\n              else throw TypeMismatchException(any.$ast.getType(any.$normalize), DataTypes.Null)\n          ))\n    }\n  }\n\n  implicit val doubleExtractor: Extractor[Double, Json] { type Throws = DataGetException } =\n    new Extractor[Double, Json] {\n      type Throws = DataGetException\n      def extract(any: Json, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Double, Throws] =\n        mode.wrap(mode.catching[DataGetException, Double](any.$ast.getDouble(any.$normalize)))\n    }\n\n  implicit val intExtractor: Extractor[Int, Json] { type Throws = DataGetException } = doubleExtractor.smap(_.toInt)\n\n  implicit val booleanExtractor: Extractor[Boolean, Json] { type Throws = DataGetException } =\n    new Extractor[Boolean, Json] {\n      type Throws = DataGetException\n      def extract(any: Json, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Boolean, DataGetException] =\n        mode.wrap(any.$ast.getBoolean(any.$normalize))\n    }\n\n  implicit val bigDecimalExtractor: Extractor[BigDecimal, Json] { type Throws = DataGetException } =\n    new Extractor[BigDecimal, Json] {\n      type Throws = DataGetException\n      def extract(any: Json,\n                  ast: DataAst,\n                  mode: Mode[_ <: MethodConstraint]): mode.Wrap[BigDecimal, DataGetException] =\n        mode.wrap(any.$ast.getBigDecimal(any.$normalize))\n    }\n\n  implicit val bigIntExtractor: Extractor[BigInt, Json] { type Throws = DataGetException } =\n    bigDecimalExtractor.smap(_.toBigInt)\n\n  implicit val longExtractor: Extractor[Long, Json] { type Throws = DataGetException } = bigIntExtractor.smap(_.toLong)\n\n  implicit val byteExtractor: Extractor[Byte, Json] { type Throws = DataGetException } = intExtractor.smap(_.toByte)\n\n  implicit val floatExtractor: Extractor[Float, Json] { type Throws = DataGetException } =\n    doubleExtractor.smap(_.toFloat)\n\n  implicit val shortExtractor: Extractor[Short, Json] { type Throws = DataGetException } = intExtractor.smap(_.toShort)\n\n}\n\nprivate[json] trait Extractors_2 {\n\n  implicit def jsonBufferExtractor[T](implicit jsonAst: JsonAst,\n                                      ext: Extractor[T, Json]): Extractor[T, JsonBuffer] { type Throws = ext.Throws } =\n    new Extractor[T, JsonBuffer] {\n      type Throws = ext.Throws\n      def extract(any: JsonBuffer, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, ext.Throws] =\n        ext.extract(Json.construct(MutableCell(any.$root.value), Vector()), ast, mode)\n    }\n\n  implicit def jsonBufferToJsonExtractor(implicit ast: JsonBufferAst): Extractor[JsonBuffer, Json] =\n    new Extractor[JsonBuffer, Json] {\n      type Throws = DataGetException\n      def extract(any: Json, dataAst: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[JsonBuffer, Throws] =\n        mode.wrap(JsonBuffer.construct(MutableCell(JsonDataType.jsonSerializer.serialize(any)), Vector()))\n    }\n\n  implicit def generalStringExtractor[S](implicit parser: StringParser[S]): Extractor[S, Json] {\n    type Throws = DataGetException with parser.Throws\n  } = new Extractor[S, Json] {\n    type Throws = DataGetException with parser.Throws\n    def extract(any: Json,\n                ast: DataAst,\n                mode: Mode[_ <: MethodConstraint]): mode.Wrap[S, DataGetException with parser.Throws] =\n      mode.wrap(mode.unwrap(parser.parse(any.$ast.getString(any.$normalize), mode)))\n  }\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/formatters.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nimport rapture.core._\nimport rapture.data._\n\nobject formatters extends formatters_1 {\n  object compact {\n    def apply[Ast <: JsonAst]()(implicit ast: Ast, df: DecimalFormat): Formatter[Ast] { type Out = String } =\n      jsonFormatterImplicit[Ast]\n\n    implicit def jsonFormatterImplicit[Ast <: JsonAst](implicit ast: Ast,\n                                                       df: DecimalFormat): Formatter[Ast] { type Out = String } =\n      new Formatter[Ast] {\n        type Out = String\n        def format(json: Any): String = general(json, 0, ast, \"\", \"\")\n      }\n  }\n}\n\nprivate[json] class formatters_1 {\n\n  /** Formats the JSON object for multi-line readability. */\n  protected def general[Ast <: JsonAst](json: Any, ln: Int, ast: Ast, pad: String = \" \", brk: String = \"\\n\")(\n      implicit df: DecimalFormat): String = {\n    val indent = pad * ln\n    json match {\n      case j =>\n        if (ast.isString(j)) {\n          \"\\\"\" + ast\n            .getString(j)\n            .replaceAll(\"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\")\n            .replaceAll(\"\\r\", \"\\\\\\\\r\")\n            .replaceAll(\"\\t\", \"\\\\\\\\t\")\n            .replaceAll(\"\\n\", \"\\\\\\\\n\")\n            .replaceAll(\"\\\"\", \"\\\\\\\\\\\"\") + \"\\\"\"\n\n        } else if (ast.isBoolean(j)) {\n          if (ast.getBoolean(j)) \"true\" else \"false\"\n        } else if (ast.isNumber(j)) {\n          val bd = ast.getBigDecimal(j)\n          if (bd.isWhole) String(bd.toBigInt) else String(df.format(bd))\n        } else if (ast.isArray(j)) {\n          val arr = ast.getArray(j)\n          if (arr.isEmpty) \"[]\"\n          else\n            List(\"[\", arr map { v =>\n              s\"${indent}${pad}${general(v, ln + 1, ast, pad, brk)}\"\n            } mkString s\",${brk}\", s\"${indent}]\") mkString brk\n        } else if (ast.isObject(j)) {\n          val keys = ast.getKeys(j)\n          if (keys.isEmpty) \"{}\"\n          else\n            List(\"{\", keys map { k =>\n              val inner = ast.dereferenceObject(j, k)\n              s\"\"\"${indent}${pad}\"${k}\":${pad}${general(inner, ln + 1, ast, pad, brk)}\"\"\"\n            } mkString s\",${brk}\", s\"${indent}}\") mkString brk\n        } else if (ast.isNull(j)) \"null\"\n        else if (j == DataCompanion.Empty) \"empty\"\n        else \"undefined\"\n    }\n  }\n\n  object humanReadable {\n    def apply[Ast <: JsonAst]()(implicit ast: Ast): Formatter[Ast] { type Out = String } =\n      jsonFormatterImplicit[Ast]\n\n    implicit def jsonFormatterImplicit[Ast <: JsonAst](implicit ast: Ast,\n                                                       df: DecimalFormat): Formatter[Ast] { type Out = String } =\n      new Formatter[Ast] {\n        type Out = String\n        def format(json: Any): String = general(json, 0, ast, \" \", \"\\n\")\n      }\n  }\n\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/json.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nimport rapture.core._\nimport rapture.data._\n\nimport language.experimental.macros\n\nprivate[json] trait Json_2 {\n  implicit def jsonExtractorMacro[T <: Product, Th]: Extractor[T, Json] = macro JsonMacros\n    .jsonExtractorMacro[T, Th]\n\n  implicit def jsonSerializerMacro[T <: Product](implicit ast: JsonAst): Serializer[T, Json] = macro JsonMacros\n    .jsonSerializerMacro[T]\n}\n\nprivate[json] trait Json_1 extends Json_2 {\n  implicit def dynamicWorkaround(j: Json) = new DynamicWorkaround(j)\n}\n\nprivate[json] class DynamicWorkaround(json: Json) {\n  def self: Json = json.selectDynamic(\"self\")(null)\n}\n\ntrait `Json.parse` extends MethodConstraint\n\nprivate[json] trait JsonDataCompanion[+Type <: JsonDataType[Type, AstType], AstType <: JsonAst]\n    extends DataCompanion[Type, AstType] {\n\n  type ParseMethodConstraint = `Json.parse`\n\n  /** Formats the JSON object for multi-line readability. */\n  private[json] def doFormat(json: Any, ln: Int, ast: AstType, pad: String = \" \", brk: String = \"\\n\"): String = {\n    val indent = pad * ln\n    json match {\n      case j =>\n        if (ast.isString(j)) {\n          \"\\\"\" + ast\n            .getString(j)\n            .replaceAll(\"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\")\n            .replaceAll(\"\\r\", \"\\\\\\\\r\")\n            .replaceAll(\"\\n\", \"\\\\\\\\n\")\n            .replaceAll(\"\\\"\", \"\\\\\\\\\\\"\") + \"\\\"\"\n        } else if (ast.isBoolean(j)) {\n          if (ast.getBoolean(j)) \"true\" else \"false\"\n        } else if (ast.isNumber(j)) {\n          val n = ast.getDouble(j)\n          if (n == n.floor) n.toInt.toString else String(n)\n        } else if (ast.isArray(j)) {\n          val arr = ast.getArray(j)\n          if (arr.isEmpty) \"[]\"\n          else\n            List(\"[\", arr map { v =>\n              s\"${indent}${pad}${doFormat(v, ln + 1, ast, pad, brk)}\"\n            } mkString s\",${brk}\", s\"${indent}]\") mkString brk\n        } else if (ast.isObject(j)) {\n          val keys = ast.getKeys(j)\n          if (keys.isEmpty) \"{}\"\n          else\n            List(\"{\", keys map { k =>\n              val inner = ast.dereferenceObject(j, k)\n              s\"\"\"${indent}${pad}\"${k}\":${pad}${doFormat(inner, ln + 1, ast, pad, brk)}\"\"\"\n            } mkString s\",${brk}\", s\"${indent}}\") mkString brk\n        } else if (ast.isNull(j)) \"null\"\n        else if (j == DataCompanion.Empty) \"empty\"\n        else \"undefined\"\n    }\n  }\n}\n\nprivate[json] object JsonDataType extends Extractors with Serializers\n\nprivate[json] trait JsonDataType[+T <: JsonDataType[T, AstType], AstType <: JsonAst] extends DataType[T, AstType]\n\nobject JsonBuffer extends JsonDataCompanion[JsonBuffer, JsonBufferAst] {\n\n  def construct(any: MutableCell, path: Vector[Either[Int, String]])(implicit ast: JsonBufferAst): JsonBuffer =\n    new JsonBuffer(any, path)\n}\n\n/** Companion object to the `Json` type, providing factory and extractor methods, and a JSON\n  * pretty printer. */\nobject Json extends JsonDataCompanion[Json, JsonAst] with Json_1 {\n  \n  def apply[T](t: T)(implicit ast: JsonAst, ser: Serializer[T, Json]): Json =\n    construct(MutableCell(if(t == null) ast.nullValue else ser.serialize(t)), Vector())\n\n  implicit def stringParser(implicit parser: Parser[String, JsonAst],\n                            mode: Mode[_ <: ParseMethodConstraint]): StringParser[Json] =\n    new StringParser[Json] {\n      type Throws = rapture.data.ParseException\n      def parse(str: String, mode2: Mode[_ <: MethodConstraint]): mode2.Wrap[Json, rapture.data.ParseException] =\n        mode2.wrap {\n          mode.unwrap(Json.parse(str)(implicitly[StringSerializer[String]], mode, parser))\n        }\n    }\n\n  def construct(any: MutableCell, path: Vector[Either[Int, String]])(implicit ast: JsonAst): Json = new Json(any, path)\n\n  def ast(json: Json): JsonAst = json.$ast\n\n  def extractor[T](implicit ext: Extractor[T, Json]): Extractor[T, Json] { type Throws = ext.Throws } = ext\n  def serializer[T](implicit ser: Serializer[T, Json]) = ser\n\n  implicit def jsonCastExtractor[T: JsonCastExtractor](\n      implicit ast: JsonAst): Extractor[T, JsonDataType[_, _ <: JsonAst]] =\n    new Extractor[T, JsonDataType[_, _ <: JsonAst]] {\n      type Throws = DataGetException\n      def extract(value: JsonDataType[_, _ <: JsonAst],\n                  ast2: DataAst,\n                  mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, DataGetException] =\n        mode.wrap(ast2 match {\n          case ast2: JsonAst =>\n            val norm = mode.catching[DataGetException, Any](value.$normalize)\n            try {\n              if (ast == ast2) norm.asInstanceOf[T]\n              else\n                JsonDataType.jsonSerializer\n                  .serialize(Json.construct(MutableCell(norm), Vector())(ast2))\n                  .asInstanceOf[T]\n            } catch {\n              case e: ClassCastException =>\n                mode.exception[T, DataGetException](\n                    TypeMismatchException(ast.getType(norm), implicitly[JsonCastExtractor[T]].dataType))\n            }\n          case _ => ???\n        })\n    }\n\n}\n\n/** Represents some parsed JSON. */\nclass Json(val $root: MutableCell, val $path: Vector[Either[Int, String]] = Vector())(implicit val $ast: JsonAst)\n    extends JsonDataType[Json, JsonAst]\n    with DynamicData[Json, JsonAst] {\n\n  def $wrap(any: Any, path: Vector[Either[Int, String]]): Json =\n    new Json(MutableCell(any), path)\n\n  def $deref(path: Vector[Either[Int, String]]): Json = new Json($root, path)\n\n  def applyDynamic(key: String)(i: Int = 0): Json = $deref(Left(i) +: Right(key) +: $path)\n\n  def $extract(sp: Vector[Either[Int, String]]): Json =\n    if (sp.isEmpty) this\n    else\n      sp match {\n        case Left(i) +: tail => apply(i).$extract(tail)\n        case Right(e) +: tail => selectDynamic(e)(null).$extract(tail)\n      }\n\n  def toBareString: String =\n    try Json.format(this)(formatters.compact.jsonFormatterImplicit($ast, decimalFormats.exact()))\n    catch {\n      case e: Exception => \"undefined\"\n    }\n\n  override def toString: String = s\"\"\"json\"\"${'\"'}${toBareString}\"\"${'\"'}\"\"\"\n}\n\nclass JsonBuffer(val $root: MutableCell, val $path: Vector[Either[Int, String]] = Vector())(\n    implicit val $ast: JsonBufferAst)\n    extends JsonDataType[JsonBuffer, JsonBufferAst]\n    with MutableDataType[JsonBuffer, JsonBufferAst]\n    with DynamicData[JsonBuffer, JsonBufferAst] {\n\n  def applyDynamic(key: String)(i: Int = 0): JsonBuffer = $deref(Left(i) +: Right(key) +: $path)\n\n  def $wrap(any: Any, path: Vector[Either[Int, String]]): JsonBuffer =\n    new JsonBuffer(MutableCell(any), path)\n\n  def $deref(path: Vector[Either[Int, String]]): JsonBuffer = new JsonBuffer($root, path)\n\n  def $extract(sp: Vector[Either[Int, String]]): JsonBuffer =\n    if (sp.isEmpty) this\n    else\n      sp match {\n        case Left(i) +: tail => apply(i).$extract(tail)\n        case Right(e) +: tail => selectDynamic(e)(null).$extract(tail)\n      }\n\n  def toBareString: String =\n    try Json.format(this)(formatters.compact.jsonFormatterImplicit($ast, decimalFormats.exact()))\n    catch {\n      case e: Exception => \"undefined\"\n    }\n\n  override def toString: String = s\"\"\"json\"\"${'\"'}${toBareString}\"\"${'\"'}\"\"\"\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/macros.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nimport rapture.base._\nimport rapture.data._\n\nprivate[json] object JsonMacros {\n  def jsonExtractorMacro[T: c.WeakTypeTag, Th](c: WhiteboxContext): c.Expr[Extractor[T, Json]] =\n    Macros.extractorMacro[T, Json, Th](c)\n\n  //def jsonBufferExtractorMacro[T: c.WeakTypeTag](c: Context) =\n  //  Macros.extractorMacro2[T, JsonBuffer](c)\n\n  def jsonSerializerMacro[T: c.WeakTypeTag](c: WhiteboxContext)(ast: c.Expr[JsonAst]): c.Expr[Serializer[T, Json]] =\n    Macros.serializerMacro[T, Json](c)(ast)\n\n  def jsonBufferSerializerMacro[T: c.WeakTypeTag](c: WhiteboxContext)(\n      ast: c.Expr[JsonBufferAst]): c.Expr[Serializer[T, JsonBuffer]] =\n    Macros.serializerMacro[T, JsonBuffer](c)(ast)\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nimport rapture.core._\nimport rapture.data._\n\nobject `package` {\n\n  val patternMatching = rapture.data.patternMatching\n\n  type Extractor[T, -D] = rapture.data.Extractor[T, D]\n  type Serializer[T, -D] = rapture.data.Serializer[T, D]\n  type DataGetException = rapture.data.DataGetException\n  type TypeMismatchException = rapture.data.TypeMismatchException\n  type MissingValueException = rapture.data.MissingValueException\n  type Dictionary[S <: String] = rapture.data.Dictionary[S]\n\n  val Dictionary = rapture.data.Dictionary\n  val TypeMismatchException = rapture.data.TypeMismatchException\n  val MissingValueException = rapture.data.MissingValueException\n\n  implicit def jsonStringContext(sc: StringContext)(implicit parser: Parser[String, JsonAst]) =\n    new JsonStrings(sc)\n\n  implicit def jsonBufferStringContext(sc: StringContext)(implicit parser: Parser[String, JsonBufferAst]) =\n    new JsonBufferStrings(sc)\n\n  implicit class JsonOperations(json: Json) extends DataType.DataClassOperations[Json, JsonAst](json)\n\n  val dictionaries = rapture.data.dictionaries\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nimport rapture.core._\nimport rapture.data._\n\nimport language.higherKinds\n\nprivate[json] case class DirectJsonSerializer[T](ast: JsonAst)\n\nprivate[json] case class BasicJsonSerializer[T](serialization: T => Any) extends Serializer[T, Json] {\n  def serialize(t: T): Any = serialization(t)\n}\n\nprivate[json] trait Serializers extends Serializers_1 {\n\n  implicit def jsonBufferSerializer[T](implicit ser: Serializer[T, Json]): Serializer[T, JsonBuffer] =\n    new Serializer[T, JsonBuffer] { def serialize(t: T): Any = ser.serialize(t) }\n\n  implicit def intSerializer(implicit ast: JsonAst): Serializer[Int, Json] =\n    BasicJsonSerializer(ast fromDouble _.toDouble)\n\n  implicit def booleanSerializer(implicit ast: JsonAst): Serializer[Boolean, Json] =\n    BasicJsonSerializer(ast fromBoolean _)\n\n  implicit def stringSerializer(implicit ast: JsonAst): Serializer[String, Json] =\n    BasicJsonSerializer(ast fromString _)\n\n  implicit def floatSerializer(implicit ast: JsonAst): Serializer[Float, Json] =\n    BasicJsonSerializer(ast fromDouble _.toDouble)\n\n  implicit def doubleSerializer(implicit ast: JsonAst): Serializer[Double, Json] =\n    BasicJsonSerializer(ast fromDouble _)\n\n  implicit def bigDecimalSerializer(implicit ast: JsonAst): Serializer[BigDecimal, Json] =\n    BasicJsonSerializer(ast fromBigDecimal _)\n\n  implicit def bigIntSerializer(implicit ast: JsonAst): Serializer[BigInt, Json] =\n    BasicJsonSerializer(ast fromBigDecimal BigDecimal(_))\n\n  implicit def longSerializer(implicit ast: JsonAst): Serializer[Long, Json] =\n    BasicJsonSerializer(ast fromDouble _.toDouble)\n\n  implicit def shortSerializer(implicit ast: JsonAst): Serializer[Short, Json] =\n    BasicJsonSerializer(ast fromDouble _.toDouble)\n\n  implicit def byteSerializer(implicit ast: JsonAst): Serializer[Byte, Json] =\n    BasicJsonSerializer(ast fromDouble _.toDouble)\n\n  implicit def nilSerializer(implicit ast: JsonAst): Serializer[Nil.type, Json] =\n    BasicJsonSerializer(v => ast fromArray Nil)\n\n  implicit def traversableSerializer[Type, Coll[T] <: Traversable[T]](\n      implicit ast: JsonAst,\n      ser: Serializer[Type, Json]): Serializer[Coll[Type], Json] =\n    BasicJsonSerializer(ast fromArray _.map(ser.serialize).to[List])\n\n  implicit def optionSerializer[Type](implicit ast: JsonAst,\n                                      ser: Serializer[Type, Json]): Serializer[Option[Type], Json] =\n    BasicJsonSerializer(_ map ser.serialize getOrElse ast.nullValue)\n\n  implicit def mapSerializer[K, Type, Ast <: JsonAst](implicit ast: Ast,\n                                                      ser: Serializer[Type, Json],\n                                                      ser2: StringSerializer[K]): Serializer[Map[K, Type], Json] =\n    new Serializer[Map[K, Type], Json] {\n      def serialize(m: Map[K, Type]) =\n        ast.fromObject(m.map {\n          case (k, v) =>\n            ser2.serialize(k) -> ser.serialize(v)\n        })\n    }\n\n  implicit def directJsonSerializer[T: DirectJsonSerializer](implicit ast: JsonAst): Serializer[T, Json] =\n    BasicJsonSerializer(\n        obj => jsonSerializer.serialize(Json.construct(MutableCell(obj), Vector())(?[DirectJsonSerializer[T]].ast)))\n\n  implicit def jsonSerializer[JsonType <: JsonDataType[JsonType, _ <: JsonAst]](\n      implicit ast: JsonAst): Serializer[JsonType, Json] =\n    BasicJsonSerializer[JsonType]({ j =>\n      if (j.$ast == ast) j.$normalize else ast.convert(j.$normalize, j.$ast)\n    })\n}\n\ntrait Serializers_1 {\n  implicit def generalStringSerializer[S](implicit ast: JsonAst, ss: StringSerializer[S]): Serializer[S, Json] =\n    BasicJsonSerializer(s => ast fromString ss.serialize(s))\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/validator.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nprivate[json] object JsonValidator {\n\n  case class ValidationException(strNo: Int, pos: Int, expected: String, found: Char) extends Exception\n\n  case class DuplicateKeyException(strNo: Int, pos: Int, key: String) extends Exception\n\n  case class NonStringKeyException(strNo: Int, pos: Int) extends Exception\n\n  def validate(parts: List[String], stringsUsed: List[Boolean]) = {\n    var i = 0\n    var n = 0\n    def s = parts(n)\n    def cur = if (i >= s.length) '\\u0000' else s(i)\n\n    def fail(expected: String) = throw ValidationException(n, i, expected, cur)\n    def failPosition(expected: String) = throw ValidationException(n, i, expected, cur)\n    def duplicateKey(start: Int, key: String) = throw DuplicateKeyException(n, start, key)\n\n    def takeWhitespace(): Unit = while (cur.isWhitespace) next()\n\n    def consume(cs: Char*): Unit = cs foreach { c =>\n      if (cur == c) next() else fail(s\"'$c'\")\n    }\n\n    def next() = i += 1\n\n    def takeValue(): Unit = cur match {\n      case '{' => takeObject()\n      case '[' => takeArray()\n      case '\"' => takeString()\n      case c if c.isDigit || c == '-' => takeNumber()\n      case 't' => takeTrue()\n      case 'f' => takeFalse()\n      case 'n' => takeNull()\n      case '\\u0000' =>\n        if (n + 1 < parts.length) {\n          n += 1\n          i = 0\n        } else fail(\"new token or interpolated value\")\n      case _ => fail(\"new token\")\n    }\n\n    def takeTrue() = consume('t', 'r', 'u', 'e')\n    def takeFalse() = consume('f', 'a', 'l', 's', 'e')\n    def takeNull() = consume('n', 'u', 'l', 'l')\n\n    def takeNumber() = {\n      if (cur == '-') next()\n\n      if (cur == '0') next()\n      else if (cur.isDigit) while (cur.isDigit) next()\n      else fail(\"digit\")\n\n      if (cur == '.') {\n        next()\n        if (cur.isDigit) next() else fail(\"digit\")\n        while (cur.isDigit) next()\n      }\n\n      if (cur == 'e' || cur == 'E') {\n        next()\n        if (cur == '+' || cur == '-') next()\n        if (cur.isDigit) next() else fail(\"digit\")\n        while (cur.isDigit) next()\n      }\n    }\n\n    def takeObject(): Unit = {\n      var seen: Set[String] = Set()\n      def takeKeyValue(): Unit = {\n        val start = i\n        cur match {\n          case '\\u0000' =>\n            if (n + 1 < parts.length) {\n              if (!stringsUsed(n)) throw new NonStringKeyException(n, i)\n              n += 1\n              i = 0\n            } else fail(\"new token or interpolated value\")\n          case '\"' =>\n            takeString()\n            val key = s.substring(start + 1, i - 1)\n            if (seen contains key) duplicateKey(start, key) else seen += key\n        }\n        takeWhitespace()\n        cur match {\n          case ':' =>\n            consume(':')\n            takeWhitespace()\n            takeValue()\n            takeWhitespace()\n            cur match {\n              case ',' =>\n                consume(',')\n                takeWhitespace()\n                takeKeyValue()\n              case '}' => consume('}')\n              case _ => fail(\"',' or '}'\")\n            }\n          case _ => fail(\"':'\")\n        }\n      }\n\n      consume('{')\n      takeWhitespace()\n      cur match {\n        case '\"' | '\\u0000' => takeKeyValue()\n        case '}' => consume('}')\n        case _ => fail(\"'\\\"' or '}'\")\n      }\n    }\n\n    def takeArray(): Unit = {\n      def takeElement(): Unit = {\n        takeValue()\n        takeWhitespace()\n        cur match {\n          case ',' =>\n            consume(',')\n            takeWhitespace()\n            takeElement()\n          case ']' => consume(']')\n          case _ => fail(\"',' or ']'\")\n        }\n      }\n      consume('[')\n      takeWhitespace()\n      cur match {\n        case ']' => consume(']')\n        case _ => takeElement()\n      }\n    }\n\n    def takeString(): Unit = {\n      consume('\"')\n      while (cur != '\"') cur match {\n        case '\\\\' =>\n          consume('\\\\')\n          cur match {\n            case '\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' => next()\n            case 'u' =>\n              consume('u')\n              1 to 4 foreach { j =>\n                if (cur.isDigit || cur >= 'a' && cur <= 'f' || cur >= 'A' && cur <= 'F') next()\n                else fail(\"hexadecimal digit\")\n              }\n          }\n        case '\\u0000' => failPosition(\"'\\\"' or more string content\")\n        case _ => next()\n      }\n      consume('\"')\n    }\n\n    takeWhitespace()\n    takeValue()\n    takeWhitespace()\n    if (i != s.length) fail(\"end of data\")\n  }\n}\n"
  },
  {
    "path": "json/shared/src/main/scala/rapture/json/verifier.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json\n\nobject JsonVerifier {\n\n  case class VerifierException(strNo: Int, pos: Int, expected: String, found: Char) extends Exception\n  case class DuplicateKeyException(strNo: Int, pos: Int, key: String) extends Exception\n\n  def verify(parts: List[String]) = {\n    var i = 0\n    var n = 0\n    def s = parts(n)\n    def cur = if (i >= s.length) '\\u0000' else s(i)\n\n    def fail(expected: String) = throw VerifierException(n, i, expected, cur)\n    def failPosition(expected: String) = throw VerifierException(n, i, expected, cur)\n    def duplicateKey(start: Int, key: String) = throw DuplicateKeyException(n, start, key)\n\n    def takeWhitespace(): Unit = while (cur.isWhitespace) next()\n\n    def consume(cs: Char*): Unit = cs foreach { c =>\n      if (cur == c) next() else fail(s\"'$c'\")\n    }\n\n    def next() = i += 1\n\n    def takeValue(): Unit = cur match {\n      case '{' => takeObject()\n      case '[' => takeArray()\n      case '\"' => takeString()\n      case c if c.isDigit || c == '-' => takeNumber()\n      case 't' => takeTrue()\n      case 'f' => takeFalse()\n      case 'n' => takeNull()\n      case '\\u0000' =>\n        if (n + 1 < parts.length) {\n          n += 1\n          i = 0\n        } else fail(\"new token or interpolated value\")\n      case _ => fail(\"new token\")\n    }\n\n    def takeTrue() = consume('t', 'r', 'u', 'e')\n    def takeFalse() = consume('f', 'a', 'l', 's', 'e')\n    def takeNull() = consume('n', 'u', 'l', 'l')\n\n    def takeNumber() = {\n      if (cur == '-') next()\n\n      if (cur == '0') next()\n      else if (cur.isDigit) while (cur.isDigit) next()\n      else fail(\"digit\")\n\n      if (cur == '.') {\n        next()\n        if (cur.isDigit) next() else fail(\"digit\")\n        while (cur.isDigit) next()\n      }\n\n      if (cur == 'e' || cur == 'E') {\n        next()\n        if (cur == '+' || cur == '-') next()\n        if (cur.isDigit) next() else fail(\"digit\")\n        while (cur.isDigit) next()\n      }\n    }\n\n    def takeObject(): Unit = {\n      var seen: Set[String] = Set()\n      def takeKeyValue(): Unit = {\n        val start = i\n        takeString()\n        val key = s.substring(start + 1, i - 1)\n\n        if (seen contains key) duplicateKey(start, key) else seen += key\n\n        takeWhitespace()\n        cur match {\n          case ':' =>\n            consume(':')\n            takeWhitespace()\n            takeValue()\n            takeWhitespace()\n            cur match {\n              case ',' =>\n                consume(',')\n                takeWhitespace()\n                takeKeyValue()\n              case '}' => consume('}')\n              case _ => fail(\"',' or '}'\")\n            }\n          case _ => fail(\"':'\")\n        }\n      }\n\n      consume('{')\n      takeWhitespace()\n      cur match {\n        case '\"' => takeKeyValue()\n        case '}' => consume('}')\n        case _ => fail(\"'\\\"' or '}'\")\n      }\n    }\n\n    def takeArray(): Unit = {\n      def takeElement(): Unit = {\n        takeValue()\n        takeWhitespace()\n        cur match {\n          case ',' =>\n            consume(',')\n            takeWhitespace()\n            takeElement()\n          case ']' => consume(']')\n          case _ => fail(\"',' or ']'\")\n        }\n      }\n      consume('[')\n      takeWhitespace()\n      cur match {\n        case ']' => consume(']')\n        case _ => takeElement()\n      }\n    }\n\n    def takeString(): Unit = {\n      consume('\"')\n      while (cur != '\"') cur match {\n        case '\\\\' =>\n          consume('\\\\')\n          cur match {\n            case '\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't' => next()\n            case 'u' =>\n              consume('u')\n              1 to 4 foreach { j =>\n                if (cur.isDigit || cur >= 'a' && cur <= 'f' || cur >= 'A' && cur <= 'F') next()\n                else fail(\"hexadecimal digit\")\n              }\n          }\n        case '\\u0000' => failPosition(\"'\\\"' or more string content\")\n        case _ => next()\n      }\n      consume('\"')\n    }\n\n    takeWhitespace()\n    takeValue()\n    takeWhitespace()\n    if (i != s.length) fail(\"end of data\")\n  }\n}\n"
  },
  {
    "path": "json-argonaut/shared/src/main/scala/rapture/json-argonaut/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.argonaut\n\nimport rapture.core._\nimport rapture.data.DataTypes\nimport rapture.json._\n\nimport argonaut.{Json => AJson, _}\nimport Argonaut._\n\nprivate[argonaut] object ArgonautAst extends JsonBufferAst {\n\n  override def toString = \"<ArgonautAst>\"\n\n  override def dereferenceObject(obj: Any, element: String): Any =\n    obj match {\n      case j: AJson if j.isObject => j.field(element).getOrElse(throw MissingValueException())\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def getKeys(obj: Any): Iterator[String] =\n    obj match {\n      case j: AJson if j.isObject => j.objectFields.get.iterator\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def dereferenceArray(array: Any, element: Int): Any =\n    array match {\n      case j: AJson if j.isArray => j.array.get(element)\n      case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n    }\n\n  def getArray(array: Any): List[Any] = array match {\n    case j: AJson if j.isArray => j.array.get\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def getBoolean(boolean: Any): Boolean = boolean match {\n    case j: AJson if j.isBool => j.bool.get\n    case _ => throw TypeMismatchException(getType(boolean), DataTypes.Boolean)\n  }\n\n  def getDouble(double: Any): Double = double match {\n    case j: AJson if j.isNumber => j.number.get.toDouble.get\n    case _ => throw TypeMismatchException(getType(double), DataTypes.Number)\n  }\n\n  def getBigDecimal(bigDecimal: Any): BigDecimal = bigDecimal match {\n    case j: AJson if j.isNumber => BigDecimal(j.number.get.toBigInt.get)\n    case _ => throw TypeMismatchException(getType(bigDecimal), DataTypes.Number)\n  }\n\n  def getString(string: Any): String = string match {\n    case j: AJson if j.isString => j.string.get\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def getObject(obj: Any): Map[String, Any] = obj match {\n    case j: AJson if j.isObject => j.obj.get.toMap.map { case (k, v) => k.toString -> v }\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def setObjectValue(obj: Any, name: String, value: Any): Any = {\n    val contents = (name, value) :: obj.asInstanceOf[AJson].obj.get.toList.collect {\n      case (k, v) if k.toString != name => k.toString -> v\n    }\n    fromObject(contents.toMap)\n  }\n\n  def removeObjectValue(obj: Any, name: String): Any = {\n    val contents = obj.asInstanceOf[AJson].obj.get.toList.collect {\n      case (k, v) if k.toString != name => k.toString -> v\n    }\n    fromObject(contents.toMap)\n  }\n\n  def addArrayValue(array: Any, value: Any): Any =\n    fromArray(array.asInstanceOf[AJson].array.get :+ value)\n\n  def setArrayValue(array: Any, index: Int, value: Any): Any =\n    fromArray(array.asInstanceOf[AJson].array.get.padTo(index, nullValue).patch(index, Seq(value), 1))\n\n  def isArray(array: Any): Boolean = array match {\n    case j: AJson if j.isArray => true\n    case _ => false\n  }\n\n  def isBoolean(boolean: Any): Boolean = boolean match {\n    case j: AJson if j.isBool => true\n    case _ => false\n  }\n\n  def isNumber(num: Any): Boolean = num match {\n    case j: AJson if j.isNumber => true\n    case _ => false\n  }\n\n  def isString(string: Any): Boolean = string match {\n    case j: AJson if j.isString => true\n    case _ => false\n  }\n\n  def isObject(obj: Any): Boolean = obj match {\n    case j: AJson if j.isObject => true\n    case _ => false\n  }\n\n  def isNull(obj: Any): Boolean = obj match {\n    case j: AJson if j.isNull => true\n    case _ => false\n  }\n\n  def fromArray(array: Seq[Any]): Any = jArray(array.to[List] map { case v: AJson => v })\n  def fromBoolean(boolean: Boolean): Any = jBool(boolean)\n  def fromDouble(number: Double): Any = jNumber(number).get\n  def fromBigDecimal(number: BigDecimal): Any = jNumber(number.toDouble).get\n\n  def fromObject(obj: Map[String, Any]): Any =\n    AJson(obj.mapValues { case v: AJson => v }.to[List]: _*)\n\n  def fromString(string: String): Any = jString(string)\n\n  // FIXME: Is there a better way of getting a JNull?\n  lazy val nullValue: Any = argonaut.Parse.parseOption(\"null\").get\n\n}\n"
  },
  {
    "path": "json-argonaut/shared/src/main/scala/rapture/json-argonaut/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.argonaut\n\nimport rapture.json._\nimport rapture.data._\n\nimport argonaut.{Json => AJson, _}\n\nprivate[argonaut] trait Extractors {\n  implicit val argonautJObjectExtractor: JsonCastExtractor[JsonObject] =\n    JsonCastExtractor(ArgonautAst, DataTypes.Object)\n\n  implicit val argonautJValueExtractor: JsonCastExtractor[AJson] = JsonCastExtractor(ArgonautAst, DataTypes.Object)\n}\n"
  },
  {
    "path": "json-argonaut/shared/src/main/scala/rapture/json-argonaut/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.argonaut\n\nobject `package` extends Extractors with Serializers {\n  implicit val implicitJsonAst = ArgonautAst\n  implicit val implicitJsonStringParser = ArgonautParser\n}\n"
  },
  {
    "path": "json-argonaut/shared/src/main/scala/rapture/json-argonaut/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.argonaut\nimport rapture.core._\nimport rapture.data._\nimport rapture.json._\n\nimport argonaut._\n\nprivate[argonaut] object ArgonautParser extends Parser[String, JsonBufferAst] {\n\n  val ast = ArgonautAst\n\n  def parse(s: String): Option[Any] = Parse.parseOption(s)\n\n  override def toString = \"<ArgonautParser>\"\n}\n"
  },
  {
    "path": "json-argonaut/shared/src/main/scala/rapture/json-argonaut/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.argonaut\n\nimport rapture.json._\n\nimport argonaut.{Json => AJson}\n\nprivate[argonaut] trait Serializers {\n  implicit val argonautJValueSerializer: DirectJsonSerializer[AJson] = DirectJsonSerializer(ArgonautAst)\n}\n"
  },
  {
    "path": "json-circe/shared/src/main/scala/rapture/json-circe/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.circe\n\nimport rapture.core._\nimport rapture.data.DataTypes\nimport rapture.json._\n\nimport io.circe.{Json => CirceJson}\n\nprivate[circe] object CirceAst extends JsonBufferAst {\n\n  override def toString = \"<Circe>\"\n\n  override def dereferenceObject(obj: Any, element: String): Any = {\n    def fail(): Nothing = throw TypeMismatchException(getType(obj), DataTypes.Object)\n    obj match {\n      case j: CirceJson => j.asObject.getOrElse(fail())(element).get\n      case _ => fail()\n    }\n  }\n\n  override def getKeys(obj: Any): Iterator[String] = {\n    def fail(): Nothing = throw TypeMismatchException(getType(obj), DataTypes.Object)\n    obj match {\n      case j: CirceJson => j.asObject.getOrElse(fail()).fields.to[Iterator]\n      case _ => fail()\n    }\n  }\n\n  override def dereferenceArray(j: Any, elem: Int): Any = j match {\n    case j: CirceJson if j.isArray => j.asArray.get(elem)\n    case _ => throw TypeMismatchException(getType(j), DataTypes.Array)\n  }\n\n  def getArray(j: Any): List[Any] = j match {\n    case j: CirceJson if j.isArray => j.asArray.get.to[List]\n    case _ => throw TypeMismatchException(getType(j), DataTypes.Array)\n  }\n\n  def getBoolean(j: Any): Boolean = j match {\n    case j: CirceJson if j.isBoolean => j.asBoolean.get\n    case _ => throw TypeMismatchException(getType(j), DataTypes.Boolean)\n  }\n\n  def getDouble(double: Any): Double = double match {\n    case j: CirceJson if j.isNumber => j.asNumber.get.toDouble\n    case _ => throw TypeMismatchException(getType(double), DataTypes.Number)\n  }\n\n  def getBigDecimal(bigDecimal: Any): BigDecimal = bigDecimal match {\n    case j: CirceJson if j.isNumber =>\n      j.asNumber.get.toBigDecimal.getOrElse(throw TypeMismatchException(getType(bigDecimal), DataTypes.Number))\n    case _ =>\n      throw TypeMismatchException(getType(bigDecimal), DataTypes.Number)\n  }\n\n  def getString(string: Any): String = string match {\n    case j: CirceJson if j.isString => j.asString.get\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def getObject(obj: Any): Map[String, Any] = obj match {\n    case j: CirceJson if j.isObject => j.asObject.get.toMap.map { case (k, v) => k.toString -> v }\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def setObjectValue(obj: Any, name: String, value: Any): Any = {\n    val contents = (name, value) :: obj.asInstanceOf[CirceJson].asObject.get.toList.collect {\n      case (k, v) if k.toString != name => k.toString -> v\n    }\n    fromObject(contents.toMap)\n  }\n\n  def removeObjectValue(obj: Any, name: String): Any = {\n    val contents = obj.asInstanceOf[CirceJson].asObject.get.toList.collect {\n      case (k, v) if k.toString != name => k.toString -> v\n    }\n    fromObject(contents.toMap)\n  }\n\n  def addArrayValue(array: Any, value: Any): Any =\n    fromArray(array.asInstanceOf[CirceJson].asArray.get :+ value)\n\n  def setArrayValue(array: Any, index: Int, value: Any): Any =\n    fromArray(array.asInstanceOf[CirceJson].asArray.get.padTo(index, nullValue).patch(index, Seq(value), 1))\n\n  def isArray(array: Any): Boolean = array match {\n    case j: CirceJson if j.isArray => true\n    case _ => false\n  }\n\n  def isBoolean(boolean: Any): Boolean = boolean match {\n    case j: CirceJson if j.isBoolean => true\n    case _ => false\n  }\n\n  def isNumber(num: Any): Boolean = num match {\n    case j: CirceJson if j.isNumber => true\n    case _ => false\n  }\n\n  def isString(string: Any): Boolean = string match {\n    case j: CirceJson if j.isString => true\n    case _ => false\n  }\n\n  def isObject(obj: Any): Boolean = obj match {\n    case j: CirceJson if j.isObject => true\n    case _ => false\n  }\n\n  def isNull(obj: Any): Boolean = obj match {\n    case j: CirceJson if j.isNull => true\n    case _ => false\n  }\n\n  def fromArray(array: Seq[Any]): Any = CirceJson.arr(array.to[List].map { case v: CirceJson => v }: _*)\n  def fromBoolean(boolean: Boolean): Any = CirceJson.fromBoolean(boolean)\n  def fromDouble(number: Double): Any = CirceJson.fromDouble(number).get\n  def fromBigDecimal(number: BigDecimal): Any = CirceJson.fromBigDecimal(number)\n\n  def fromObject(obj: Map[String, Any]): Any =\n    CirceJson.obj(obj.mapValues { case v: CirceJson => v }.to[List]: _*)\n\n  def fromString(string: String): Any = CirceJson.fromString(string)\n\n  // FIXME: Is there a better way of getting a JNull?\n  lazy val nullValue: Any = CirceJson.Null\n\n}\n"
  },
  {
    "path": "json-circe/shared/src/main/scala/rapture/json-circe/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.circe\n\nimport rapture.json._\nimport rapture.data._\n\nimport io.circe.{Json => CirceJson, _}\n\nprivate[circe] trait Extractors {\n  implicit val circeJObjectExtractor: JsonCastExtractor[JsonObject] = JsonCastExtractor(CirceAst, DataTypes.Object)\n\n  implicit val circeJValueExtractor: JsonCastExtractor[CirceJson] = JsonCastExtractor(CirceAst, DataTypes.Object)\n}\n"
  },
  {
    "path": "json-circe/shared/src/main/scala/rapture/json-circe/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.circe\n\nobject `package` extends Extractors with Serializers {\n  implicit val implicitJsonAst = CirceAst\n  implicit val implicitJsonStringParser = CirceParser\n}\n"
  },
  {
    "path": "json-circe/shared/src/main/scala/rapture/json-circe/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.circe\nimport rapture.core._\nimport rapture.data._\nimport rapture.json._\n\nimport io.circe.jawn._\n\nprivate[circe] object CirceParser extends Parser[String, JsonBufferAst] {\n\n  val ast = CirceAst\n\n  def parse(s: String): Option[Any] = CirceSupportParser.parseFromString(s).toOption\n\n  override def toString = \"<CirceParser>\"\n}\n"
  },
  {
    "path": "json-circe/shared/src/main/scala/rapture/json-circe/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.circe\n\nimport rapture.json._\n\nimport io.circe.{Json => CirceJson}\n\nprivate[circe] trait Serializers {\n  implicit val circeJValueSerializer: DirectJsonSerializer[CirceJson] = DirectJsonSerializer(CirceAst)\n}\n"
  },
  {
    "path": "json-jackson/shared/src/main/scala/rapture/json-jackson/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jackson\nimport rapture.core._\nimport rapture.json._\nimport rapture.data.DataTypes\nimport com.fasterxml.jackson.databind._\nimport com.fasterxml.jackson.databind.node.NullNode\n\nimport scala.collection.JavaConverters._\n\n/** A type class for Jackson parsing */\nprivate[jackson] object JacksonAst extends JsonAst {\n\n  override def toString = \"<JacksonAst>\"\n\n  private val mapper = new ObjectMapper()\n    .enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)\n    .enable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS)\n\n  def getArray(array: Any): List[Any] = array match {\n    case list: JsonNode if list.isArray => asScalaIteratorConverter(list.elements).asScala.to[List]\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def getBoolean(boolean: Any): Boolean = boolean match {\n    case boolean: JsonNode if boolean.isBoolean => boolean.asBoolean\n    case _ => throw TypeMismatchException(getType(boolean), DataTypes.Boolean)\n  }\n\n  def getDouble(number: Any): Double = number match {\n    case number: JsonNode if number.isBigDecimal => number.decimalValue.doubleValue\n    case number: JsonNode if number.isBigInteger => number.bigIntegerValue.doubleValue\n    case number: JsonNode if number.isNumber => number.asDouble\n    case number: Double => number\n    case _ => throw TypeMismatchException(getType(number), DataTypes.Number)\n  }\n\n  def getBigDecimal(number: Any): BigDecimal = number match {\n    case number: JsonNode if number.isBigDecimal => BigDecimal(number.decimalValue)\n    case number: JsonNode if number.isBigInteger => BigDecimal(number.bigIntegerValue)\n    case number: JsonNode if number.isNumber => number.asDouble\n    case number: Double => BigDecimal(number)\n    case _ => throw TypeMismatchException(getType(number), DataTypes.Number)\n  }\n\n  def getString(string: Any): String = string match {\n    case string: JsonNode if string.isTextual => string.asText\n    case string: String => string\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def getObject(obj: Any): Map[String, Any] = obj match {\n    case obj: JsonNode if obj.isObject =>\n      (asScalaIteratorConverter(obj.fieldNames).asScala map { case k => k -> Option(obj.get(k)).get }).toMap\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  override def dereferenceObject(obj: Any, element: String): Any = obj match {\n    case obj: JsonNode if obj.isObject => Option(obj.get(element)).get\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  override def getKeys(obj: Any): Iterator[String] = obj match {\n    case obj: JsonNode if obj.isObject => asScalaIteratorConverter(obj.fieldNames).asScala\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  override def dereferenceArray(array: Any, element: Int): Any = array match {\n    case array: JsonNode if array.isArray => array.get(element)\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def setObjectValue(obj: JsonNode, name: String, value: JsonNode): Unit = obj match {\n    case obj: node.ObjectNode => obj.set(name, value)\n  }\n\n  def removeObjectValue(obj: JsonNode, name: String): Unit = obj match {\n    case obj: node.ObjectNode => obj.remove(name)\n  }\n\n  def addArrayValue(array: JsonNode, value: JsonNode): Unit = array match {\n    case array: node.ArrayNode => array.add(value)\n  }\n\n  def setArrayValue(array: JsonNode, index: Int, value: JsonNode): Unit = ???\n\n  def nullValue = NullNode.instance\n\n  def fromArray(array: Seq[Any]): Any = {\n    val newArray = mapper.createArrayNode\n    for (v <- array) v match {\n      case v: Boolean => newArray.add(v)\n      case v: String => newArray.add(v)\n      case v: Double => newArray.add(v)\n      case v: JsonNode => newArray.add(v)\n    }\n    newArray\n  }\n\n  def fromBoolean(boolean: Boolean): Any = boolean\n  def fromDouble(number: Double): Any = number\n  def fromBigDecimal(number: BigDecimal): Any = number.toDouble\n\n  def fromObject(obj: Map[String, Any]): Any = {\n    val newObject = mapper.createObjectNode\n    for ((k, v) <- obj) v match {\n      case v: Boolean => newObject.put(k, v)\n      case v: String => newObject.put(k, v)\n      case v: Double => newObject.put(k, v)\n      case v: JsonNode => newObject.set(k, v)\n      case null => newObject.putNull(k)\n    }\n    newObject\n  }\n  def fromString(string: String): Any = string\n\n  def isBoolean(any: Any): Boolean = any match {\n    case x: JsonNode if x.isBoolean => true\n    case _ => false\n  }\n\n  def isString(any: Any): Boolean = any match {\n    case x: JsonNode if x.isTextual => true\n    case x: String => true\n    case _ => false\n  }\n\n  def isNumber(any: Any): Boolean = any match {\n    case x: JsonNode if x.isNumber => true\n    case x: Double => true\n    case _ => false\n  }\n\n  def isObject(any: Any): Boolean = any match {\n    case x: JsonNode if x.isObject => true\n    case _ => false\n  }\n\n  def isArray(any: Any): Boolean = any match {\n    case x: JsonNode if x.isArray => true\n    case _ => false\n  }\n\n  def isNull(any: Any): Boolean = any match {\n    case x: JsonNode if x.isNull => true\n    case _ => false\n  }\n}\n"
  },
  {
    "path": "json-jackson/shared/src/main/scala/rapture/json-jackson/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jackson\n\nimport rapture.json._\nimport rapture.data._\nimport com.fasterxml.jackson.databind._\n\nprivate[jackson] trait Extractors {\n  implicit val jacksonJsonNodeExtractor: JsonCastExtractor[JsonNode] = JsonCastExtractor(JacksonAst, DataTypes.Any)\n}\n"
  },
  {
    "path": "json-jackson/shared/src/main/scala/rapture/json-jackson/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jackson\n\nimport rapture.json._\nimport rapture.data._\n\nobject `package` extends Extractors with Serializers {\n  implicit val implicitJsonAst: JsonAst = JacksonAst\n  implicit val implicitJsonStringParser: Parser[String, JsonAst] = JacksonParser\n}\n"
  },
  {
    "path": "json-jackson/shared/src/main/scala/rapture/json-jackson/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jackson\nimport rapture.core._\nimport rapture.json._\nimport rapture.data._\n\nimport com.fasterxml.jackson.databind._\n\nprivate[jackson] object JacksonParser extends Parser[String, JsonAst] {\n\n  val ast = JacksonAst\n\n  override def toString = \"<JacksonParser>\"\n\n  private val mapper = new ObjectMapper()\n    .enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)\n    .enable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS)\n\n  def parse(s: String): Option[Any] =\n    Some(mapper.readTree(s))\n}\n"
  },
  {
    "path": "json-jackson/shared/src/main/scala/rapture/json-jackson/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jackson\n\nimport rapture.json._\n\nprivate[jackson] trait Serializers {\n  import com.fasterxml.jackson.databind._\n\n  implicit val jacksonJsonNodeSerializer: DirectJsonSerializer[JsonNode] = DirectJsonSerializer(JacksonAst)\n}\n"
  },
  {
    "path": "json-jawn/shared/src/main/scala/rapture/json-jawn/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jawn\n\nimport rapture.core._\nimport rapture.json._\nimport rapture.data.DataTypes\nimport rapture.data.TypeMismatchException\nimport rapture.data.MissingValueException\n\nimport jawn.ast._\n\nprivate[jawn] object JawnAst extends JsonBufferAst {\n\n  override def dereferenceObject(obj: Any, element: String): Any =\n    obj match {\n      case JObject(obj) =>\n        try obj(element)\n        catch {\n          case e: Exception => throw MissingValueException()\n        }\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def getKeys(obj: Any): Iterator[String] =\n    obj match {\n      case JObject(obj) => obj.keys.iterator\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def dereferenceArray(array: Any, element: Int): Any =\n    array match {\n      case JArray(arr) => arr(element)\n      case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n    }\n\n  def getArray(array: Any): List[Any] = array match {\n    case JArray(xs) => xs.toList\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def getBoolean(boolean: Any): Boolean = boolean match {\n    case boolean: Boolean => boolean\n    case JTrue => true\n    case JFalse => false\n    case _ => throw TypeMismatchException(getType(boolean), DataTypes.Boolean)\n  }\n\n  def getBigDecimal(bigDecimal: Any): BigDecimal = bigDecimal match {\n    case DoubleNum(d) => BigDecimal(d)\n    case DeferLong(v) => BigDecimal(v)\n    case DeferNum(v) => BigDecimal(v)\n    case _ => throw TypeMismatchException(getType(bigDecimal), DataTypes.Number)\n  }\n\n  def getDouble(double: Any): Double = double match {\n    case DoubleNum(d) => d\n    case DeferLong(v) => v.toDouble\n    case DeferNum(v) => java.lang.Double.valueOf(v)\n    case _ => throw TypeMismatchException(getType(double), DataTypes.Number)\n  }\n\n  def getString(string: Any): String = string match {\n    case JString(s) => s\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def getObject(obj: Any): Map[String, Any] = obj match {\n    case JObject(o) => o.toMap\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def setObjectValue(obj: Any, name: String, value: Any): Any = {\n    obj.asInstanceOf[JObject].vs(name) = value.asInstanceOf[JValue]\n    obj\n  }\n\n  def removeObjectValue(obj: Any, name: String): Any = {\n    obj.asInstanceOf[JObject].vs -= name\n    obj\n  }\n\n  def addArrayValue(array: Any, value: Any): Any =\n    JArray(array.asInstanceOf[JArray].vs :+ value.asInstanceOf[JValue])\n\n  def setArrayValue(array: Any, index: Int, value: Any): Any =\n    JArray(array.asInstanceOf[JArray].vs.padTo(index, null).patch(index, Seq(value.asInstanceOf[JValue]), 1))\n\n  def isArray(array: Any): Boolean = array match {\n    case JArray(xs) => true\n    case _ => false\n  }\n\n  def isBoolean(boolean: Any): Boolean = boolean match {\n    case JTrue | JFalse => true\n    case _ => false\n  }\n\n  def isNumber(num: Any): Boolean = num match {\n    case DoubleNum(_) | DeferLong(_) | DeferNum(_) => true\n    case _ => false\n  }\n\n  def isString(string: Any): Boolean = string match {\n    case JString(_) => true\n    case _ => false\n  }\n\n  def isObject(obj: Any): Boolean = obj match {\n    case JObject(_) => true\n    case _ => false\n  }\n\n  def isNull(obj: Any): Boolean = obj match {\n    case JNull => true\n    case _ => false\n  }\n\n  def fromArray(array: Seq[Any]): Any = JArray(array.to[Array] map { case v: JValue => v })\n  def fromBoolean(boolean: Boolean): Any = if (boolean) JTrue else JFalse\n  def fromDouble(number: Double): Any = DoubleNum(number)\n  def fromBigDecimal(number: BigDecimal): Any = DeferNum(number.toString)\n\n  def fromObject(obj: Map[String, Any]): Any =\n    JObject(collection.mutable.Map(obj.mapValues { case v: JValue => v }.to[Seq]: _*))\n\n  def fromString(string: String): Any = JString(string)\n\n  val nullValue = JNull\n\n  override def toString = \"<Jawn>\"\n\n}\n"
  },
  {
    "path": "json-jawn/shared/src/main/scala/rapture/json-jawn/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jawn\n\nimport rapture.data._\nimport rapture.json._\n\nimport _root_.jawn.ast._\n\nprivate[jawn] trait Extractors {\n  implicit val jawnJObjectExtractor: JsonCastExtractor[JObject] = JsonCastExtractor(JawnAst, DataTypes.Object)\n\n  implicit val jawnJArrayExtractor: JsonCastExtractor[JArray] = JsonCastExtractor(JawnAst, DataTypes.Array)\n\n  implicit val jawnDeferNumExtractor: JsonCastExtractor[DeferNum] = JsonCastExtractor(JawnAst, DataTypes.Number)\n\n  implicit val jawnDoubleNumExtractor: JsonCastExtractor[DoubleNum] = JsonCastExtractor(JawnAst, DataTypes.Number)\n\n  implicit val jawnLongNumExtractor: JsonCastExtractor[LongNum] = JsonCastExtractor(JawnAst, DataTypes.Number)\n\n  implicit val jawnJNumExtractor: JsonCastExtractor[JNum] = JsonCastExtractor(JawnAst, DataTypes.Number)\n\n  implicit val jawnStringExtractor: JsonCastExtractor[JString] = JsonCastExtractor(JawnAst, DataTypes.String)\n\n  implicit val jawnAtomExtractor: JsonCastExtractor[JAtom] = JsonCastExtractor(JawnAst, DataTypes.Scalar)\n\n  implicit val jawnValueExtractor: JsonCastExtractor[JValue] = JsonCastExtractor(JawnAst, DataTypes.Any)\n}\n"
  },
  {
    "path": "json-jawn/shared/src/main/scala/rapture/json-jawn/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jawn\n\nimport rapture.core._\nimport rapture.data._\nimport rapture.json._\n\nimport _root_.jawn.{Parser => _, _}\nimport _root_.jawn.ast._\n\nprivate[jawn] trait package_1 {\n  implicit val jawnFacade: Facade[JValue] = JawnFacade\n}\n\nobject `package` extends package_1 with Extractors with Serializers {\n  implicit val implicitJsonAst: JsonBufferAst = JawnAst\n  implicit def implicitJsonStringParser(implicit f: Facade[_]): Parser[String, JsonBufferAst] =\n    new JawnStringParser\n\n  implicit def implicitJsonByteBufferParser(implicit f: Facade[_]): Parser[java.nio.ByteBuffer, JsonBufferAst] =\n    new JawnByteBufferParser\n\n  implicit def implicitJsonFileParser(implicit f: Facade[_]): Parser[java.io.File, JsonBufferAst] = new JawnFileParser\n\n  implicit def jsonFormatterImplicit[Ast <: JsonAst](implicit ast: Ast): Formatter[Ast] {\n    type Out = String\n  } = new Formatter[Ast] {\n    type Out = String\n    def format(json: Any): String = json match {\n      case jv: JValue => jv.render(FastRenderer)\n      case _ => ???\n    }\n  }\n}\n"
  },
  {
    "path": "json-jawn/shared/src/main/scala/rapture/json-jawn/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jawn\n\nimport rapture.core._\nimport rapture.data._\nimport rapture.json._\n\nimport jawn.{Parser => JawnParser, _}\n\nprivate[jawn] class JawnStringParser(implicit f: Facade[_]) extends Parser[String, JsonBufferAst] {\n\n  override def toString = \"<JawnStringParser>\"\n\n  val ast = JawnAst\n  def parse(s: String): Option[Any] = JawnParser.parseFromString(s).toOption\n}\n\nprivate[jawn] class JawnByteBufferParser(implicit f: Facade[_]) extends Parser[java.nio.ByteBuffer, JsonBufferAst] {\n\n  override def toString = \"<JawnByteBufferParser>\"\n\n  val ast = JawnAst\n  def parse(buf: java.nio.ByteBuffer): Option[Any] =\n    JawnParser.parseFromByteBuffer(buf).toOption\n}\n\nprivate[jawn] class JawnFileParser(implicit f: Facade[_]) extends Parser[java.io.File, JsonBufferAst] {\n\n  override def toString = \"<JawnFileParser>\"\n\n  val ast = JawnAst\n  def parse(file: java.io.File): Option[Any] = JawnParser.parseFromFile(file).toOption\n}\n"
  },
  {
    "path": "json-jawn/shared/src/main/scala/rapture/json-jawn/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.jawn\n\nimport rapture.json._\n\nimport _root_.jawn.ast._\n\nprivate[jawn] trait Serializers {\n  implicit val jawnJValueSerializer: DirectJsonSerializer[JValue] = DirectJsonSerializer(JawnAst)\n}\n"
  },
  {
    "path": "json-json4s/shared/src/main/scala/rapture/json-json4s/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.json4s\n\nimport org.json4s._\nimport rapture.data.DataTypes\nimport rapture.json._\n\nprivate[json4s] object Json4sAst extends JsonBufferAst {\n\n  import JsonAST._\n\n  override def toString = \"<Json4sAst>\"\n\n  def getArray(array: Any): List[Any] = array match {\n    case JArray(xs) => xs.toList\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def fromArray(array: Seq[Any]): Any = JArray(array.to[List] map { case v: JValue => v })\n\n  def getBoolean(boolean: Any): Boolean = boolean match {\n    case boolean: Boolean => boolean\n    case JBool(v) => v\n    case _ => throw TypeMismatchException(getType(boolean), DataTypes.Boolean)\n  }\n\n  def fromBoolean(boolean: Boolean): Any = JBool(boolean)\n\n  def getDouble(double: Any): Double = double match {\n    case JDouble(d) => d\n    case JInt(v) => v.toDouble\n    case JDecimal(v) => v.toDouble\n    case _ => throw TypeMismatchException(getType(double), DataTypes.Number)\n  }\n\n  def getBigDecimal(bigDecimal: Any): BigDecimal = bigDecimal match {\n    case JDecimal(v) => v\n    case JDouble(d) => BigDecimal(d)\n    case JInt(v) => BigDecimal(v)\n    case _ => throw TypeMismatchException(getType(bigDecimal), DataTypes.Number)\n  }\n\n  def fromDouble(number: Double): Any = JDouble(number)\n\n  def fromBigDecimal(number: BigDecimal): Any = JDecimal(number)\n\n  def getString(string: Any): String = string match {\n    case JString(s) => s\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def fromString(string: String): Any = JString(string)\n\n  def getObject(obj: Any): Map[String, Any] = obj match {\n    case JObject(o) => o.toMap\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def fromObject(obj: Map[String, Any]): Any =\n    JObject(obj.mapValues { case v: JValue => v }.to[List])\n\n  def setObjectValue(obj: Any, name: String, value: Any): Any = {\n    val contents = (name, value) :: obj.asInstanceOf[JObject].obj.filter(_._1 != name)\n    JObject(contents map {\n      case (k: String, v: JValue) => k -> v\n      case _ => ???\n    })\n  }\n\n  def removeObjectValue(obj: Any, name: String): Any =\n    JObject(obj.asInstanceOf[JObject].obj.filter(_._1 == name))\n\n  def addArrayValue(array: Any, value: Any): Any =\n    JArray(array.asInstanceOf[JArray].arr :+ value.asInstanceOf[JValue])\n\n  def setArrayValue(array: Any, index: Int, value: Any): Any = array match {\n    case array: JArray =>\n      JArray(array.arr.padTo(index, JNull).patch(index, Seq(value.asInstanceOf[JValue]), 1))\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def isBoolean(boolean: Any): Boolean = boolean match {\n    case JBool(_) => true\n    case _ => false\n  }\n\n  def isString(string: Any): Boolean = string match {\n    case JString(_) => true\n    case _ => false\n  }\n\n  def isNumber(num: Any): Boolean = num match {\n    case JDecimal(_) | JInt(_) | JDouble(_) => true\n    case _ => false\n  }\n\n  def isObject(obj: Any): Boolean = obj match {\n    case JObject(_) => true\n    case _ => false\n  }\n\n  def isArray(array: Any): Boolean = array match {\n    case JArray(xs) => true\n    case _ => false\n  }\n\n  def isNull(obj: Any): Boolean = obj match {\n    case JNull => true\n    case _ => false\n  }\n\n  def nullValue: Any = JNull\n\n  override def dereferenceObject(obj: Any, element: String): Any =\n    obj match {\n      case obj: JObject =>\n        val result = obj \\ element\n        if(result == JNothing) throw MissingValueException()\n        else result\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def getKeys(obj: Any): Iterator[String] =\n    obj match {\n      case JObject(obj) => obj.map(_._1).iterator\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def dereferenceArray(array: Any, element: Int): Any =\n    array match {\n      case JArray(arr) =>\n        val result = arr(element)\n        if(result == JNothing) throw MissingValueException()\n        else result\n      case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n    }\n}\n"
  },
  {
    "path": "json-json4s/shared/src/main/scala/rapture/json-json4s/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.json4s\n\nimport rapture.json._\nimport rapture.data._\n\nimport org.json4s._\n\nprivate[json4s] trait Extractors {\n  implicit val json4sJValueExtractor: JsonCastExtractor[JValue] = JsonCastExtractor(Json4sAst, DataTypes.Any)\n\n  implicit val json4sJDecimalExtractor: JsonCastExtractor[JDecimal] = JsonCastExtractor(Json4sAst, DataTypes.Number)\n\n  implicit val json4sJDoubleExtractor: JsonCastExtractor[JDouble] = JsonCastExtractor(Json4sAst, DataTypes.Number)\n\n  implicit val json4sJStringExtractor: JsonCastExtractor[JString] = JsonCastExtractor(Json4sAst, DataTypes.String)\n\n  implicit val json4sJIntExtractor: JsonCastExtractor[JInt] = JsonCastExtractor(Json4sAst, DataTypes.Number)\n\n  implicit val json4sJArrayExtractor: JsonCastExtractor[JArray] = JsonCastExtractor(Json4sAst, DataTypes.Array)\n\n  implicit val json4sJObjectExtractor: JsonCastExtractor[JObject] = JsonCastExtractor(Json4sAst, DataTypes.Object)\n}\n"
  },
  {
    "path": "json-json4s/shared/src/main/scala/rapture/json-json4s/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.json4s\n\nobject `package` extends Extractors with Serializers {\n  implicit val implicitJsonAst = Json4sAst\n  implicit val implicitJsonStringParser = Json4sParser\n}\n"
  },
  {
    "path": "json-json4s/shared/src/main/scala/rapture/json-json4s/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.json4s\n\nimport rapture.data._\nimport rapture.json._\n\nimport org.json4s._\n\nprivate[json4s] object Json4sParser extends Parser[String, JsonBufferAst] {\n\n  val ast = Json4sAst\n\n  def parse(s: String): Option[Any] =\n    try Some(native.JsonParser.parse(s\"\"\"{\"x\":$s}\"\"\", useBigDecimalForDouble = true) \\ \"x\")\n    catch {\n      case e: Exception => None\n    }\n\n  override def toString = \"<Json4sParser>\"\n}\n"
  },
  {
    "path": "json-json4s/shared/src/main/scala/rapture/json-json4s/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.json4s\n\nimport rapture.json._\n\nimport org.json4s._\n\nprivate[json4s] trait Serializers {\n  implicit val json4sJValueSerializer: DirectJsonSerializer[JValue] = DirectJsonSerializer(Json4sAst)\n}\n"
  },
  {
    "path": "json-lift/shared/src/main/scala/rapture/json-lift/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.lift\n\nimport rapture.core._\nimport rapture.json._\nimport rapture.data.DataTypes\n\nimport net.liftweb.json._\n\nprivate[lift] object LiftAst extends JsonBufferAst {\n\n  import JsonAST._\n\n  override def toString = \"<LiftAst>\"\n\n  override def dereferenceObject(obj: Any, element: String): Any =\n    obj match {\n      case JObject(obj) => obj.find(_.name == element).get.value\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def getKeys(obj: Any): Iterator[String] =\n    obj match {\n      case JObject(obj) => obj.map(_.name).iterator\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def dereferenceArray(array: Any, element: Int): Any =\n    array match {\n      case JArray(arr) => arr(element)\n      case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n    }\n\n  def getArray(array: Any): List[Any] = array match {\n    case JArray(xs) => xs.toList\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def getBoolean(boolean: Any): Boolean = boolean match {\n    case boolean: Boolean => boolean\n    case JBool(v) => v\n    case _ => throw TypeMismatchException(getType(boolean), DataTypes.Boolean)\n  }\n\n  def getBigDecimal(bigDecimal: Any): BigDecimal = bigDecimal match {\n    case JDouble(d) => BigDecimal(d)\n    case JInt(v) => BigDecimal(v)\n    case _ => throw TypeMismatchException(getType(bigDecimal), DataTypes.Number)\n  }\n\n  def getDouble(double: Any): Double = double match {\n    case JDouble(d) => d\n    case JInt(v) => v.toDouble\n    case _ => throw TypeMismatchException(getType(double), DataTypes.Number)\n  }\n\n  def getString(string: Any): String = string match {\n    case JString(s) => s\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def getObject(obj: Any): Map[String, Any] = obj match {\n    case JObject(o) =>\n      o.map { f =>\n        f.name -> f.value\n      }.toMap\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def setObjectValue(obj: Any, name: String, value: Any): Any = {\n    val contents = (name, value) :: obj.asInstanceOf[JObject].obj.filter(_.name != name)\n    JObject(contents map {\n      case JField(k: String, v: JValue) => JField(k, v)\n      case (k: String, v: JValue) => JField(k, v)\n    })\n  }\n\n  def removeObjectValue(obj: Any, name: String): Any =\n    JObject(obj.asInstanceOf[JObject].obj.filter(_.name == name))\n\n  def addArrayValue(array: Any, value: Any): Any =\n    JArray(array.asInstanceOf[JArray].arr :+ value.asInstanceOf[JValue])\n\n  def setArrayValue(array: Any, index: Int, value: Any): Any = array match {\n    case array: JArray =>\n      JArray(array.arr.padTo(index, JNull).patch(index, Seq(value.asInstanceOf[JValue]), 1))\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def isArray(array: Any): Boolean = array match {\n    case JArray(xs) => true\n    case _ => false\n  }\n\n  def isBoolean(boolean: Any): Boolean = boolean match {\n    case JBool(_) => true\n    case _ => false\n  }\n\n  def isNumber(num: Any): Boolean = num match {\n    case JInt(_) | JDouble(_) => true\n    case _ => false\n  }\n\n  def isString(string: Any): Boolean = string match {\n    case JString(_) => true\n    case _ => false\n  }\n\n  def isObject(obj: Any): Boolean = obj match {\n    case JObject(_) => true\n    case _ => false\n  }\n\n  def isNull(obj: Any): Boolean = obj match {\n    case JNull => true\n    case _ => false\n  }\n\n  def nullValue: Any = JNull\n\n  def fromArray(array: Seq[Any]): Any = JArray(array.to[List] map { case v: JValue => v })\n  def fromBoolean(boolean: Boolean): Any = JBool(boolean)\n  def fromDouble(number: Double): Any = JDouble(number)\n  def fromBigDecimal(number: BigDecimal): Any = JDouble(number.toDouble)\n\n  def fromObject(obj: Map[String, Any]): Any =\n    JObject(obj.map {\n      case (k, v: JValue) => JField(k, v)\n      case _ => ???\n    }.to[List])\n\n  def fromString(string: String): Any = JString(string)\n\n}\n"
  },
  {
    "path": "json-lift/shared/src/main/scala/rapture/json-lift/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.lift\n\nimport rapture.json._\nimport rapture.data._\n\nimport net.liftweb.json._\nimport JsonAST._\n\nprivate[lift] trait Extractors {\n  implicit val liftJValueExtractor: JsonCastExtractor[JValue] = JsonCastExtractor(LiftAst, DataTypes.Any)\n\n  implicit val liftJStringExtractor: JsonCastExtractor[JString] = JsonCastExtractor(LiftAst, DataTypes.String)\n\n  implicit val liftJIntExtractor: JsonCastExtractor[JInt] = JsonCastExtractor(LiftAst, DataTypes.Number)\n\n  implicit val liftJDoubleExtractor: JsonCastExtractor[JDouble] = JsonCastExtractor(LiftAst, DataTypes.Number)\n\n  implicit val liftJArrayExtractor: JsonCastExtractor[JArray] = JsonCastExtractor(LiftAst, DataTypes.Array)\n\n  implicit val liftJObjectExtractor: JsonCastExtractor[JObject] = JsonCastExtractor(LiftAst, DataTypes.Object)\n}\n"
  },
  {
    "path": "json-lift/shared/src/main/scala/rapture/json-lift/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.lift\n\nobject `package` extends Serializers with Extractors {\n  implicit val implicitJsonAst = LiftAst\n  implicit val implicitJsonStringParser = LiftParser\n}\n"
  },
  {
    "path": "json-lift/shared/src/main/scala/rapture/json-lift/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.lift\n\nimport rapture.core._\nimport rapture.json._\nimport rapture.data._\n\nimport net.liftweb.json._\n\nprivate[lift] object LiftParser extends Parser[String, JsonBufferAst] {\n  val ast = LiftAst\n  def parse(s: String): Option[Any] =\n    try Some(JsonParser.parse(s))\n    catch { case e: Exception => None }\n\n  override def toString = \"<LiftParser>\"\n}\n"
  },
  {
    "path": "json-lift/shared/src/main/scala/rapture/json-lift/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.lift\n\nimport rapture.json._\n\nimport net.liftweb.json._\nimport JsonAST._\n\nprivate[lift] trait Serializers {\n  implicit val liftJValueSerializer: DirectJsonSerializer[JValue] = DirectJsonSerializer(LiftAst)\n}\n"
  },
  {
    "path": "json-play/shared/src/main/scala/rapture/json-play/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.play\n\nimport rapture.core._\nimport rapture.json._\nimport rapture.data.DataTypes\n\nimport play.api.libs.json.{Json => PJson, _}\n\nprivate[play] object PlayAst extends JsonBufferAst {\n\n  override def toString = \"<PlayAst>\"\n\n  override def dereferenceObject(obj: Any, element: String): Any = obj match {\n    case obj @ JsObject(_) =>\n      obj \\ element match {\n        case JsDefined(v) => v\n        case _ => throw MissingValueException()\n      }\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  override def getKeys(obj: Any): Iterator[String] =\n    obj match {\n      case obj: JsObject => obj.keys.iterator\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def dereferenceArray(array: Any, element: Int): Any =\n    array match {\n      case arr @ JsArray(_) =>\n        arr(element) match {\n          case JsDefined(v) => v\n          case _ => throw MissingValueException()\n        }\n      case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n    }\n\n  def getArray(array: Any): List[Any] = array match {\n    case JsArray(arr) => arr.to[List]\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def getBoolean(boolean: Any): Boolean = boolean match {\n    case JsBoolean(v) => v\n    case _ => throw TypeMismatchException(getType(boolean), DataTypes.Boolean)\n  }\n\n  def getBigDecimal(bigDecimal: Any): BigDecimal = bigDecimal match {\n    case JsNumber(n) => n\n    case _ => throw TypeMismatchException(getType(bigDecimal), DataTypes.Number)\n  }\n\n  def getDouble(double: Any): Double = double match {\n    case JsNumber(n) => n.toDouble\n    case _ => throw TypeMismatchException(getType(double), DataTypes.Number)\n  }\n\n  def getString(string: Any): String = string match {\n    case JsString(s) => s\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def getObject(obj: Any): Map[String, Any] = obj match {\n    case JsObject(obj) => obj.toMap\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def setObjectValue(obj: Any, name: String, value: Any): Any =\n    (value, obj) match {\n      case (value: JsValue, obj: JsValue) => PJson.toJson(obj.as[Map[String, JsValue]].updated(name, value))\n      case (_, _) => ??? // should never get there?\n    }\n\n  def removeObjectValue(obj: Any, name: String): Any = obj match {\n    case obj: JsObject => PJson.toJson(obj.as[Map[String, JsValue]] - name)\n  }\n\n  def addArrayValue(array: Any, value: Any): Any = array match {\n    case v: JsValue => PJson.toJson(v.as[Array[JsValue]] :+ value.asInstanceOf[JsValue])\n  }\n\n  def setArrayValue(array: Any, index: Int, value: Any): Any = array match {\n    case v: JsValue =>\n      val array = v.as[Array[JsValue]]\n      PJson.toJson(array.padTo(index, JsNull: JsValue).patch(index, Seq(value.asInstanceOf[JsValue]), 1))\n  }\n\n  def isArray(array: Any): Boolean =\n    try {\n      array match {\n        case JsArray(_) => true\n        case _ => false\n      }\n    } catch { case e: Exception => false }\n\n  def isBoolean(boolean: Any): Boolean =\n    try {\n      boolean match {\n        case JsBoolean(boolean) => true\n        case _ => false\n      }\n    } catch { case e: Exception => false }\n\n  def isNumber(num: Any): Boolean =\n    try {\n      num match {\n        case JsNumber(_) => true\n        case _ => false\n      }\n    } catch { case e: Exception => false }\n\n  def isString(string: Any): Boolean =\n    try {\n      string match {\n        case JsString(s) => true\n        case _ => false\n        //case JsDefined(string) => string.asOpt[String].isDefined\n      }\n    } catch { case e: Exception => false }\n\n  def isObject(obj: Any): Boolean =\n    try {\n      obj match {\n        case JsObject(obj) => true\n        case _ => false\n      }\n    } catch { case e: Exception => false }\n\n  def isNull(obj: Any): Boolean = obj match {\n    case JsNull => true\n    case _ => false\n  }\n\n  val nullValue: Any = JsNull\n\n  def fromArray(array: Seq[Any]): Any = PJson.toJson(array.map(_.asInstanceOf[JsValue]))\n  def fromBoolean(boolean: Boolean): Any = PJson.toJson(boolean)\n  def fromDouble(number: Double): Any = PJson.toJson(number)\n  def fromBigDecimal(number: BigDecimal): Any = PJson.toJson(number)\n\n  def fromObject(obj: Map[String, Any]): Any =\n    PJson.toJson(obj.map {\n      case (k, v: JsValue) => (k, v)\n      case _ => ???\n    })\n\n  def fromString(string: String): Any = PJson.toJson(string)\n\n}\n"
  },
  {
    "path": "json-play/shared/src/main/scala/rapture/json-play/extraction.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.play\n\nimport rapture.json._\nimport rapture.data._\n\nimport play.api.libs.json._\n\nprivate[play] trait Extractors {\n  implicit val playJsValueExtractor: JsonCastExtractor[JsValue] = JsonCastExtractor(PlayAst, DataTypes.Any)\n\n  implicit val playJsObjectExtractor: JsonCastExtractor[JsObject] = JsonCastExtractor(PlayAst, DataTypes.Object)\n\n  implicit val playJsArrayExtractor: JsonCastExtractor[JsArray] = JsonCastExtractor(PlayAst, DataTypes.Array)\n}\n"
  },
  {
    "path": "json-play/shared/src/main/scala/rapture/json-play/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.play\n\nobject `package` extends Extractors with Serializers {\n  implicit val implicitJsonAst = PlayAst\n  implicit val implicitJsonStringParser = PlayParser\n}\n"
  },
  {
    "path": "json-play/shared/src/main/scala/rapture/json-play/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.play\n\nimport rapture.core._\nimport rapture.json._\nimport rapture.data._\n\nimport play.api.libs.json.{Json => PJson}\n\nprivate[play] object PlayParser extends Parser[String, JsonBufferAst] {\n  val ast = PlayAst\n  def parse(s: String): Option[Any] =\n    try Some(PJson.parse(s))\n    catch { case e: Exception => None }\n\n  override def toString = \"<PlayParser>\"\n}\n"
  },
  {
    "path": "json-play/shared/src/main/scala/rapture/json-play/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.play\n\nimport rapture.json._\n\nimport play.api.libs.json._\n\nprivate[play] trait Serializers {\n  implicit val playJsValueSerializer: DirectJsonSerializer[JsValue] = DirectJsonSerializer(PlayAst)\n\n  implicit val playJsObjectSerializer: DirectJsonSerializer[JsObject] = DirectJsonSerializer(PlayAst)\n}\n"
  },
  {
    "path": "json-spray/shared/src/main/scala/rapture/json-spray/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.spray\n\nimport rapture.core._\nimport rapture.json._\nimport rapture.data.DataTypes\n\nimport spray.json._\n\nimport DefaultJsonProtocol._\n\nprivate[spray] object SprayAst extends JsonBufferAst {\n\n  override def toString = \"<SprayAst>\"\n\n  override def dereferenceObject(obj: Any, element: String): Any =\n    obj match {\n      case obj: JsObject =>\n        try obj.getFields(element).head\n        catch {\n          case e: IndexOutOfBoundsException => throw MissingValueException()\n        }\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def getKeys(obj: Any): Iterator[String] =\n    obj match {\n      case obj: JsObject => obj.fields.keysIterator\n      case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n    }\n\n  override def dereferenceArray(array: Any, element: Int): Any =\n    array match {\n      case v: JsValue =>\n        val arr = v.convertTo[Array[JsValue]]\n        arr(element)\n      case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n    }\n\n  def getArray(array: Any): List[Any] = array match {\n    case v: JsValue =>\n      try v.convertTo[List[JsValue]]\n      catch {\n        case e: Exception => throw TypeMismatchException(getType(array), DataTypes.Array)\n      }\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def getBoolean(boolean: Any): Boolean = boolean match {\n    case v: JsValue =>\n      try v.convertTo[Boolean]\n      catch {\n        case e: Exception => throw TypeMismatchException(getType(boolean), DataTypes.Boolean)\n      }\n    case _ => throw TypeMismatchException(getType(boolean), DataTypes.Boolean)\n  }\n\n  def getBigDecimal(bigDecimal: Any): BigDecimal = bigDecimal match {\n    case v: JsValue =>\n      try v.convertTo[BigDecimal]\n      catch {\n        case e: Exception => throw TypeMismatchException(getType(bigDecimal), DataTypes.Number)\n      }\n    case _ => throw TypeMismatchException(getType(bigDecimal), DataTypes.Number)\n  }\n\n  def getDouble(double: Any): Double = double match {\n    case v: JsValue =>\n      try v.convertTo[Double]\n      catch {\n        case e: Exception => throw TypeMismatchException(getType(double), DataTypes.Number)\n      }\n    case _ => throw TypeMismatchException(getType(double), DataTypes.Number)\n  }\n\n  def getString(string: Any): String = string match {\n    case v: JsValue =>\n      try v.convertTo[String]\n      catch {\n        case e: Exception => throw TypeMismatchException(getType(string), DataTypes.String)\n      }\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def getObject(obj: Any): Map[String, Any] = obj match {\n    case v: JsObject => v.fields\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def setObjectValue(obj: Any, name: String, value: Any): Any =\n    (value, obj) match {\n      case (value: JsValue, obj: JsValue) => obj.asJsObject.fields.updated(name, value).toJson\n      case _ => ???\n    }\n\n  def removeObjectValue(obj: Any, name: String): Any = obj match {\n    case obj: JsObject => (obj.fields - name).toJson\n  }\n\n  def addArrayValue(array: Any, value: Any): Any = array match {\n    case v: JsValue => (v.convertTo[Array[JsValue]] :+ value.asInstanceOf[JsValue]).toJson\n  }\n\n  def setArrayValue(array: Any, index: Int, value: Any): Any = array match {\n    case v: JsValue =>\n      val array = v.convertTo[Array[JsValue]]\n      array.padTo(index, JsNull: JsValue).patch(index, Seq(value.asInstanceOf[JsValue]), 1).toJson\n  }\n\n  def isArray(array: Any): Boolean =\n    try {\n      array match {\n        case array: JsValue =>\n          array.convertTo[Array[JsValue]]\n          true\n        case _ => false\n      }\n    } catch {\n      case e: DeserializationException => false\n    }\n\n  def isBoolean(boolean: Any): Boolean =\n    try {\n      boolean match {\n        case boolean: JsValue =>\n          boolean.convertTo[Boolean]\n          true\n        case _ => false\n      }\n    } catch {\n      case e: ClassCastException => false\n      case e: DeserializationException => false\n    }\n\n  def isNumber(num: Any): Boolean =\n    try {\n      num match {\n        case JsNull => false\n        case num: JsValue =>\n          num.convertTo[Double]\n          true\n        case _ => false\n      }\n    } catch {\n      case e: ClassCastException => false\n      case e: DeserializationException => false\n    }\n\n  def isString(string: Any): Boolean =\n    try {\n      string match {\n        case string: JsValue =>\n          string.convertTo[String]\n          true\n        case _ => false\n      }\n    } catch {\n      case e: ClassCastException => false\n      case e: DeserializationException => false\n    }\n\n  def isObject(obj: Any): Boolean = obj match {\n    case obj: JsObject => true\n    case _ => false\n  }\n\n  def isNull(obj: Any): Boolean = obj match {\n    case JsNull => true\n    case _ => false\n  }\n\n  def nullValue: Any = JsNull\n\n  def fromArray(array: Seq[Any]): Any = array.map(_.asInstanceOf[JsValue]).toJson\n  def fromBoolean(boolean: Boolean): Any = boolean.toJson\n  def fromDouble(number: Double): Any = number.toJson\n  def fromBigDecimal(number: BigDecimal): Any = number.toJson\n\n  def fromObject(obj: Map[String, Any]): Any =\n    obj.map {\n      case (k, v: JsValue) => (k, v)\n      case _ => ???\n    }.toJson\n\n  def fromString(string: String): Any = string.toJson\n\n}\n"
  },
  {
    "path": "json-spray/shared/src/main/scala/rapture/json-spray/extraction.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.spray\n\nimport rapture.json._\nimport rapture.data._\n\nimport spray.json._\n\nprivate[spray] trait Extractors {\n  implicit val sprayJsValueExtractor: JsonCastExtractor[JsValue] = JsonCastExtractor(SprayAst, DataTypes.Any)\n\n  implicit val sprayJsObjectExtractor: JsonCastExtractor[JsObject] = JsonCastExtractor(SprayAst, DataTypes.Object)\n}\n"
  },
  {
    "path": "json-spray/shared/src/main/scala/rapture/json-spray/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.spray\n\nobject `package` extends Extractors with Serializers {\n  implicit val implicitJsonAst = SprayAst\n  implicit val implicitJsonStringParser = SprayParser\n}\n"
  },
  {
    "path": "json-spray/shared/src/main/scala/rapture/json-spray/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.spray\n\nimport rapture.core._\nimport rapture.json._\n\nimport rapture.data._\n\nimport spray.json._\n\nprivate[spray] object SprayParser extends Parser[String, JsonBufferAst] {\n  val ast = SprayAst\n  def parse(s: String): Option[Any] =\n    try Some(s.parseJson)\n    catch { case e: Exception => None }\n\n  override def toString = \"<SprayParser>\"\n}\n"
  },
  {
    "path": "json-spray/shared/src/main/scala/rapture/json-spray/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.jsonBackends.spray\n\nimport rapture.json._\n\nimport spray.json._\n\nprivate[spray] trait Serializers {\n  implicit val sprayJsValueSerializer: DirectJsonSerializer[JsValue] = DirectJsonSerializer(SprayAst)\n\n  implicit val sprayJsObjectSerializer: DirectJsonSerializer[JsObject] = DirectJsonSerializer(SprayAst)\n}\n"
  },
  {
    "path": "json-test/shared/src/test/scala/rapture/json-test/java8TimeTests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n\n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.json.test\n\nimport java.time._\n\nimport rapture.core.ParseException\nimport rapture.data.Parser\nimport rapture.json.jsonBackends._\nimport rapture.json.{JsonAst, _}\nimport rapture.test.{Programme, TestSuite}\nimport rapture.core.java8.time._\nimport dictionaries.dynamic._\n\nclass JsonJava8TimeApiTestRun extends Programme {\n  include(PlayTests)\n  include(JawnTests)\n  include(Json4sTests)\n  include(SprayTests)\n  include(JacksonTests)\n  include(ArgonautTests)\n  include(CirceTests)\n  include(LiftTests)\n\n  object PlayTests extends JsonJava8TimeApiTests(play.implicitJsonAst, play.implicitJsonStringParser)\n\n  object JawnTests extends JsonJava8TimeApiTests(jawn.implicitJsonAst, jawn.implicitJsonStringParser(jawn.jawnFacade))\n\n  object Json4sTests extends JsonJava8TimeApiTests(json4s.implicitJsonAst, json4s.implicitJsonStringParser)\n\n  object SprayTests extends JsonJava8TimeApiTests(spray.implicitJsonAst, spray.implicitJsonStringParser)\n\n  object JacksonTests extends JsonJava8TimeApiTests(jackson.implicitJsonAst, jackson.implicitJsonStringParser)\n\n  object ArgonautTests extends JsonJava8TimeApiTests(argonaut.implicitJsonAst, argonaut.implicitJsonStringParser)\n\n  object CirceTests extends JsonJava8TimeApiTests(circe.implicitJsonAst, circe.implicitJsonStringParser)\n\n  object LiftTests extends JsonJava8TimeApiTests(lift.implicitJsonAst, lift.implicitJsonStringParser)\n\n}\n\n\n\nabstract class JsonJava8TimeApiTests(ast: JsonAst, parser: Parser[String, JsonAst]) extends TestSuite {\n  implicit def implicitAst: JsonAst = ast\n\n  implicit def implicitParser: Parser[String, JsonAst] = parser\n\n\n  case class TestLocalDate(time: LocalDate)\n  case class TestLocalDateTime(time: LocalDateTime)\n  case class TestLocalTime(time: LocalTime)\n  case class TestZonedDateTime(time: ZonedDateTime)\n  case class TestOffsetDateTime(time: OffsetDateTime)\n  case class TestOffsetTime(time: OffsetTime)\n\n  val `[Java 8 Time Extractor] Extract LocalDate` = test {\n    json\"\"\"{\"time\":  \"2017-01-23\"}\"\"\".time.as[LocalDate]\n  } returns LocalDate.of(2017, 1, 23)\n\n  val `[Java 8 Time Extractor] Extract LocalDateTime` = test {\n    json\"\"\"{\"time\":  \"2017-01-23T18:28:51.045\"}\"\"\".time.as[LocalDateTime]\n  } returns LocalDateTime.of(2017, 1, 23, 18, 28, 51, 45000000)\n\n  val `[Java 8 Time Extractor] Extract LocalTime` = test {\n    json\"\"\"{\"time\":  \"18:38:14.997\"}\"\"\".time.as[LocalTime]\n  } returns LocalTime.of(18, 38, 14, 997000000)\n\n\n  val `[Java 8 Time Extractor] Extract ZonedDateTime` = test {\n    json\"\"\"{\"time\":  \"2017-01-23T18:41:02.086+02:00[Europe/Kiev]\"}\"\"\".time.as[ZonedDateTime]\n  } returns ZonedDateTime.of(2017, 1, 23, 18, 41, 2, 86000000, ZoneId.of(\"Europe/Kiev\"))\n\n\n  val `[Java 8 Time Extractor] Extract OffsetDateTime` = test {\n    json\"\"\"{\"time\":  \"2017-01-23T18:44:18.221+02:00\"}\"\"\".time.as[OffsetDateTime]\n  } returns OffsetDateTime.of(2017, 1, 23, 18, 44, 18, 221000000, ZoneOffset.ofHours(2))\n\n\n  val `[Java 8 Time Extractor] Extract OffsetTime` = test {\n    json\"\"\"{\"time\":  \"19:03:25.325+02:00\"}\"\"\".time.as[OffsetTime]\n  } returns OffsetTime.of(19, 3, 25, 325000000, ZoneOffset.ofHours(2))\n\n\n  val `[Java 8 Time Extractor] Extract Failure` = test {\n    json\"\"\"{\"time\":  \"19:03:25.325+02:0\"}\"\"\".time.as[OffsetTime]\n  } throws classOf[ParseException]\n\n\n  val `[Java 8 Time Serializator] Serialize LocalDate` = test {\n    Json(TestLocalDate(LocalDate.of(2017, 1, 23)))\n  } returns json\"\"\"{\"time\":  \"2017-01-23\"}\"\"\"\n\n  val `[Java 8 Time Serializator] Serialize LocalDateTime` = test {\n    Json(TestLocalDateTime( LocalDateTime.of(2017, 1, 23, 18, 28, 51, 45000000)))\n  } returns json\"\"\"{\"time\":  \"2017-01-23T18:28:51.045\"}\"\"\"\n\n\n  val `[Java 8 Time Serializator] Serialize LocalTime` = test {\n    Json(TestLocalTime(LocalTime.of(18, 38, 14, 997000000)))\n  } returns json\"\"\"{\"time\":  \"18:38:14.997\"}\"\"\"\n\n\n  val `[Java 8 Time Serializator] Serialize ZonedDateTime` = test {\n    Json(TestZonedDateTime(ZonedDateTime.of(2017, 1, 23, 18, 41, 2, 86000000, ZoneId.of(\"Europe/Kiev\"))))\n  } returns json\"\"\"{\"time\":  \"2017-01-23T18:41:02.086+02:00[Europe/Kiev]\"}\"\"\"\n\n\n  val `[Java 8 Time Serializator] Serialize OffsetDateTime` = test {\n    Json(TestOffsetDateTime(OffsetDateTime.of(2017, 1, 23, 18, 44, 18, 221000000, ZoneOffset.ofHours(2))))\n  } returns json\"\"\"{\"time\":  \"2017-01-23T18:44:18.221+02:00\"}\"\"\"\n\n\n  val `[Java 8 Time Serializator] Serialize OffsetTime` = test {\n    Json(TestOffsetTime(OffsetTime.of(19, 3, 25, 325000000, ZoneOffset.ofHours(2))))\n  } returns json\"\"\"{\"time\":  \"19:03:25.325+02:00\"}\"\"\"\n\n}\n"
  },
  {
    "path": "json-test/shared/src/test/scala/rapture/json-test/tests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n*/\n\npackage rapture.json.test\n\n//import rapture.core._\nimport rapture.json._\nimport rapture.data.{DataTypes, Parser}\nimport rapture.test._\nimport jsonBackends._\nimport dictionaries.dynamic._\n\nclass TestRun extends Programme {\n  include(PlayTests)\n  include(JawnTests)\n  include(Json4sTests)\n  include(SprayTests)\n  include(JacksonTests)\n  include(ArgonautTests)\n  include(CirceTests)\n  include(LiftTests)\n  //include(MutablePlayTests)\n  //include(MutableJawnTests)\n  //include(MutableJson4sTests)\n  //include(MutableSprayTests)\n  //include(MutableArgonautTests)\n  //include(MutableCirceTests)\n  //include(MutableLiftTests)\n\n\n  object PlayTests extends JsonTests(play.implicitJsonAst, play.implicitJsonStringParser)\n  object JawnTests extends JsonTests(jawn.implicitJsonAst, jawn.implicitJsonStringParser(jawn.jawnFacade))\n  object Json4sTests extends JsonTests(json4s.implicitJsonAst, json4s.implicitJsonStringParser)\n  object SprayTests extends JsonTests(spray.implicitJsonAst, spray.implicitJsonStringParser)\n  object JacksonTests extends JsonTests(jackson.implicitJsonAst, jackson.implicitJsonStringParser)\n  object ArgonautTests extends JsonTests(argonaut.implicitJsonAst, argonaut.implicitJsonStringParser)\n  object CirceTests extends JsonTests(circe.implicitJsonAst, circe.implicitJsonStringParser)\n  object LiftTests extends JsonTests(lift.implicitJsonAst, lift.implicitJsonStringParser)\n\n  object MutablePlayTests extends MutableJsonTests(play.implicitJsonAst, play.implicitJsonStringParser)\n  object MutableJawnTests extends MutableJsonTests(jawn.implicitJsonAst, jawn.implicitJsonStringParser(jawn.jawnFacade))\n  object MutableJson4sTests extends MutableJsonTests(json4s.implicitJsonAst, json4s.implicitJsonStringParser)\n  object MutableSprayTests extends MutableJsonTests(spray.implicitJsonAst, spray.implicitJsonStringParser)\n  object MutableArgonautTests extends MutableJsonTests(argonaut.implicitJsonAst, argonaut.implicitJsonStringParser)\n  object MutableCirceTests extends MutableJsonTests(circe.implicitJsonAst, circe.implicitJsonStringParser)\n  object MutableLiftTests extends MutableJsonTests(lift.implicitJsonAst, lift.implicitJsonStringParser)\n\n}\n\n\n\ncase class Foo(alpha: String, beta: Int)\ncase class Bar(foo: Foo, gamma: Double)\n\ncase class Baz(alpha: String, beta: Option[Int])\ncase class Baz2(alpha: String, beta: util.Try[Int])\n\ncase class HasDefault(alpha: String = \"yes\", beta: Int)\ncase class HasDefault2(alpha: String, beta: Int = 1)\n\ncase class A(a: B)\ncase class B(b: C)\ncase class C(c: D)\ncase class D(d: E)\ncase class E(e: F)\ncase class F(f: Int)\ncase class FooDefaultOption(param1: Option[String] = None, param2: Option[Int] = None)\n\nabstract class JsonTests(ast: JsonAst, parser: Parser[String, JsonAst]) extends TestSuite {\n\n  implicit def implicitAst: JsonAst = ast\n  implicit def implicitParser: Parser[String, JsonAst] = parser\n\n  val source1 = json\"\"\"{\n    \"string\": \"Hello\",\n    \"int\": 42,\n    \"double\": 3.14159,\n    \"boolean\": true,\n    \"list\": [1, 2, 3],\n    \"foo\": { \"alpha\": \"test\", \"beta\": 1 },\n    \"bar\": { \"foo\": { \"alpha\": \"test2\", \"beta\": 2 }, \"gamma\": 2.7 },\n    \"baz\": { \"alpha\": \"test\" },\n    \"baz2\": { \"alpha\": \"test\", \"beta\": 7 },\n    \"self\": 0,\n    \"boo\": null,\n    \"booInner\": {\"foo\": null, \"bar\": \"value\"}\n  }\"\"\"\n\n  val `Extract Int` = test {\n    source1.int.as[Int]\n  } returns 42\n  \n  val `Extract value called \"self\"` = test {\n    source1.self.as[Int]\n  } returns 0\n  \n  val `Extract Option[Int]` = test {\n    source1.int.as[Option[Int]]\n  } returns Some(42)\n  \n  val `Extract Option[Int], wrong type` = test {\n    source1.string.as[Option[Int]]\n  } returns None\n \n  val `Extract String` = test {\n    source1.string.as[String]\n  } returns \"Hello\"\n  \n  val `Extract Double` = test {\n    source1.double.as[Double]\n  } returns 3.14159\n  \n  val `Extract Boolean` = test {\n    source1.boolean.as[Boolean]\n  } returns true\n  \n  val `Extract List[Int]` = test {\n    source1.list.as[List[Int]]\n  } returns List(1, 2, 3)\n  \n  val `Extract Vector[Int]` = test {\n    source1.list.as[Vector[Int]]\n  } returns Vector(1, 2, 3)\n  \n  val `Extract case class` = test {\n    source1.foo.as[Foo]\n  } returns Foo(\"test\", 1)\n  \n  val `Extract case class with missing optional value` = test {\n    source1.baz.as[Baz]\n  } returns Baz(\"test\", None)\n  \n  val `Extract case class with missing tried value` = test {\n    source1.baz.as[Baz2]\n  } returns Baz2(\"test\", util.Failure(MissingValueException(\"beta\")))\n  \n  val `Extract case class with present optional value` = test {\n    source1.baz2.as[Baz]\n  } returns Baz(\"test\", Some(7))\n  \n  val `Extract case class with present tried value` = test {\n    source1.baz2.as[Baz2]\n  } returns Baz2(\"test\", util.Success(7))\n  \n  val `Extract nested case class` = test {\n    source1.bar.as[Bar]\n  } returns Bar(Foo(\"test2\", 2), 2.7)\n  \n  val `Extract deeply-nested case class` = test {\n    json\"\"\"{ \"a\": { \"b\": { \"c\": { \"d\": { \"e\": { \"f\": 1 } } } } } }\"\"\".as[A]\n  } returns A(B(C(D(E(F(1))))))\n\n  val `Extract List element` = test {\n    source1.list(1).as[Int]\n  } returns 2\n  \n  val `Extract object element` = test {\n    source1.bar.foo.alpha.as[String]\n  } returns \"test2\"\n\n  val `Extract null element` = test[Null] {\n    source1.boo.as[Null]\n  } returns null\n\n  val `Extract null element from inner value` = test[Null] {\n    source1.booInner.foo.as[Null]\n  } returns null\n\n  val `Try to extract null element from not null inner value` = test {\n    source1.booInner.bar.as[Null]\n  } throws TypeMismatchException(DataTypes.String, DataTypes.Null)\n\n  val `Try to extract null element from not null value` = test {\n    source1.double.as[Null]\n  } throws TypeMismatchException(DataTypes.Number, DataTypes.Null)\n\n  val `Match null element` = test[Null] {\n    source1 match {\n      case json\"\"\" { \"boo\": $h } \"\"\" => h.as[Null]\n    }\n  } returns null\n\n  val `Match inner null element` = test[Null] {\n    source1 match {\n      case json\"\"\" { \"booInner\": {\"foo\": $h } } \"\"\" => h.as[Null]\n    }\n  } returns null\n\n  val `Extract long element` = test {\n    source1.int.as[Long]\n  } returns 42L\n  \n  val `Extract missing value with case class default` = test {\n    json\"\"\"{\"beta\": 0}\"\"\".as[HasDefault]\n  } returns HasDefault(\"yes\", 0)\n  \n  val `Extract missing value with case class default 2` = test {\n    json\"\"\"{\"alpha\": \"no\"}\"\"\".as[HasDefault2]\n  } returns HasDefault2(\"no\", 1)\n \n  val `Extract case class ignoring default value` = test {\n    json\"\"\"{\"alpha\": \"no\", \"beta\": 0}\"\"\".as[HasDefault2]\n  } returns HasDefault2(\"no\", 0)\n  \n  val `Check type failure` = test {\n    source1.string.as[Int]\n  } throws TypeMismatchException(DataTypes.String, DataTypes.Number)\n\n  val `Check missing value failure` = test {\n    source1.nothing.as[Int]\n  } throws MissingValueException(\"nothing\")\n\n  val `Match string` = test {\n    source1 match {\n      case json\"\"\" { \"string\": $h } \"\"\" => h.as[String]\n    }\n  } returns \"Hello\"\n\n  val `Match inner JSON` = test {\n    source1 match {\n      case json\"\"\" { \"foo\": $foo } \"\"\" => foo\n    }\n  } returns json\"\"\"{ \"alpha\": \"test\", \"beta\": 1 }\"\"\"\n  \n  val `Match inner string` = test {\n    source1 match {\n      case json\"\"\" { \"foo\": { \"alpha\": $t } } \"\"\" => t.as[String]\n    }\n  } returns \"test\"\n  \n  val `Filtered match` = test {\n    source1 match {\n      case json\"\"\" { \"int\": 42, \"foo\": { \"alpha\": $t } } \"\"\" => t.as[String]\n    }\n  } returns \"test\"\n  \n  val `Inner filtered match` = test {\n    source1 match {\n      case json\"\"\" { \"foo\": { \"alpha\": \"test\" }, \"bar\": { \"gamma\": $g } } \"\"\" => g.as[Double]\n    }\n  } returns 2.7\n  \n  val `Filtered failed match` = test {\n    source1 match {\n      case json\"\"\" { \"int\": 0, \"foo\": { \"alpha\": $t } } \"\"\" => t.as[String]\n    }\n  } throws classOf[MatchError]\n\n  val `Multiple pattern match` = test {\n    json\"\"\"{ \"foo\": \"bar\" }\"\"\" match {\n      case json\"\"\"{ \"bar\": \"foo\" }\"\"\" => 0\n      case json\"\"\"{ \"foo\": \"baz\" }\"\"\" => 1\n      case json\"\"\"{ \"foo\": \"bar\" }\"\"\" => 2\n    }\n  } returns 2\n\n  val `Empty object doesn't match` = test {\n    json\"\"\"{ \"foo\": \"bar\" }\"\"\" match {\n      case json\"\"\"{ \"foo\": {} }\"\"\" => 0\n    }\n  } throws classOf[MatchError]\n\n  val `Serialize string` = test {\n    Json(\"Hello World!\").toString\n  } returns \"json\\\"\\\"\\\"\\\"Hello World!\\\"\\\"\\\"\\\"\"\n\n  val `Serialize int` = test {\n    Json(1648).toString\n  } returns \"json\\\"\\\"\\\"1648\\\"\\\"\\\"\"\n\n  val `Serialize array` = test {\n    Json(List(1, 2, 3)).toString\n  } returns \"json\\\"\\\"\\\"[1,2,3]\\\"\\\"\\\"\"\n\n  val `Serialize object` = test {\n    import formatters.humanReadable._\n    Json.format(json\"\"\"{\"baz\":\"quux\",\"foo\":\"bar\"}\"\"\")\n  } returns \"\"\"{\n             | \"baz\": \"quux\",\n             | \"foo\": \"bar\"\n             |}\"\"\".stripMargin\n  \n  val `Empty object serialization` = test {\n    import formatters.humanReadable._\n    Json.format(json\"{}\")\n  } returns \"{}\"\n  \n  val `Empty array serialization` = test {\n    import formatters.humanReadable._\n    Json.format(json\"[]\")\n  } returns \"[]\"\n\n  // As reported by Jim Newsham\n  val `Extracting Option should not throw exception` = test {\n    val j = json\"\"\"{\"foo\":\"bar\"}\"\"\"\n    j.as[Option[String]]\n  } returns None\n\n  val `Tabs should be escaped when serializing strings` = test {\n    Json(\"\\t\").toString\n  } returns \"json\\\"\\\"\\\"\\\"\\\\t\\\"\\\"\\\"\\\"\"\n\n  val `Extract Byte` = test {\n    val j = json\"\"\"{ \"foo\": 127 }\"\"\"\n    j.foo.as[Byte]\n  } returns (127.toByte)\n\n  val `Extract Short` = test {\n    val j = json\"\"\"{ \"foo\": 12345 }\"\"\"\n    j.foo.as[Short]\n  } returns (12345.toShort)\n\n  val `Extract Long` = test {\n    val j = json\"\"\"{ \"foo\": 1234567890123456789 }\"\"\"\n    j.foo.as[Long]\n  } returns 1234567890123456789L\n\n  val `Extract case class with empty/default option` =  test {\n    import rapture.json.formatters.compact._\n    Json.format(Json(FooDefaultOption()))\n  } returns \"{}\"\n\n  val `Extract case class with default None param and one Some(..) param` =  test {\n    import rapture.json.formatters.compact._\n    Json.format(Json(FooDefaultOption(param2 = Some(10))))\n  } returns \"\"\"{\"param2\":10}\"\"\"\n  \n  val `Serialize null` = test { Json(null) } returns json\"\"\"{\"nullValue\":null}\"\"\".nullValue\n\n  val `Parse basic JSON null value` = test { json\"null\" } returns json\"null\"\n\n  /*val `Serialize sealed trait` = test {\n    Json(Left(50): Either[Int, String])\n  }.returns(json\"\"\"{\"left\":50}\"\"\")\n\n  val `Extract sealed trait` = test {\n    json\"\"\"{ \"left\": 50 }\"\"\".as[Either[Int, String]]\n  }.returns(Left(50))*/\n}\n\nabstract class MutableJsonTests(ast: JsonBufferAst, parser: Parser[String, JsonBufferAst]) extends TestSuite {\n \n  implicit def implicitAst: JsonBufferAst = ast\n  implicit def implicitParser: Parser[String, JsonBufferAst] = parser\n\n  case class Foo(alpha: String, beta: Int)\n  case class Bar(foo: Foo, gamma: Double)\n  \n  val mutableSource = jsonBuffer\"\"\"{\n    \"string\": \"Hello\",\n    \"int\": 42,\n    \"double\": 3.14159,\n    \"boolean\": true,\n    \"list\": [1, 2, 3],\n    \"foo\": { \"alpha\": \"test\", \"beta\": 1 },\n    \"bar\": { \"foo\": { \"alpha\": \"test2\", \"beta\": 2 }, \"gamma\": 2.7 },\n    \"baz\": { \"alpha\": \"test\" },\n    \"baz2\": { \"alpha\": \"test\", \"beta\": 7 },\n    \"self\": 0\n  }\"\"\"\n\n  val `Mutable extract Int` = test {\n    mutableSource.int.as[Int]\n  } returns 42\n  \n  val source2 = JsonBuffer.parse(\"\"\"{\n    \"string\": \"Hello\",\n    \"int\": 42\n  }\"\"\")\n\n  val `Mutable get String` = test {\n    source2.string.as[String]\n  } returns \"Hello\"\n\n  //val `Mutable get optional String` = test {\n  //  source2.string.as[Option[String]]\n  //} returns Some(\"Hello\")\n\n  val `Mutable get Int` = test {\n    source2.int.as[Int]\n  } returns 42\n\n  val `Mutable change String` = test {\n    source2.string = \"World\"\n    source2.string.as[String]\n  } returns \"World\"\n\n  val `Mutable add String` = test {\n    source2.inner.newString = \"Hello\"\n    source2.inner.newString.as[String]\n  } returns \"Hello\"\n \n  val `Mutable add Json` = test {\n    val jb = JsonBuffer.empty\n    jb.foo = json\"\"\"{ \"foo\": \"bar\" }\"\"\"\n  } returns jsonBuffer\"\"\"{ \"foo\": { \"foo\": \"bar\" } }\"\"\"\n\n  val `Mutable add case class` = test {\n    source2.foo = Foo(\"string\", -1)\n    source2.foo.as[Foo]\n  } returns Foo(\"string\", -1)\n \n  val `Deep insertion of integer` = test {\n    source2.alpha.beta.gamma.delta = 1\n    source2.alpha.beta.gamma.delta.as[Int]\n  } returns 1\n\n  val `Array autopadding` = test {\n    source2.autopad(4) = 1\n    source2.autopad(4).as[Int]\n  } returns 1\n\n  val `Deep array insertion of integer` = test {\n    source2.array(1)(2)(3)(4) = 1\n    source2.array(1)(2)(3)(4).as[Int]\n  } returns 1\n\n  val `Deep mixed insertion of string` = test {\n    source2.mixed(4).foo.bar(2).baz = \"Mixed\"\n    source2.mixed(4).foo.bar(2).baz.as[String]\n  } returns \"Mixed\"\n\n  val `Mutable add array String` = test {\n    source2.inner.newArray += \"Hello\"\n    source2.inner.newArray(0).as[String]\n  } returns \"Hello\"\n}\n"
  },
  {
    "path": "latex/shared/src/main/scala/latex/latex.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.latex\n\nimport rapture.io._\nimport rapture.fs._\nimport rapture.text._\nimport rapture.uri._\nimport rapture.core._\nimport rapture.cli._\nimport rapture.codec._, encodings.`UTF-8`._\n\nimport language.implicitConversions\n\nobject TemporaryStorage {\n  implicit def defaultTemporary: TemporaryStorage = TemporaryStorage(uri\"file:///tmp\")\n}\n\ncase class TemporaryStorage(file: FsUrl) {\n  def tmpFile(prefix: String = \"rapture\", suffix: String = \".tmp\") =\n    File.parse(java.io.File.createTempFile(prefix, suffix, file.javaFile).getAbsolutePath)\n}\n\ntrait LatexBackend {\n  def process(latex: Latex, data: Seq[(String, Bytes)], mode: Mode[_], tmp: TemporaryStorage): PdfFile\n}\n\npackage latexBackends {\n  object xelatex {\n    implicit val implicitLatexBackend: LatexBackend = new LatexBackend {\n      def process(latex: Latex, data: Seq[(String, Bytes)], mode: Mode[_], tmp: TemporaryStorage): PdfFile = {\n        val dir = tmp.file / Guid.generate()()\n        dir.mkdir()\n        data.foreach {\n          case (name, bytes) =>\n            val f = dir / name\n            bytes.copyTo(f)\n        }\n        val file = dir / \"document.tex\"\n        implicit val env: Environment = new Environment {\n          def workDir = Some(dir.javaFile.getAbsolutePath)\n          def apply() = environments.enclosing()()\n        }\n\n        latex.content.copyTo(file)\n        val cmd = sh\"/usr/bin/xelatex -interaction nonstopmode ${file}\"\n        val output = cmd.exec[Iterator[String]]\n\n        while (output.hasNext) {\n          var next = output.next()\n          if (next startsWith \"! \") {\n            val msg = next.drop(if (next.startsWith(\"! LaTeX Error: \")) 15 else 2)\n            val content = new StringBuilder()\n            while (output.hasNext && !next.startsWith(\"l.\")) {\n              next = output.next()\n              if (!next.startsWith(\"l.\")) content.append(s\"$next\\n\")\n              else {\n                val line = next.drop(2).takeWhile(_ != ' ').toInt\n                mode.exception(LatexException(msg, line, content.toString.trim))\n              }\n            }\n          }\n        }\n\n        PdfFile((file.parent / file.filename.replaceAll(\"tex$\", \"pdf\")).slurp[Byte])\n      }\n    }\n  }\n}\n\nobject Latex {\n  def escape(string: String): String = string.flatMap {\n    case c @ ('#' | '$' | '%' | '&' | '_' | '{' | '}') => s\"\\\\$c\"\n    case '\\\\' => \"\\\\textbackslash{}\"\n    case '\\n' => \" \\\\\\\\\\n\"\n    case '^' => \"\\\\textasciicircum{}\"\n    case '~' => \"\\\\textasciitilde{}\"\n    case c => c.toString\n  }\n}\n\ntrait `Latex#generate` extends MethodConstraint\n\ncase class LatexException(msg: String, line: Int, content: String) extends Exception {\n  override def getMessage = s\"latex error at line $line: $msg\"\n}\n\ncase class Latex(content: String) {\n\n  def generate(data: (String, Bytes)*)(implicit backend: LatexBackend,\n                                       mode: Mode[`Latex#generate`],\n                                       tmp: TemporaryStorage): mode.Wrap[PdfFile, LatexException] =\n    mode.wrap { backend.process(this, data, mode, tmp) }\n}\n\ncase class PdfFile(data: Bytes)\n\nobject Latexable {\n  implicit val stringLatexable: Latexable[String] = new Latexable[String] {\n    def toLatex(s: String) = Latex.escape(s)\n  }\n\n  implicit val latexLatexable: Latexable[Latex] = new Latexable[Latex] {\n    def toLatex(latex: Latex) = latex.content\n  }\n\n  implicit def seqLatexable[T: Latexable]: Latexable[Seq[T]] = new Latexable[Seq[T]] {\n    def toLatex(seq: Seq[T]) = seq.map(?[Latexable[T]].toLatex(_)).mkString\n  }\n}\n\ntrait Latexable[-T] { def toLatex(t: T): String }\n\ncase class LatexStringContext(sc: StringContext) {\n  def latex(variables: Annex[Latexable]*)(implicit process: TextProcess) =\n    Latex(process(sc.parts.zip(variables.map(_ (_.toLatex))).map { case (a, b) => a + b }.mkString + sc.parts.last))\n}\n\nobject `package` {\n  implicit def latexStringContext(sc: StringContext): LatexStringContext = LatexStringContext(sc)\n}\n"
  },
  {
    "path": "log/shared/src/main/scala/rapture/log/levels.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.log\n\ntrait LogLevel\ntrait Trace extends LogLevel\ntrait Debug extends Trace\ntrait Info extends Debug\ntrait Warn extends Info\ntrait Error extends Warn\ntrait Fatal extends Error\n\nobject logLevels {\n\n  object trace {\n    implicit val logLevelImplicit: NamedLogAction = new NamedLogAction(0, \"trace\")\n  }\n\n  object debug {\n    implicit val logLevelImplicit: NamedLogAction = new NamedLogAction(1, \"debug\")\n  }\n\n  object info {\n    implicit val logLevelImplicit: NamedLogAction = new NamedLogAction(2, \"info\")\n  }\n\n  object warn {\n    implicit val logLevelImplicit: NamedLogAction = new NamedLogAction(3, \"warn\")\n  }\n\n  object error {\n    implicit val logLevelImplicit: NamedLogAction = new NamedLogAction(4, \"error\")\n  }\n\n  object fatal {\n    implicit val logLevelImplicit: NamedLogAction = new NamedLogAction(5, \"fatal\")\n  }\n}\n"
  },
  {
    "path": "log/shared/src/main/scala/rapture/log/log.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.log\n\nimport rapture.base._\nimport rapture.core._\nimport rapture.io._\n\nimport scala.annotation._\n\nimport language.experimental.macros\n\nobject `package` {\n  val log = Log\n\n  implicit class LogStringContext(sc: StringContext) {\n    def log(xs: rapture.log.parts.Part*): Spec = {\n      new Spec {\n        def render(level: Int, lineNo: Int, source: String) = {\n          val sb = new StringBuilder\n          for (i <- 0 until (sc.parts.length - 1)) {\n            sb.append(sc.parts(i))\n            sb.append(xs(i).fit(level, lineNo, source))\n          }\n          sb.append(sc.parts.last)\n          sb.toString\n        }\n      }\n    }\n  }\n}\n\ntrait Outputter {\n  def log[L <: LogLevel](prefix: String, msg: Array[String])\n}\n\nobject LogAction {\n  implicit def defaultLogAction(implicit act: NamedLogAction): LogAction =\n    new LogAction { def level = -1 }\n}\n\n@implicitNotFound(\n    \"You have not specified a valid logging level. Please import one of logLevels\" +\n      \".{trace._, debug._, info._, warn._, error._, fatal._}.\")\ntrait LogAction {\n  def level: Int\n}\n\nclass NamedLogAction(val level: Int, val name: String) extends LogAction\n\nobject Loggable {\n  implicit val stringLoggable: Loggable[String] = new Loggable[String] {\n    def toArray(msg: String) = Array(msg)\n  }\n\n  implicit val exceptionLoggable: Loggable[Throwable] = new Loggable[Throwable] {\n    def toArray(msg: Throwable) = Array(msg.toString) ++ msg.getStackTrace.map(\"        at \" + _)\n  }\n}\ntrait Loggable[-Msg] { def toArray(msg: Msg): Array[String] }\n\nobject SourceContext {\n  implicit def sourceContext: SourceContext = macro LogMacros.sourceContextMacro\n}\ncase class SourceContext(lineNo: Int, sourceFile: String)\n\nobject LogMacros {\n  def logMacro[Msg: c.WeakTypeTag](level: Int)(c: BlackboxContext)(msg: c.Expr[Msg])(\n      log: c.Expr[Log],\n      loggable: c.Expr[Loggable[Msg]],\n      srcCtx: c.Expr[SourceContext]): c.Expr[Unit] = {\n    import c.universe._\n    val lev = c.Expr[Int](q\"$level\")\n    reify {\n      if (log.splice.action.level <= lev.splice) {\n        log.splice.out.log(log.splice.spec.render(lev.splice, srcCtx.splice.lineNo, srcCtx.splice.sourceFile),\n                           loggable.splice.toArray(msg.splice))\n      }\n    }\n  }\n\n  def sourceContextMacro(c: BlackboxContext): c.Expr[SourceContext] = {\n    import c.universe._\n    val lineNo = c.Expr[Int](q\"${c.enclosingPosition.line}\")\n    val sourceFile = c.Expr[String](q\"${c.enclosingPosition.source.toString}\")\n    reify { SourceContext(lineNo.splice, sourceFile.splice) }\n  }\n\n  def traceMacro[Msg: c.WeakTypeTag](c: BlackboxContext)(msg: c.Expr[Msg])(\n      log: c.Expr[Log],\n      loggable: c.Expr[Loggable[Msg]],\n      sourceContext: c.Expr[SourceContext]): c.Expr[Unit] =\n    logMacro(0)(c)(msg)(log, loggable, sourceContext)\n\n  def debugMacro[Msg: c.WeakTypeTag](c: BlackboxContext)(msg: c.Expr[Msg])(\n      log: c.Expr[Log],\n      loggable: c.Expr[Loggable[Msg]],\n      sourceContext: c.Expr[SourceContext]): c.Expr[Unit] =\n    logMacro(1)(c)(msg)(log, loggable, sourceContext)\n\n  def infoMacro[Msg: c.WeakTypeTag](c: BlackboxContext)(msg: c.Expr[Msg])(\n      log: c.Expr[Log],\n      loggable: c.Expr[Loggable[Msg]],\n      sourceContext: c.Expr[SourceContext]): c.Expr[Unit] =\n    logMacro(2)(c)(msg)(log, loggable, sourceContext)\n\n  def warnMacro[Msg: c.WeakTypeTag](c: BlackboxContext)(msg: c.Expr[Msg])(\n      log: c.Expr[Log],\n      loggable: c.Expr[Loggable[Msg]],\n      sourceContext: c.Expr[SourceContext]): c.Expr[Unit] =\n    logMacro(3)(c)(msg)(log, loggable, sourceContext)\n\n  def errorMacro[Msg: c.WeakTypeTag](c: BlackboxContext)(msg: c.Expr[Msg])(\n      log: c.Expr[Log],\n      loggable: c.Expr[Loggable[Msg]],\n      sourceContext: c.Expr[SourceContext]): c.Expr[Unit] =\n    logMacro(4)(c)(msg)(log, loggable, sourceContext)\n\n  def fatalMacro[Msg: c.WeakTypeTag](c: BlackboxContext)(msg: c.Expr[Msg])(\n      log: c.Expr[Log],\n      loggable: c.Expr[Loggable[Msg]],\n      sourceContext: c.Expr[SourceContext]): c.Expr[Unit] =\n    logMacro(5)(c)(msg)(log, loggable, sourceContext)\n}\n\nabstract class Spec {\n  def render(level: Int, lineNo: Int, source: String): String\n}\n\n/*object Main extends App {\n  import logLevels.debug._\n  import encodings.system\n  implicit val output = Logger(Stdout)\n  implicit val spec = log\"  \"\n  Log.logImplicit\n  log.info(\"Here is an information message.\")\n  sys.exit(1)\n}*/\n\nobject Log {\n  implicit def logImplicit(implicit spec: Spec, out: Outputter, action: LogAction) =\n    Log(spec, out, action)\n\n  def trace[Msg](msg: Msg)(implicit log: Log, loggable: Loggable[Msg], sourceContext: SourceContext): Unit = macro LogMacros\n    .traceMacro[Msg]\n\n  def debug[Msg](msg: Msg)(implicit log: Log, loggable: Loggable[Msg], sourceContext: SourceContext): Unit = macro LogMacros\n    .debugMacro[Msg]\n\n  def info[Msg](msg: Msg)(implicit log: Log, loggable: Loggable[Msg], sourceContext: SourceContext): Unit = macro LogMacros\n    .infoMacro[Msg]\n\n  def warn[Msg](msg: Msg)(implicit log: Log, loggable: Loggable[Msg], sourceContext: SourceContext): Unit = macro LogMacros\n    .warnMacro[Msg]\n\n  def error[Msg](msg: Msg)(implicit log: Log, loggable: Loggable[Msg], sourceContext: SourceContext): Unit = macro LogMacros\n    .errorMacro[Msg]\n\n  def fatal[Msg](msg: Msg)(implicit log: Log, loggable: Loggable[Msg], sourceContext: SourceContext): Unit = macro LogMacros\n    .fatalMacro[Msg]\n}\ncase class Log(spec: Spec, out: Outputter, action: LogAction)\n\ncase class Logger[Res](res: Res)(implicit appender: Appender[Res, String]) extends Outputter {\n\n  final val maxDelay = 25\n  final val queueThreshold = 10\n\n  private val queue = new scala.collection.mutable.Queue[String]\n  private var blankPrefix: String = null\n\n  private val thread: Thread = Thread.fork(\"rapture-log\") {\n    var continue = true\n    sys.addShutdownHook { continue = false }\n\n    while (continue) {\n      try {\n        queue synchronized {\n          queue.wait(maxDelay)\n          if (queue.nonEmpty) res handleAppend { out: Output[String] =>\n            while (queue.nonEmpty) out.write(queue.dequeue)\n          }\n        }\n      } catch {\n        case e: InterruptedException =>\n          continue = false\n      }\n    }\n  }\n\n  def log[L <: LogLevel](prefix: String, msg: Array[String]) = queue synchronized {\n    if (blankPrefix == null) blankPrefix = \" \" * (prefix.length + 1)\n    queue.enqueue(prefix + \" \" + msg(0))\n    msg.tail foreach { m =>\n      queue.enqueue(blankPrefix + m)\n    }\n    if (queue.size >= queueThreshold) queue.notify()\n  }\n}\n\nobject stdoutLogging {\n  import parts._\n  implicit def implicitSpec(implicit severity: Severity, date: Date, time: Time, thread: Thread): Spec =\n    log\"\"\"$date $time [$severity] ${sourceFile(width = 12, Right)}:${lineNo(4)} ${thread(10)}\"\"\"\n\n  implicit val output = Logger(Stdout)\n\n  def apply()(implicit severity: Severity, date: Date, time: Time, thread: Thread): Spec with Outputter =\n    new Spec with Outputter {\n\n      def render(level: Int, lineNo: Int, source: String): String =\n        implicitSpec.render(level, lineNo, source)\n\n      def log[L <: LogLevel](prefix: String, msg: Array[String]) = output.log(prefix, msg)\n    }\n}\n"
  },
  {
    "path": "log/shared/src/main/scala/rapture/log/parts.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.log\n\nimport rapture.core._\n\nobject parts {\n\n  abstract class Part(width: Int, align: Alignment) { part =>\n    def text(level: Int, lineNo: Int, source: String): String\n    def fit(level: Int, lineNo: Int, source: String) = {\n      val t = text(level, lineNo, source)\n      if (t.length > width) t.substring(0, width)\n      else if (align == Left) t.padTo(width, ' ')\n      else \" \" * (width - t.length) + t\n    }\n\n    def apply(width: Int = width, align: Alignment = align): Part = new Part(width, align) {\n      def text(level: Int, lineNo: Int, source: String) =\n        part.text(level, lineNo, source)\n    }\n  }\n\n  sealed trait Alignment\n  case object Left extends Alignment\n  case object Right extends Alignment\n\n  object Severity {\n    implicit def severity: Severity = new Severity()\n  }\n\n  class Severity() extends Part(5, Left) {\n    def text(level: Int, lineNo: Int, source: String) = level match {\n      case 0 => \"TRACE\"\n      case 1 => \"DEBUG\"\n      case 2 => \"INFO\"\n      case 3 => \"WARN\"\n      case 4 => \"ERROR\"\n      case 5 => \"FATAL\"\n    }\n  }\n\n  object Time {\n    implicit def logTime = new Time(System.currentTimeMillis)\n    val timeFormat = new java.text.SimpleDateFormat(\"HH:mm:ss.SSS\")\n  }\n\n  class Time(time: Long) extends Part(12, Left) {\n    def text(level: Int, lineNo: Int, source: String) = Time.timeFormat.format(time)\n  }\n\n  object Date {\n    implicit def logDate = new Date(System.currentTimeMillis)\n    val dateFormat = new java.text.SimpleDateFormat(\"dd-MMM-yyyy\")\n  }\n\n  class Date(date: Long) extends Part(9, Left) {\n    def text(level: Int, lineNo: Int, source: String) = Date.dateFormat.format(date)\n  }\n\n  object sourceFile extends Part(4, Left) {\n    def text(level: Int, lineNo: Int, source: String) = source.toString\n  }\n\n  object lineNo extends Part(4, Left) {\n    def text(level: Int, lineNo: Int, source: String) = lineNo.toString\n  }\n\n  object Thread {\n    implicit def currentThread: Thread = new Thread(java.lang.Thread.currentThread.getName)\n  }\n\n  class Thread(name: String) extends Part(10, Left) {\n    def text(level: Int, lineNo: Int, source: String) = name\n  }\n}\n"
  },
  {
    "path": "mail/shared/src/main/scala/rapture/mail/javamail.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.mail\n\nimport rapture.core._\n\npackage sendmailBackends {\n  object javamail {\n    def apply()(implicit smtpServer: Smtp): SendmailBackend = implicitSendmailBackend\n    implicit def implicitSendmailBackend(implicit smtpServer: Smtp): SendmailBackend =\n      new SendmailBackend {\n        def sendmail(to: Seq[String],\n                     from: String,\n                     subject: String,\n                     cc: Seq[String],\n                     bcc: Seq[String],\n                     bodyText: String,\n                     bodyHtml: Option[(String, Seq[Annex[Attachable]])],\n                     attachments: Seq[Annex[Attachable]])(implicit mode: Mode[_]): mode.Wrap[SendReport, SendAddressException with SendException] = mode wrap {\n\n          import javax.mail._\n          import javax.mail.util._\n          import javax.mail.internet._\n          import javax.activation._\n\n          val props = System.getProperties()\n          props.put(\"mail.smtp.host\", smtpServer.hostname)\n          props.put(\"mail.smtp.port\", smtpServer.port.toString)\n          val session = Session.getDefaultInstance(props, null)\n          val msg = new MimeMessage(session)\n          \n          msg.setFrom(new InternetAddress(from))\n          for (r <- to) msg.addRecipient(Message.RecipientType.TO, new InternetAddress(r))\n          for (r <- cc) msg.addRecipient(Message.RecipientType.CC, new InternetAddress(r))\n          for (r <- bcc) msg.addRecipient(Message.RecipientType.BCC, new InternetAddress(r))\n          msg.setSubject(subject)\n\n          def source(attachment: Annex[Attachable], inline: Boolean) = {\n            val part = new MimeBodyPart()\n            part.setDisposition(if(inline) Part.INLINE else Part.ATTACHMENT)\n            if(inline) part.setHeader(\"Content-ID\", s\"<${attachment(_.resourceName)}>\")\n            else part.setFileName(attachment(_.resourceName))\n            part.setDataHandler(new DataHandler(new ByteArrayDataSource(attachment(_.bytes).bytes, attachment(_.contentType).name)))\n            part\n          }\n          \n          bodyHtml match {\n            case Some((html, inlines)) =>\n              var top = new MimeMultipart(\"alternative\")\n              val textPart = new MimeBodyPart()\n              textPart.setText(bodyText, \"UTF-8\")\n              top.addBodyPart(textPart)\n\n              val htmlPart = new MimeBodyPart()\n              htmlPart.setContent(html, \"text/html;charset=UTF-8\")\n              top.addBodyPart(htmlPart)\n\n              if (inlines.length > 0) {\n                val body = new MimeBodyPart()\n                body.setContent(top)\n                top = new MimeMultipart(\"related\")\n                top.addBodyPart(body)\n                inlines.foreach { inline => top.addBodyPart(source(inline, true)) }\n              }\n\n              if (attachments.length > 0) {\n                val body = new MimeBodyPart()\n                body.setContent(top)\n                top = new MimeMultipart(\"mixed\")\n                top.addBodyPart(body)\n                attachments.foreach { attachment => top.addBodyPart(source(attachment, false)) }\n              }\n              msg.setContent(top)\n\n            case None => {\n              if (attachments.length > 0) {\n                val body = new MimeBodyPart()\n                body.setText(bodyText, \"UTF-8\")\n                val top = new MimeMultipart(\"mixed\")\n                top.addBodyPart(body)\n                attachments.foreach { attachment => top.addBodyPart(source(attachment, false)) }\n                msg.setContent(top)\n              } else {\n                msg.setText(bodyText, \"UTF-8\")\n              }\n            }\n          }\n\n          Transport.send(msg)\n          SendReport(msg.getMessageID)\n        }\n      }\n  }\n}\n"
  },
  {
    "path": "mail/shared/src/main/scala/rapture/mail/mail.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.mail\n\nimport rapture.base._\nimport rapture.core._\nimport rapture.io._\nimport rapture.uri._\nimport rapture.html._\nimport rapture.mime._\nimport rapture.codec._\n\nimport scala.reflect._\nimport scala.language.experimental.macros\n\nobject Macros {\n\n  def mailtoMacro(c: BlackboxContext)(constants: c.Expr[List[String]])(\n      variables: c.Expr[List[String]]): c.Expr[MailtoUri] = {\n    import c.universe._\n\n    c.Expr(q\"\"\"\n      new _root_.rapture.mail.MailtoUri(_root_.scala.List($constants,\n          $variables :+ \"\").transpose.flatten.mkString)\n    \"\"\")\n  }\n\n  def contactMacro(c: BlackboxContext)(variables: c.Expr[String]*): c.Expr[Contact] = {\n    import c.universe._\n\n    val literals = c.prefix.tree match {\n      case Apply(_, List(Apply(_, rawParts))) => rawParts.map {\n        case Literal(Constant(s: String)) => s\n      }\n    }\n\n    val mock = literals.mkString(\"x\")\n\n    val result = if(Contact.parse(mock).isDefined) c.Expr(q\"\"\"\n      _root_.rapture.mail.Contact.parse(_root_.scala.List($literals,\n          _root_.scala.List(..$variables, \"\")).transpose.flatten.mkString).get\n    \"\"\") else c.abort(c.enclosingPosition, \"this is not a valid email address\")\n\n\n    result\n  }\n\n  def smtpMacro(c: BlackboxContext)(constants: c.Expr[List[String]])(\n      variables: c.Expr[List[String]]): c.Expr[Smtp] = {\n    import c.universe._\n    import compatibility._\n    \n    val start = constants.tree match {\n      case Apply(_, constants) =>\n        val Literal(Constant(start: String)) = constants.head\n        start\n    }\n    if(!start.startsWith(\"//\")) c.abort(c.enclosingPosition, \"this is not a valid SMTP URI\")\n    val rest = start.substring(2)\n\n    val newName = termName(c, freshName(c)(\"ctx\"))\n\n    c.Expr[Smtp](q\"\"\"{\n      val $newName = List($constants, $variables :+ \"\").transpose.flatten.mkString.substring(2).split(\":\")\n      _root_.rapture.mail.Smtp($newName(0), new _root_.rapture.core.EnrichedString(\n          if($newName.length > 1) $newName(1) else \"25\").as[_root_.scala.Int](\n          _root_.rapture.core.StringParser.intParser, _root_.rapture.core.modes.returnOption()).getOrElse(25))\n    }\"\"\")\n  }\n\n}\n\ntrait `Smtp#send` extends MethodConstraint\ntrait `Smtp#sendmail` extends MethodConstraint\ntrait `send` extends MethodConstraint\ntrait `sendTo` extends MethodConstraint\n\nobject Mailto {\n  private val Regex =\n    \"\"\"^mailto:([_A-Za-z0-9-\\\\+]+(\\\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\\\.[A-Za-z0-9]+)*(\\\\.[A-Za-z]{2,}))$\"\"\".r\n\n  def parse(s: String): MailtoUri = s match {\n    case Regex(address, _, _, _) => new MailtoUri(address)\n  }\n}\n\nobject MailtoUri {\n  implicit val mailtoUriLinkable: UriCapable[MailtoUri] = new UriCapable[MailtoUri] {\n    def uri(mu: MailtoUri): Uri =\n      Uri(\"mailto\", mu.email)\n  }\n}\n\ncase class MailtoUri(email: String) {\n  override def toString = s\"mailto:$email\"\n}\n\ncase class HtmlEmail(html: HtmlDoc, inlines: List[Annex[Attachable]], attachments: List[Annex[Attachable]])\n\nobject Attachable {\n  implicit def attachable[Res: HasResourceName: HasContentType: Reader.ForBytes] = new Attachable[Res] {\n    def resourceName(res: Res): String = res.resourceName\n    def contentType(res: Res): MimeTypes.MimeType = res.contentType\n    def bytes(res: Res): Bytes = res.slurp[Byte]\n  }\n}\n\ntrait Attachable[Res] {\n  def resourceName(res: Res): String\n  def contentType(res: Res): MimeTypes.MimeType\n  def bytes(res: Res): Bytes\n}\n\ncase class Envelope(\n  subject: String,\n  from: Contact,\n  to: SeqParameter[Contact],\n  cc: SeqParameter[Contact] = Nil,\n  bcc: SeqParameter[Contact] = Nil) {\n\n  def insert(mailable: Annex[Mailable], attachments: Annex[Attachable]*) =\n    EmailMessage(from, to.elements, cc.elements, bcc.elements, subject, mailable, attachments)\n}\n\nobject EmailMessage {\n  implicit val emailMessageSendable: Sendable[EmailMessage] = new Sendable[EmailMessage] {\n    def to(env: EmailMessage): Seq[Contact] = env.to\n    def cc(env: EmailMessage): Seq[Contact] = env.cc\n    def bcc(env: EmailMessage): Seq[Contact] = env.bcc\n    def from(env: EmailMessage): Contact = env.from\n    def subject(env: EmailMessage): String = env.subject\n    def bodyText(env: EmailMessage): String = env.mailable(_.bodyText)\n    def bodyHtml(env: EmailMessage): Option[(String, Seq[Annex[Attachable]])] = env.mailable(_.bodyHtml)\n    def attachments(env: EmailMessage): Seq[Annex[Attachable]] = env.mailable(_.attachments)\n  }\n}\n\ncase class EmailMessage(from: Contact, to: Seq[Contact], cc: Seq[Contact], bcc: Seq[Contact], subject: String, mailable: Annex[Mailable], attachments: Seq[Annex[Attachable]]*)\n\nclass ContactStringContext(sc: StringContext) {\n  def contact(variables: String*): Contact = macro Macros.contactMacro\n}\nobject Contact {\n  private val EmailWithName =\n    \"\"\"^([^<]*) <([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,})>$\"\"\".r\n  \n  private val JustEmail =\n    \"\"\"^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,})$\"\"\".r\n\n  def parse(email: String): Option[Contact] = email match {\n    case JustEmail(e, _, _) => Some(Contact(e))\n    case EmailWithName(n, e, _, _0) => Some(Contact(e, Some(n)))\n    case _ => None\n  }\n}\n\ncase class Contact(email: String, name: Option[String] = None) {\n  override def toString = if (name == None) email else s\"\"\"\"${name.get}\" <${email}>\"\"\"\n}\n\nobject Smtp {\n  private val Regex = \"\"\"^smtp:\\/\\/([^:]*)(:([1-9][0-9]*))?\\/?$\"\"\".r\n\n  def parse(s: String) = s match {\n    case Regex(host, _, port) => new Smtp(host, Option(port).map(_.toInt).getOrElse(25))\n  }\n}\n\ncase class MailEnrichedUriContext(uri: UriContext.type) {\n  def mailto(constants: List[String])(variables: List[String]): MailtoUri = macro Macros.mailtoMacro\n  def smtp(constants: List[String])(variables: List[String]): Smtp = macro Macros.smtpMacro\n  def cid(constants: List[String])(variables: List[String]): PathLink = PathLink(s\"cid:${List(constants, variables :+ \"\").transpose.flatten.mkString}\")\n}\n\nobject Mailable {\n  implicit val stringMailable: Mailable[String] = new Mailable[String] {\n    def bodyText(t: String) = t\n    def bodyHtml(t: String) = None\n    def attachments(t: String): Seq[Annex[Attachable]] = Nil\n  }\n\n  implicit def htmlMailable(implicit conv: HtmlToPlainTextConverter): Mailable[HtmlEmail] =\n    new Mailable[HtmlEmail] {\n      def bodyText(t: HtmlEmail) = conv.convert(t.html)\n      def bodyHtml(t: HtmlEmail) = Some((t.html.format, t.inlines))\n      def attachments(t: HtmlEmail) = t.attachments\n    }\n\n}\n\nobject Attachment {\n  implicit def attachmentIsAttachable: Attachable[Attachment] = new Attachable[Attachment] {\n    def resourceName(attachment: Attachment): String = attachment.name\n    \n    def contentType(attachment: Attachment): MimeTypes.MimeType =\n      attachment.contentType().orElse(MimeTypes.extension(attachment.name).headOption).getOrElse(\n          MimeTypes.`application/octet-stream`)\n    \n    def bytes(attachment: Attachment): Bytes =\n      attachment.content { implicit reader => _.slurp[Byte] }\n  }\n}\n\ncase class Attachment(name: String, content: Annex[Reader.ForBytes],\n    contentType: OptionalParameter[MimeTypes.MimeType] = UnspecifiedParameter)\n\ntrait Mailable[T] {\n  def bodyText(t: T): String\n  def bodyHtml(t: T): Option[(String, Seq[Annex[Attachable]])]\n  def attachments(t: T): Seq[Annex[Attachable]]\n}\n\nobject `package` {\n  implicit def mailEnrichedUriContext(uri: UriContext.type): MailEnrichedUriContext =\n    MailEnrichedUriContext(uri)\n  \n  implicit def mailEnrichedStringContext(sc: StringContext): ContactStringContext =\n    new ContactStringContext(sc)\n  \n  implicit def sendExtensionMethod[T: Sendable](sendable: T): Sendable.Capability[T] =\n    Sendable.Capability[T](sendable)\n}\n\ncase class Smtp(hostname: String, port: Int = 25)\n\n/*{\n\n  def sendmail(to: Seq[Contact],\n                             from: Contact,\n                             subject: String,\n                             cc: Seq[Contact],\n                             bcc: Seq[Contact],\n                             content: String,\n                             bodyHtml: Option[(String, Seq[Annex[Attachable]])],\n                             attachments: Seq[Annex[Attachable]])(implicit mode: Mode[`Smtp#sendmail`],\n                                                                           backend: SendmailBackend): mode.Wrap[SendReport, SendAddressException with SendException] =\n    backend.sendmail(hostname,\n                     port,\n                     to.map(_.toString),\n                     from.toString,\n                     subject,\n                     cc.map(_.toString),\n                     bcc.map(_.toString),\n                     content,\n                     bodyHtml,\n                     attachments)\n}*/\n\ncase class SendReport(messageId: String)\n\nobject Sendable {\n  case class Capability[T: Sendable](msg: T) {\n    def send()(implicit mode: Mode[`send`], sendmailBackend: SendmailBackend): mode.Wrap[SendReport,\n        SendAddressException with SendException] =\n      sendmailBackend.sendmail(\n        to = ?[Sendable[T]].to(msg).map(_.toString),\n        from = ?[Sendable[T]].from(msg).toString,\n        subject = ?[Sendable[T]].subject(msg),\n        cc = ?[Sendable[T]].cc(msg).map(_.toString),\n        bcc = ?[Sendable[T]].bcc(msg).map(_.toString),\n        bodyText = ?[Sendable[T]].bodyText(msg),\n        bodyHtml = ?[Sendable[T]].bodyHtml(msg),\n        attachments = ?[Sendable[T]].attachments(msg)\n      )\n  }\n}\n\ntrait Sendable[T] {\n  def to(t: T): Seq[Contact]\n  def cc(t: T): Seq[Contact]\n  def bcc(t: T): Seq[Contact]\n  def from(t: T): Contact\n  def subject(t: T): String\n  def bodyText(t: T): String\n  def bodyHtml(t: T): Option[(String, Seq[Annex[Attachable]])]\n  def attachments(t: T): Seq[Annex[Attachable]]\n}\n\ncase class SendAddressException(invalid: Set[Contact], validSent: Set[Contact],\n    validUnsent: Set[Contact]) extends RuntimeException(\"the email could not be sent to all addresses\")\n\ncase class SendException() extends RuntimeException(\"the email could not be sent\")\n\n\ntrait SendmailBackend {\n  def sendmail(to: Seq[String],\n               from: String,\n               subject: String,\n               cc: Seq[String],\n               bcc: Seq[String],\n               bodyText: String,\n               bodyHtml: Option[(String, Seq[Annex[Attachable]])],\n               attachments: Seq[Annex[Attachable]])(implicit mode: Mode[_]): mode.Wrap[SendReport, SendAddressException with SendException]\n}\n"
  },
  {
    "path": "mail/shared/src/main/scala/rapture/mail/plaintext.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.mail\n\nimport rapture.core._\nimport rapture.io._\nimport rapture.fs._\nimport rapture.uri._\nimport rapture.html._\nimport rapture.cli._, environments.enclosing._\nimport rapture.codec._, encodings.`UTF-8`._\n\npackage htmlToPlainTextConverters {\n\n  object elinks {\n    implicit val htmlToPlainTextConverter: HtmlToPlainTextConverter = new HtmlToPlainTextConverter {\n      def convert(html: HtmlDoc): String = {\n        val file = uri\"file:///tmp/${Guid.generate()()}.html\"\n        html.format.copyTo(file)\n        val output = sh\"elinks -dump -dump-width 76 '$file'\".exec[String]\n        file.delete()\n        output\n      }\n    }\n  }\n\n  object links {\n    implicit val htmlToPlainTextConverter: HtmlToPlainTextConverter = new HtmlToPlainTextConverter {\n      def convert(html: HtmlDoc): String = {\n        val file = uri\"file:///tmp/${Guid.generate()()}.html\"\n        html.format.copyTo(file)\n        val output = sh\"links -dump 'file://$file'\".exec[String]\n        file.delete()\n        output\n      }\n    }\n  }\n\n  object lynx {\n    implicit val htmlToPlainTextConverter: HtmlToPlainTextConverter = new HtmlToPlainTextConverter {\n      def convert(html: HtmlDoc): String = {\n        val file = uri\"file:///tmp/${Guid.generate()()}.html\"\n        html.format.copyTo(file)\n        val output = sh\"lynx -dump -width=76 'file://$file'\".exec[String]\n        file.delete()\n        output\n      }\n    }\n  }\n\n}\n\ntrait HtmlToPlainTextConverter {\n  def convert(html: HtmlDoc): String\n}\n"
  },
  {
    "path": "mime/shared/src/main/scala/rapture/mime/mime.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.mime\n\n/** Provides a typesafe list of MIME types, including mappings from common file extensions. This\n  * list was produced from the public domain list of MIME types at\n  * http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types w*/\nobject MimeTypes {\n\n  private var exts = Map[String, List[MimeType]]()\n  private var types = Map[String, MimeType]()\n\n  def unapply(mt: String) = types.get(mt)\n\n  /** Looks up the MIME type based on a file extension. */\n  def extension(ext: String) = exts.get(ext).getOrElse(Nil)\n\n  /** Provides a simple wrapper around a String to represent a MIME type, and the filename\n    * extensions which correspond to that type. */\n  case class MimeType(name: String, extensions: String*) {\n    override def toString = name\n    for (ext <- extensions) exts = exts.updated(ext, this :: exts.get(ext).getOrElse(Nil))\n    types = types.updated(name, this)\n  }\n\n  val `text/plain` = MimeType(\"text/plain\", \"asc\", \"conf\", \"def\", \"diff\", \"in\", \"list\", \"log\", \"pot\", \"text\", \"txt\")\n\n  val `application/x-www-form-urlencoded` = MimeType(\"application/x-www-form-urlencoded\")\n  val `application/activemessage` = MimeType(\"application/activemessage\")\n  val `application/andrew-inset` = MimeType(\"application/andrew-inset\", \"ez\")\n  val `application/applefile` = MimeType(\"application/applefile\")\n  val `application/applixware` = MimeType(\"application/applixware\", \"aw\")\n  val `application/atom+xml` = MimeType(\"application/atom+xml\", \"atom\")\n  val `application/atomcat+xml` = MimeType(\"application/atomcat+xml\", \"atomcat\")\n  val `application/atomicmail` = MimeType(\"application/atomicmail\")\n  val `application/atomsvc+xml` = MimeType(\"application/atomsvc+xml\", \"atomsvc\")\n  val `application/auth-policy+xml` = MimeType(\"application/auth-policy+xml\")\n  val `application/batch-smtp` = MimeType(\"application/batch-smtp\")\n  val `application/beep+xml` = MimeType(\"application/beep+xml\")\n  val `application/cals-1840` = MimeType(\"application/cals-1840\")\n  val `application/ccxml+xml` = MimeType(\"application/ccxml+xml\", \"ccxml\")\n  val `application/cea-2018+xml` = MimeType(\"application/cea-2018+xml\")\n  val `application/cellml+xml` = MimeType(\"application/cellml+xml\")\n  val `application/cnrp+xml` = MimeType(\"application/cnrp+xml\")\n  val `application/commonground` = MimeType(\"application/commonground\")\n  val `application/conference-info+xml` = MimeType(\"application/conference-info+xml\")\n  val `application/cpl+xml` = MimeType(\"application/cpl+xml\")\n  val `application/csta+xml` = MimeType(\"application/csta+xml\")\n  val `application/cstadata+xml` = MimeType(\"application/cstadata+xml\")\n  val `application/cu-seeme` = MimeType(\"application/cu-seeme\", \"cu\")\n  val `application/cybercash` = MimeType(\"application/cybercash\")\n  val `application/davmount+xml` = MimeType(\"application/davmount+xml\", \"davmount\")\n  val `application/dca-rft` = MimeType(\"application/dca-rft\")\n  val `application/dec-dx` = MimeType(\"application/dec-dx\")\n  val `application/dialog-info+xml` = MimeType(\"application/dialog-info+xml\")\n  val `application/dicom` = MimeType(\"application/dicom\")\n  val `application/dns` = MimeType(\"application/dns\")\n  val `application/dsptype` = MimeType(\"application/dsptype\", \"tsp\")\n  val `application/dvcs` = MimeType(\"application/dvcs\")\n  val `application/ecmascript` = MimeType(\"application/ecmascript\", \"ecma\")\n  val `application/edi-consent` = MimeType(\"application/edi-consent\")\n  val `application/edi-x12` = MimeType(\"application/edi-x12\")\n  val `application/edifact` = MimeType(\"application/edifact\")\n  val `application/emma+xml` = MimeType(\"application/emma+xml\", \"emma\")\n  val `application/epp+xml` = MimeType(\"application/epp+xml\")\n  val `application/epub+zip` = MimeType(\"application/epub+zip\", \"epub\")\n  val `application/eshop` = MimeType(\"application/eshop\")\n  val `application/example` = MimeType(\"application/example\")\n  val `application/fastinfoset` = MimeType(\"application/fastinfoset\")\n  val `application/fastsoap` = MimeType(\"application/fastsoap\")\n  val `application/fits` = MimeType(\"application/fits\")\n  val `application/font-tdpfr` = MimeType(\"application/font-tdpfr\", \"pfr\")\n  val `application/futuresplash` = MimeType(\"application/futuresplash\", \"spl\")\n  val `application/h224` = MimeType(\"application/h224\")\n  val `application/hta` = MimeType(\"application/hta\", \"hta\")\n  val `application/http` = MimeType(\"application/http\")\n  val `application/hyperstudio` = MimeType(\"application/hyperstudio\", \"stk\")\n  val `application/ibe-key-request+xml` = MimeType(\"application/ibe-key-request+xml\")\n  val `application/ibe-pkg-reply+xml` = MimeType(\"application/ibe-pkg-reply+xml\")\n  val `application/ibe-pp-data` = MimeType(\"application/ibe-pp-data\")\n  val `application/iges` = MimeType(\"application/iges\")\n  val `application/im-iscomposing+xml` = MimeType(\"application/im-iscomposing+xml\")\n  val `application/index` = MimeType(\"application/index\")\n  val `application/index.cmd` = MimeType(\"application/index.cmd\")\n  val `application/index.obj` = MimeType(\"application/index.obj\")\n  val `application/index.response` = MimeType(\"application/index.response\")\n  val `application/index.vnd` = MimeType(\"application/index.vnd\")\n  val `application/iotp` = MimeType(\"application/iotp\")\n  val `application/ipp` = MimeType(\"application/ipp\")\n  val `application/isup` = MimeType(\"application/isup\")\n  val `application/java-archive` = MimeType(\"application/java-archive\", \"jar\")\n  val `application/java-serialized-object` = MimeType(\"application/java-serialized-object\", \"ser\")\n  val `application/java-vm` = MimeType(\"application/java-vm\", \"class\")\n  val `application/javascript` = MimeType(\"application/javascript\", \"js\")\n  val `application/json` = MimeType(\"application/json\", \"json\")\n  val `application/kpml-request+xml` = MimeType(\"application/kpml-request+xml\")\n  val `application/kpml-response+xml` = MimeType(\"application/kpml-response+xml\")\n  val `application/lost+xml` = MimeType(\"application/lost+xml\", \"lostxml\")\n  val `application/mac-binhex40` = MimeType(\"application/mac-binhex40\", \"hqx\")\n  val `application/mac-compactpro` = MimeType(\"application/mac-compactpro\", \"cpt\")\n  val `application/macwriteii` = MimeType(\"application/macwriteii\")\n  val `application/marc` = MimeType(\"application/marc\", \"mrc\")\n  val `application/mathematica` = MimeType(\"application/mathematica\", \"ma\", \"mb\", \"nb\")\n  val `application/mathml+xml` = MimeType(\"application/mathml+xml\", \"mathml\")\n\n  val `application/mbms-associated-procedure-description+xml` = MimeType(\n      \"application/mbms-associated-procedure-description+xml\")\n\n  val `application/mbms-deregister+xml` = MimeType(\"application/mbms-deregister+xml\")\n  val `application/mbms-envelope+xml` = MimeType(\"application/mbms-envelope+xml\")\n  val `application/mbms-msk+xml` = MimeType(\"application/mbms-msk+xml\")\n  val `application/mbms-msk-response+xml` = MimeType(\"application/mbms-msk-response+xml\")\n  val `application/mbms-protection-description+xml` = MimeType(\"application/mbms-protection-description+xml\")\n  val `application/mbms-reception-report+xml` = MimeType(\"application/mbms-reception-report+xml\")\n  val `application/mbms-register+xml` = MimeType(\"application/mbms-register+xml\")\n  val `application/mbms-register-response+xml` = MimeType(\"application/mbms-register-response+xml\")\n  val `application/mbms-user-service-description+xml` = MimeType(\"application/mbms-user-service-description+xml\")\n  val `application/mbox` = MimeType(\"application/mbox\", \"mbox\")\n  val `application/media_control+xml` = MimeType(\"application/media_control+xml\")\n  val `application/mediaservercontrol+xml` = MimeType(\"application/mediaservercontrol+xml\", \"mscml\")\n  val `application/mikey` = MimeType(\"application/mikey\")\n  val `application/moss-keys` = MimeType(\"application/moss-keys\")\n  val `application/moss-signature` = MimeType(\"application/moss-signature\")\n  val `application/mosskey-data` = MimeType(\"application/mosskey-data\")\n  val `application/mosskey-request` = MimeType(\"application/mosskey-request\")\n  val `application/mp4` = MimeType(\"application/mp4\", \"mp4s\")\n  val `application/mpeg4-generic` = MimeType(\"application/mpeg4-generic\")\n  val `application/mpeg4-iod` = MimeType(\"application/mpeg4-iod\")\n  val `application/mpeg4-iod-xmt` = MimeType(\"application/mpeg4-iod-xmt\")\n  val `application/msaccess` = MimeType(\"application/msaccess\", \"mdb\")\n  val `application/msword` = MimeType(\"application/msword\", \"doc\", \"dot\")\n  val `application/mxf` = MimeType(\"application/mxf\", \"mxf\")\n  val `application/nasdata` = MimeType(\"application/nasdata\")\n  val `application/news-checkgroups` = MimeType(\"application/news-checkgroups\")\n  val `application/news-groupinfo` = MimeType(\"application/news-groupinfo\")\n  val `application/news-transmission` = MimeType(\"application/news-transmission\")\n  val `application/nss` = MimeType(\"application/nss\")\n  val `application/ocsp-request` = MimeType(\"application/ocsp-request\")\n  val `application/ocsp-response` = MimeType(\"application/ocsp-response\")\n\n  val `application/octet-stream` = MimeType(\"application/octet-stream\",\n                                            \"bin\",\n                                            \"bpk\",\n                                            \"deploy\",\n                                            \"dist\",\n                                            \"distz\",\n                                            \"dmg\",\n                                            \"dms\",\n                                            \"dump\",\n                                            \"elc\",\n                                            \"iso\",\n                                            \"lha\",\n                                            \"lrf\",\n                                            \"lzh\",\n                                            \"pkg\",\n                                            \"so\")\n\n  val `application/oda` = MimeType(\"application/oda\", \"oda\")\n  val `application/oebps-package+xml` = MimeType(\"application/oebps-package+xml\", \"opf\")\n  val `application/ogg` = MimeType(\"application/ogg\", \"ogg\", \"ogx\")\n  val `application/onenote` = MimeType(\"application/onenote\", \"onepkg\", \"onetmp\", \"onetoc\", \"onetoc2\")\n  val `application/parityfec` = MimeType(\"application/parityfec\")\n  val `application/patch-ops-error+xml` = MimeType(\"application/patch-ops-error+xml\", \"xer\")\n  val `application/pdf` = MimeType(\"application/pdf\", \"pdf\")\n  val `application/pgp-encrypted` = MimeType(\"application/pgp-encrypted\", \"pgp\")\n  val `application/pgp-keys` = MimeType(\"application/pgp-keys\", \"key\")\n  val `application/pgp-signature` = MimeType(\"application/pgp-signature\", \"asc\", \"pgp\", \"sig\")\n  val `application/pics-rules` = MimeType(\"application/pics-rules\", \"prf\")\n  val `application/pidf+xml` = MimeType(\"application/pidf+xml\")\n  val `application/pidf-diff+xml` = MimeType(\"application/pidf-diff+xml\")\n  val `application/pkcs10` = MimeType(\"application/pkcs10\", \"p10\")\n  val `application/pkcs7-mime` = MimeType(\"application/pkcs7-mime\", \"p7c\", \"p7m\")\n  val `application/pkcs7-signature` = MimeType(\"application/pkcs7-signature\", \"p7s\")\n  val `application/pkix-cert` = MimeType(\"application/pkix-cert\", \"cer\")\n  val `application/pkix-crl` = MimeType(\"application/pkix-crl\", \"crl\")\n  val `application/pkix-pkipath` = MimeType(\"application/pkix-pkipath\", \"pkipath\")\n  val `application/pkixcmp` = MimeType(\"application/pkixcmp\", \"pki\")\n  val `application/pls+xml` = MimeType(\"application/pls+xml\", \"pls\")\n  val `application/poc-settings+xml` = MimeType(\"application/poc-settings+xml\")\n  val `application/postscript` = MimeType(\"application/postscript\", \"ai\", \"eps\", \"ps\")\n  val `application/prs.alvestrand.titrax-sheet` = MimeType(\"application/prs.alvestrand.titrax-sheet\")\n  val `application/prs.cww` = MimeType(\"application/prs.cww\", \"cww\")\n  val `application/prs.nprend` = MimeType(\"application/prs.nprend\")\n  val `application/prs.plucker` = MimeType(\"application/prs.plucker\")\n  val `application/qsig` = MimeType(\"application/qsig\")\n  val `application/rar` = MimeType(\"application/rar\", \"rar\")\n  val `application/rdf+xml` = MimeType(\"application/rdf+xml\", \"rdf\")\n  val `application/reginfo+xml` = MimeType(\"application/reginfo+xml\", \"rif\")\n  val `application/relax-ng-compact-syntax` = MimeType(\"application/relax-ng-compact-syntax\", \"rnc\")\n  val `application/remote-printing` = MimeType(\"application/remote-printing\")\n  val `application/resource-lists+xml` = MimeType(\"application/resource-lists+xml\", \"rl\")\n  val `application/resource-lists-diff+xml` = MimeType(\"application/resource-lists-diff+xml\", \"rld\")\n  val `application/riscos` = MimeType(\"application/riscos\")\n  val `application/rlmi+xml` = MimeType(\"application/rlmi+xml\")\n  val `application/rls-services+xml` = MimeType(\"application/rls-services+xml\", \"rs\")\n  val `application/rsd+xml` = MimeType(\"application/rsd+xml\", \"rsd\")\n  val `application/rss+xml` = MimeType(\"application/rss+xml\", \"rss\")\n  val `application/rtf` = MimeType(\"application/rtf\", \"rtf\")\n  val `application/rtx` = MimeType(\"application/rtx\")\n  val `application/samlassertion+xml` = MimeType(\"application/samlassertion+xml\")\n  val `application/samlmetadata+xml` = MimeType(\"application/samlmetadata+xml\")\n  val `application/sbml+xml` = MimeType(\"application/sbml+xml\", \"sbml\")\n  val `application/scvp-cv-request` = MimeType(\"application/scvp-cv-request\", \"scq\")\n  val `application/scvp-cv-response` = MimeType(\"application/scvp-cv-response\", \"scs\")\n  val `application/scvp-vp-request` = MimeType(\"application/scvp-vp-request\", \"spq\")\n  val `application/scvp-vp-response` = MimeType(\"application/scvp-vp-response\", \"spp\")\n  val `application/sdp` = MimeType(\"application/sdp\", \"sdp\")\n  val `application/set-payment` = MimeType(\"application/set-payment\")\n  val `application/set-payment-initiation` = MimeType(\"application/set-payment-initiation\", \"setpay\")\n  val `application/set-registration` = MimeType(\"application/set-registration\")\n  val `application/set-registration-initiation` = MimeType(\"application/set-registration-initiation\", \"setreg\")\n  val `application/sgml` = MimeType(\"application/sgml\")\n  val `application/sgml-open-catalog` = MimeType(\"application/sgml-open-catalog\")\n  val `application/shf+xml` = MimeType(\"application/shf+xml\", \"shf\")\n  val `application/sieve` = MimeType(\"application/sieve\")\n  val `application/simple-filter+xml` = MimeType(\"application/simple-filter+xml\")\n  val `application/simple-message-summary` = MimeType(\"application/simple-message-summary\")\n  val `application/simplesymbolcontainer` = MimeType(\"application/simplesymbolcontainer\")\n  val `application/slate` = MimeType(\"application/slate\")\n  val `application/smil` = MimeType(\"application/smil\", \"smi\", \"smil\")\n  val `application/smil+xml` = MimeType(\"application/smil+xml\", \"smi\", \"smil\")\n  val `application/soap+fastinfoset` = MimeType(\"application/soap+fastinfoset\")\n  val `application/soap+xml` = MimeType(\"application/soap+xml\")\n  val `application/sparql-query` = MimeType(\"application/sparql-query\", \"rq\")\n  val `application/sparql-results+xml` = MimeType(\"application/sparql-results+xml\", \"srx\")\n  val `application/spirits-event+xml` = MimeType(\"application/spirits-event+xml\")\n  val `application/srgs` = MimeType(\"application/srgs\", \"gram\")\n  val `application/srgs+xml` = MimeType(\"application/srgs+xml\", \"grxml\")\n  val `application/ssml+xml` = MimeType(\"application/ssml+xml\", \"ssml\")\n  val `application/timestamp-query` = MimeType(\"application/timestamp-query\")\n  val `application/timestamp-reply` = MimeType(\"application/timestamp-reply\")\n  val `application/tve-trigger` = MimeType(\"application/tve-trigger\")\n  val `application/ulpfec` = MimeType(\"application/ulpfec\")\n  val `application/vemmi` = MimeType(\"application/vemmi\")\n  val `application/vividence.scriptfile` = MimeType(\"application/vividence.scriptfile\")\n  val `application/vnd.3gpp.bsf+xml` = MimeType(\"application/vnd.3gpp.bsf+xml\")\n  val `application/vnd.3gpp.pic-bw-large` = MimeType(\"application/vnd.3gpp.pic-bw-large\", \"plb\")\n  val `application/vnd.3gpp.pic-bw-small` = MimeType(\"application/vnd.3gpp.pic-bw-small\", \"psb\")\n  val `application/vnd.3gpp.pic-bw-var` = MimeType(\"application/vnd.3gpp.pic-bw-var\", \"pvb\")\n  val `application/vnd.3gpp.sms` = MimeType(\"application/vnd.3gpp.sms\")\n  val `application/vnd.3gpp2.bcmcsinfo+xml` = MimeType(\"application/vnd.3gpp2.bcmcsinfo+xml\")\n  val `application/vnd.3gpp2.sms` = MimeType(\"application/vnd.3gpp2.sms\")\n  val `application/vnd.3gpp2.tcap` = MimeType(\"application/vnd.3gpp2.tcap\", \"tcap\")\n  val `application/vnd.3m.post-it-notes` = MimeType(\"application/vnd.3m.post-it-notes\", \"pwn\")\n  val `application/vnd.accpac.simply.aso` = MimeType(\"application/vnd.accpac.simply.aso\", \"aso\")\n  val `application/vnd.accpac.simply.imp` = MimeType(\"application/vnd.accpac.simply.imp\", \"imp\")\n  val `application/vnd.acucobol` = MimeType(\"application/vnd.acucobol\", \"acu\")\n  val `application/vnd.acucorp` = MimeType(\"application/vnd.acucorp\", \"acutc\", \"atc\")\n\n  val `application/vnd.adobe.air-application-installer-package+zip` =\n    MimeType(\"application/vnd.adobe.air-application-installer-package+zip\", \"air\")\n\n  val `application/vnd.adobe.xdp+xml` = MimeType(\"application/vnd.adobe.xdp+xml\", \"xdp\")\n  val `application/vnd.adobe.xfdf` = MimeType(\"application/vnd.adobe.xfdf\", \"xfdf\")\n  val `application/vnd.aether.imp` = MimeType(\"application/vnd.aether.imp\")\n  val `application/vnd.airzip.filesecure.azf` = MimeType(\"application/vnd.airzip.filesecure.azf\", \"azf\")\n  val `application/vnd.airzip.filesecure.azs` = MimeType(\"application/vnd.airzip.filesecure.azs\", \"azs\")\n  val `application/vnd.amazon.ebook` = MimeType(\"application/vnd.amazon.ebook\", \"azw\")\n  val `application/vnd.americandynamics.acc` = MimeType(\"application/vnd.americandynamics.acc\", \"acc\")\n  val `application/vnd.amiga.ami` = MimeType(\"application/vnd.amiga.ami\", \"ami\")\n  val `application/vnd.android.package-archive` = MimeType(\"application/vnd.android.package-archive\", \"apk\")\n\n  val `application/vnd.anser-web-certificate-issue-initiation` =\n    MimeType(\"application/vnd.anser-web-certificate-issue-initiation\", \"cii\")\n\n  val `application/vnd.anser-web-funds-transfer-initiation` =\n    MimeType(\"application/vnd.anser-web-funds-transfer-initiation\", \"fti\")\n\n  val `application/vnd.antix.game-component` = MimeType(\"application/vnd.antix.game-component\", \"atx\")\n  val `application/vnd.apple.installer+xml` = MimeType(\"application/vnd.apple.installer+xml\", \"mpkg\")\n  val `application/vnd.arastra.swi` = MimeType(\"application/vnd.arastra.swi\", \"swi\")\n  val `application/vnd.audiograph` = MimeType(\"application/vnd.audiograph\", \"aep\")\n  val `application/vnd.autopackage` = MimeType(\"application/vnd.autopackage\")\n  val `application/vnd.avistar+xml` = MimeType(\"application/vnd.avistar+xml\")\n  val `application/vnd.blueice.multipass` = MimeType(\"application/vnd.blueice.multipass\", \"mpm\")\n  val `application/vnd.bluetooth.ep.oob` = MimeType(\"application/vnd.bluetooth.ep.oob\")\n  val `application/vnd.bmi` = MimeType(\"application/vnd.bmi\", \"bmi\")\n  val `application/vnd.businessobjects` = MimeType(\"application/vnd.businessobjects\", \"rep\")\n  val `application/vnd.cab-jscript` = MimeType(\"application/vnd.cab-jscript\")\n  val `application/vnd.canon-cpdl` = MimeType(\"application/vnd.canon-cpdl\")\n  val `application/vnd.canon-lips` = MimeType(\"application/vnd.canon-lips\")\n  val `application/vnd.cendio.thinlinc.clientconf` = MimeType(\"application/vnd.cendio.thinlinc.clientconf\")\n  val `application/vnd.chemdraw+xml` = MimeType(\"application/vnd.chemdraw+xml\", \"cdxml\")\n  val `application/vnd.chipnuts.karaoke-mmd` = MimeType(\"application/vnd.chipnuts.karaoke-mmd\", \"mmd\")\n  val `application/vnd.cinderella` = MimeType(\"application/vnd.cinderella\", \"cdy\")\n  val `application/vnd.cirpack.isdn-ext` = MimeType(\"application/vnd.cirpack.isdn-ext\")\n  val `application/vnd.claymore` = MimeType(\"application/vnd.claymore\", \"cla\")\n  val `application/vnd.clonk.c4group` = MimeType(\"application/vnd.clonk.c4group\", \"c4d\", \"c4f\", \"c4g\", \"c4p\", \"c4u\")\n  val `application/vnd.commerce-battelle` = MimeType(\"application/vnd.commerce-battelle\")\n  val `application/vnd.commonspace` = MimeType(\"application/vnd.commonspace\", \"csp\")\n  val `application/vnd.contact.cmsg` = MimeType(\"application/vnd.contact.cmsg\", \"cdbcmsg\")\n  val `application/vnd.cosmocaller` = MimeType(\"application/vnd.cosmocaller\", \"cmc\")\n  val `application/vnd.crick.clicker` = MimeType(\"application/vnd.crick.clicker\", \"clkx\")\n  val `application/vnd.crick.clicker.keyboard` = MimeType(\"application/vnd.crick.clicker.keyboard\", \"clkk\")\n  val `application/vnd.crick.clicker.palette` = MimeType(\"application/vnd.crick.clicker.palette\", \"clkp\")\n  val `application/vnd.crick.clicker.template` = MimeType(\"application/vnd.crick.clicker.template\", \"clkt\")\n  val `application/vnd.crick.clicker.wordbank` = MimeType(\"application/vnd.crick.clicker.wordbank\", \"clkw\")\n  val `application/vnd.criticaltools.wbs+xml` = MimeType(\"application/vnd.criticaltools.wbs+xml\", \"wbs\")\n  val `application/vnd.ctc-posml` = MimeType(\"application/vnd.ctc-posml\", \"pml\")\n  val `application/vnd.ctct.ws+xml` = MimeType(\"application/vnd.ctct.ws+xml\")\n  val `application/vnd.cups-pdf` = MimeType(\"application/vnd.cups-pdf\")\n  val `application/vnd.cups-postscript` = MimeType(\"application/vnd.cups-postscript\")\n  val `application/vnd.cups-ppd` = MimeType(\"application/vnd.cups-ppd\", \"ppd\")\n  val `application/vnd.cups-raster` = MimeType(\"application/vnd.cups-raster\")\n  val `application/vnd.cups-raw` = MimeType(\"application/vnd.cups-raw\")\n  val `application/vnd.curl.car` = MimeType(\"application/vnd.curl.car\", \"car\")\n  val `application/vnd.curl.pcurl` = MimeType(\"application/vnd.curl.pcurl\", \"pcurl\")\n  val `application/vnd.cybank` = MimeType(\"application/vnd.cybank\")\n  val `application/vnd.data-vision.rdz` = MimeType(\"application/vnd.data-vision.rdz\", \"rdz\")\n  val `application/vnd.denovo.fcselayout-link` = MimeType(\"application/vnd.denovo.fcselayout-link\", \"fe\", \"_launch\")\n  val `application/vnd.dir-bi.plate-dl-nosuffix` = MimeType(\"application/vnd.dir-bi.plate-dl-nosuffix\")\n  val `application/vnd.dna` = MimeType(\"application/vnd.dna\", \"dna\")\n  val `application/vnd.dolby.mlp` = MimeType(\"application/vnd.dolby.mlp\", \"mlp\")\n  val `application/vnd.dolby.mobile.1` = MimeType(\"application/vnd.dolby.mobile.1\")\n  val `application/vnd.dolby.mobile.2` = MimeType(\"application/vnd.dolby.mobile.2\")\n  val `application/vnd.dpgraph` = MimeType(\"application/vnd.dpgraph\", \"dpg\")\n  val `application/vnd.dreamfactory` = MimeType(\"application/vnd.dreamfactory\", \"dfac\")\n  val `application/vnd.dvb.esgcontainer` = MimeType(\"application/vnd.dvb.esgcontainer\")\n  val `application/vnd.dvb.ipdcdftnotifaccess` = MimeType(\"application/vnd.dvb.ipdcdftnotifaccess\")\n  val `application/vnd.dvb.ipdcesgaccess` = MimeType(\"application/vnd.dvb.ipdcesgaccess\")\n  val `application/vnd.dvb.ipdcroaming` = MimeType(\"application/vnd.dvb.ipdcroaming\")\n  val `application/vnd.dvb.iptv.alfec-base` = MimeType(\"application/vnd.dvb.iptv.alfec-base\")\n  val `application/vnd.dvb.iptv.alfec-enhancement` = MimeType(\"application/vnd.dvb.iptv.alfec-enhancement\")\n  val `application/vnd.dvb.notif-aggregate-root+xml` = MimeType(\"application/vnd.dvb.notif-aggregate-root+xml\")\n  val `application/vnd.dvb.notif-container+xml` = MimeType(\"application/vnd.dvb.notif-container+xml\")\n  val `application/vnd.dvb.notif-generic+xml` = MimeType(\"application/vnd.dvb.notif-generic+xml\")\n  val `application/vnd.dvb.notif-ia-msglist+xml` = MimeType(\"application/vnd.dvb.notif-ia-msglist+xml\")\n\n  val `application/vnd.dvb.notif-ia-registration-request+xml` = MimeType(\n      \"application/vnd.dvb.notif-ia-registration-request+xml\")\n\n  val `application/vnd.dvb.notif-ia-registration-response+xml` = MimeType(\n      \"application/vnd.dvb.notif-ia-registration-response+xml\")\n\n  val `application/vnd.dvb.notif-init+xml` = MimeType(\"application/vnd.dvb.notif-init+xml\")\n  val `application/vnd.dxr` = MimeType(\"application/vnd.dxr\")\n  val `application/vnd.dynageo` = MimeType(\"application/vnd.dynageo\", \"geo\")\n  val `application/vnd.ecdis-update` = MimeType(\"application/vnd.ecdis-update\")\n  val `application/vnd.ecowin.chart` = MimeType(\"application/vnd.ecowin.chart\", \"mag\")\n  val `application/vnd.ecowin.filerequest` = MimeType(\"application/vnd.ecowin.filerequest\")\n  val `application/vnd.ecowin.fileupdate` = MimeType(\"application/vnd.ecowin.fileupdate\")\n  val `application/vnd.ecowin.series` = MimeType(\"application/vnd.ecowin.series\")\n  val `application/vnd.ecowin.seriesrequest` = MimeType(\"application/vnd.ecowin.seriesrequest\")\n  val `application/vnd.ecowin.seriesupdate` = MimeType(\"application/vnd.ecowin.seriesupdate\")\n  val `application/vnd.emclient.accessrequest+xml` = MimeType(\"application/vnd.emclient.accessrequest+xml\")\n  val `application/vnd.enliven` = MimeType(\"application/vnd.enliven\", \"nml\")\n  val `application/vnd.epson.esf` = MimeType(\"application/vnd.epson.esf\", \"esf\")\n  val `application/vnd.epson.msf` = MimeType(\"application/vnd.epson.msf\", \"msf\")\n  val `application/vnd.epson.quickanime` = MimeType(\"application/vnd.epson.quickanime\", \"qam\")\n  val `application/vnd.epson.salt` = MimeType(\"application/vnd.epson.salt\", \"slt\")\n  val `application/vnd.epson.ssf` = MimeType(\"application/vnd.epson.ssf\", \"ssf\")\n  val `application/vnd.ericsson.quickcall` = MimeType(\"application/vnd.ericsson.quickcall\")\n  val `application/vnd.eszigno3+xml` = MimeType(\"application/vnd.eszigno3+xml\", \"es3\", \"et3\")\n  val `application/vnd.etsi.aoc+xml` = MimeType(\"application/vnd.etsi.aoc+xml\")\n  val `application/vnd.etsi.cug+xml` = MimeType(\"application/vnd.etsi.cug+xml\")\n  val `application/vnd.etsi.iptvcommand+xml` = MimeType(\"application/vnd.etsi.iptvcommand+xml\")\n  val `application/vnd.etsi.iptvdiscovery+xml` = MimeType(\"application/vnd.etsi.iptvdiscovery+xml\")\n  val `application/vnd.etsi.iptvprofile+xml` = MimeType(\"application/vnd.etsi.iptvprofile+xml\")\n  val `application/vnd.etsi.iptvsad-bc+xml` = MimeType(\"application/vnd.etsi.iptvsad-bc+xml\")\n  val `application/vnd.etsi.iptvsad-cod+xml` = MimeType(\"application/vnd.etsi.iptvsad-cod+xml\")\n  val `application/vnd.etsi.iptvsad-npvr+xml` = MimeType(\"application/vnd.etsi.iptvsad-npvr+xml\")\n  val `application/vnd.etsi.iptvueprofile+xml` = MimeType(\"application/vnd.etsi.iptvueprofile+xml\")\n  val `application/vnd.etsi.mcid+xml` = MimeType(\"application/vnd.etsi.mcid+xml\")\n  val `application/vnd.etsi.sci+xml` = MimeType(\"application/vnd.etsi.sci+xml\")\n  val `application/vnd.etsi.simservs+xml` = MimeType(\"application/vnd.etsi.simservs+xml\")\n  val `application/vnd.eudora.data` = MimeType(\"application/vnd.eudora.data\")\n  val `application/vnd.ezpix-album` = MimeType(\"application/vnd.ezpix-album\", \"ez2\")\n  val `application/vnd.ezpix-package` = MimeType(\"application/vnd.ezpix-package\", \"ez3\")\n  val `application/vnd.f-secure.mobile` = MimeType(\"application/vnd.f-secure.mobile\")\n  val `application/vnd.fdf` = MimeType(\"application/vnd.fdf\", \"fdf\")\n  val `application/vnd.fdsn.mseed` = MimeType(\"application/vnd.fdsn.mseed\", \"mseed\")\n  val `application/vnd.fdsn.seed` = MimeType(\"application/vnd.fdsn.seed\", \"dataless\", \"seed\")\n  val `application/vnd.ffsns` = MimeType(\"application/vnd.ffsns\")\n  val `application/vnd.fints` = MimeType(\"application/vnd.fints\")\n  val `application/vnd.flographit` = MimeType(\"application/vnd.flographit\", \"gph\")\n  val `application/vnd.fluxtime.clip` = MimeType(\"application/vnd.fluxtime.clip\", \"ftc\")\n  val `application/vnd.font-fontforge-sfd` = MimeType(\"application/vnd.font-fontforge-sfd\")\n  val `application/vnd.framemaker` = MimeType(\"application/vnd.framemaker\", \"book\", \"fm\", \"frame\", \"maker\")\n  val `application/vnd.frogans.fnc` = MimeType(\"application/vnd.frogans.fnc\", \"fnc\")\n  val `application/vnd.frogans.ltf` = MimeType(\"application/vnd.frogans.ltf\", \"ltf\")\n  val `application/vnd.fsc.weblaunch` = MimeType(\"application/vnd.fsc.weblaunch\", \"fsc\")\n  val `application/vnd.fujitsu.oasys` = MimeType(\"application/vnd.fujitsu.oasys\", \"oas\")\n  val `application/vnd.fujitsu.oasys2` = MimeType(\"application/vnd.fujitsu.oasys2\", \"oa2\")\n  val `application/vnd.fujitsu.oasys3` = MimeType(\"application/vnd.fujitsu.oasys3\", \"oa3\")\n  val `application/vnd.fujitsu.oasysgp` = MimeType(\"application/vnd.fujitsu.oasysgp\", \"fg5\")\n  val `application/vnd.fujitsu.oasysprs` = MimeType(\"application/vnd.fujitsu.oasysprs\", \"bh2\")\n  val `application/vnd.fujixerox.art-ex` = MimeType(\"application/vnd.fujixerox.art-ex\")\n  val `application/vnd.fujixerox.art4` = MimeType(\"application/vnd.fujixerox.art4\")\n  val `application/vnd.fujixerox.ddd` = MimeType(\"application/vnd.fujixerox.ddd\", \"ddd\")\n  val `application/vnd.fujixerox.docuworks` = MimeType(\"application/vnd.fujixerox.docuworks\", \"xdw\")\n  val `application/vnd.fujixerox.docuworks.binder` = MimeType(\"application/vnd.fujixerox.docuworks.binder\", \"xbd\")\n  val `application/vnd.fujixerox.hbpl` = MimeType(\"application/vnd.fujixerox.hbpl\")\n  val `application/vnd.fut-misnet` = MimeType(\"application/vnd.fut-misnet\")\n  val `application/vnd.fuzzysheet` = MimeType(\"application/vnd.fuzzysheet\", \"fzs\")\n  val `application/vnd.genomatix.tuxedo` = MimeType(\"application/vnd.genomatix.tuxedo\", \"txd\")\n  val `application/vnd.geogebra.file` = MimeType(\"application/vnd.geogebra.file\", \"ggb\")\n  val `application/vnd.geogebra.tool` = MimeType(\"application/vnd.geogebra.tool\", \"ggt\")\n  val `application/vnd.geometry-explorer` = MimeType(\"application/vnd.geometry-explorer\", \"gex\", \"gre\")\n  val `application/vnd.gmx` = MimeType(\"application/vnd.gmx\", \"gmx\")\n  val `application/vnd.google-earth.kml+xml` = MimeType(\"application/vnd.google-earth.kml+xml\", \"kml\")\n  val `application/vnd.google-earth.kmz` = MimeType(\"application/vnd.google-earth.kmz\", \"kmz\")\n  val `application/vnd.grafeq` = MimeType(\"application/vnd.grafeq\", \"gqf\", \"gqs\")\n  val `application/vnd.gridmp` = MimeType(\"application/vnd.gridmp\")\n  val `application/vnd.groove-account` = MimeType(\"application/vnd.groove-account\", \"gac\")\n  val `application/vnd.groove-help` = MimeType(\"application/vnd.groove-help\", \"ghf\")\n  val `application/vnd.groove-identity-message` = MimeType(\"application/vnd.groove-identity-message\", \"gim\")\n  val `application/vnd.groove-injector` = MimeType(\"application/vnd.groove-injector\", \"grv\")\n  val `application/vnd.groove-tool-message` = MimeType(\"application/vnd.groove-tool-message\", \"gtm\")\n  val `application/vnd.groove-tool-template` = MimeType(\"application/vnd.groove-tool-template\", \"tpl\")\n  val `application/vnd.groove-vcard` = MimeType(\"application/vnd.groove-vcard\", \"vcg\")\n  val `application/vnd.handheld-entertainment+xml` = MimeType(\"application/vnd.handheld-entertainment+xml\", \"zmm\")\n  val `application/vnd.hbci` = MimeType(\"application/vnd.hbci\", \"hbci\")\n  val `application/vnd.hcl-bireports` = MimeType(\"application/vnd.hcl-bireports\")\n  val `application/vnd.hhe.lesson-player` = MimeType(\"application/vnd.hhe.lesson-player\", \"les\")\n  val `application/vnd.hp-hpgl` = MimeType(\"application/vnd.hp-hpgl\", \"hpgl\")\n  val `application/vnd.hp-hpid` = MimeType(\"application/vnd.hp-hpid\", \"hpid\")\n  val `application/vnd.hp-hps` = MimeType(\"application/vnd.hp-hps\", \"hps\")\n  val `application/vnd.hp-jlyt` = MimeType(\"application/vnd.hp-jlyt\", \"jlt\")\n  val `application/vnd.hp-pcl` = MimeType(\"application/vnd.hp-pcl\", \"pcl\")\n  val `application/vnd.hp-pclxl` = MimeType(\"application/vnd.hp-pclxl\", \"pclxl\")\n  val `application/vnd.httphone` = MimeType(\"application/vnd.httphone\")\n  val `application/vnd.hydrostatix.sof-data` = MimeType(\"application/vnd.hydrostatix.sof-data\", \"sfd\", \"-hdstx\")\n  val `application/vnd.hzn-3d-crossword` = MimeType(\"application/vnd.hzn-3d-crossword\", \"x3d\")\n  val `application/vnd.ibm.afplinedata` = MimeType(\"application/vnd.ibm.afplinedata\")\n  val `application/vnd.ibm.electronic-media` = MimeType(\"application/vnd.ibm.electronic-media\")\n  val `application/vnd.ibm.minipay` = MimeType(\"application/vnd.ibm.minipay\", \"mpy\")\n  val `application/vnd.ibm.modcap` = MimeType(\"application/vnd.ibm.modcap\", \"afp\", \"list3820\", \"listafp\")\n  val `application/vnd.ibm.rights-management` = MimeType(\"application/vnd.ibm.rights-management\", \"irm\")\n  val `application/vnd.ibm.secure-container` = MimeType(\"application/vnd.ibm.secure-container\", \"sc\")\n  val `application/vnd.iccprofile` = MimeType(\"application/vnd.iccprofile\", \"icc\", \"icm\")\n  val `application/vnd.igloader` = MimeType(\"application/vnd.igloader\", \"igl\")\n  val `application/vnd.immervision-ivp` = MimeType(\"application/vnd.immervision-ivp\", \"ivp\")\n  val `application/vnd.immervision-ivu` = MimeType(\"application/vnd.immervision-ivu\", \"ivu\")\n  val `application/vnd.informedcontrol.rms+xml` = MimeType(\"application/vnd.informedcontrol.rms+xml\")\n  val `application/vnd.informix-visionary` = MimeType(\"application/vnd.informix-visionary\")\n  val `application/vnd.intercon.formnet` = MimeType(\"application/vnd.intercon.formnet\", \"xpw\", \"xpx\")\n  val `application/vnd.intertrust.digibox` = MimeType(\"application/vnd.intertrust.digibox\")\n  val `application/vnd.intertrust.nncp` = MimeType(\"application/vnd.intertrust.nncp\")\n  val `application/vnd.intu.qbo` = MimeType(\"application/vnd.intu.qbo\", \"qbo\")\n  val `application/vnd.intu.qfx` = MimeType(\"application/vnd.intu.qfx\", \"qfx\")\n  val `application/vnd.iptc.g2.conceptitem+xml` = MimeType(\"application/vnd.iptc.g2.conceptitem+xml\")\n  val `application/vnd.iptc.g2.knowledgeitem+xml` = MimeType(\"application/vnd.iptc.g2.knowledgeitem+xml\")\n  val `application/vnd.iptc.g2.newsitem+xml` = MimeType(\"application/vnd.iptc.g2.newsitem+xml\")\n  val `application/vnd.iptc.g2.packageitem+xml` = MimeType(\"application/vnd.iptc.g2.packageitem+xml\")\n  val `application/vnd.ipunplugged.rcprofile` = MimeType(\"application/vnd.ipunplugged.rcprofile\", \"rcprofile\")\n  val `application/vnd.irepository.package+xml` = MimeType(\"application/vnd.irepository.package+xml\", \"irp\")\n  val `application/vnd.is-xpr` = MimeType(\"application/vnd.is-xpr\", \"xpr\")\n  val `application/vnd.jam` = MimeType(\"application/vnd.jam\", \"jam\")\n  val `application/vnd.japannet-directory-service` = MimeType(\"application/vnd.japannet-directory-service\")\n  val `application/vnd.japannet-jpnstore-wakeup` = MimeType(\"application/vnd.japannet-jpnstore-wakeup\")\n  val `application/vnd.japannet-payment-wakeup` = MimeType(\"application/vnd.japannet-payment-wakeup\")\n  val `application/vnd.japannet-registration` = MimeType(\"application/vnd.japannet-registration\")\n  val `application/vnd.japannet-registration-wakeup` = MimeType(\"application/vnd.japannet-registration-wakeup\")\n  val `application/vnd.japannet-setstore-wakeup` = MimeType(\"application/vnd.japannet-setstore-wakeup\")\n  val `application/vnd.japannet-verification` = MimeType(\"application/vnd.japannet-verification\")\n  val `application/vnd.japannet-verification-wakeup` = MimeType(\"application/vnd.japannet-verification-wakeup\")\n  val `application/vnd.jcp.javame.midlet-rms` = MimeType(\"application/vnd.jcp.javame.midlet-rms\", \"rms\")\n  val `application/vnd.jisp` = MimeType(\"application/vnd.jisp\", \"jisp\")\n  val `application/vnd.joost.joda-archive` = MimeType(\"application/vnd.joost.joda-archive\", \"joda\")\n  val `application/vnd.kahootz` = MimeType(\"application/vnd.kahootz\", \"ktr\", \"ktz\")\n  val `application/vnd.kde.karbon` = MimeType(\"application/vnd.kde.karbon\", \"karbon\")\n  val `application/vnd.kde.kchart` = MimeType(\"application/vnd.kde.kchart\", \"chrt\")\n  val `application/vnd.kde.kformula` = MimeType(\"application/vnd.kde.kformula\", \"kfo\")\n  val `application/vnd.kde.kivio` = MimeType(\"application/vnd.kde.kivio\", \"flw\")\n  val `application/vnd.kde.kontour` = MimeType(\"application/vnd.kde.kontour\", \"kon\")\n  val `application/vnd.kde.kpresenter` = MimeType(\"application/vnd.kde.kpresenter\", \"kpr\", \"kpt\")\n  val `application/vnd.kde.kspread` = MimeType(\"application/vnd.kde.kspread\", \"ksp\")\n  val `application/vnd.kde.kword` = MimeType(\"application/vnd.kde.kword\", \"kwd\", \"kwt\")\n  val `application/vnd.kenameaapp` = MimeType(\"application/vnd.kenameaapp\", \"htke\")\n  val `application/vnd.kidspiration` = MimeType(\"application/vnd.kidspiration\", \"kia\")\n  val `application/vnd.kinar` = MimeType(\"application/vnd.kinar\", \"kne\", \"knp\")\n  val `application/vnd.koan` = MimeType(\"application/vnd.koan\", \"skd\", \"skm\", \"skp\", \"skt\")\n  val `application/vnd.kodak-descriptor` = MimeType(\"application/vnd.kodak-descriptor\", \"sse\")\n  val `application/vnd.liberty-request+xml` = MimeType(\"application/vnd.liberty-request+xml\")\n\n  val `application/vnd.llamagraphics.life-balance.desktop` =\n    MimeType(\"application/vnd.llamagraphics.life-balance.desktop\", \"lbd\")\n\n  val `application/vnd.llamagraphics.life-balance.exchange+xml` =\n    MimeType(\"application/vnd.llamagraphics.life-balance.exchange+xml\", \"lbe\")\n\n  val `application/vnd.lotus-1-2-3` = MimeType(\"application/vnd.lotus-1-2-3\", \"123\")\n  val `application/vnd.lotus-approach` = MimeType(\"application/vnd.lotus-approach\", \"apr\")\n  val `application/vnd.lotus-freelance` = MimeType(\"application/vnd.lotus-freelance\", \"pre\")\n  val `application/vnd.lotus-notes` = MimeType(\"application/vnd.lotus-notes\", \"nsf\")\n  val `application/vnd.lotus-organizer` = MimeType(\"application/vnd.lotus-organizer\", \"org\")\n  val `application/vnd.lotus-screencam` = MimeType(\"application/vnd.lotus-screencam\", \"scm\")\n  val `application/vnd.lotus-wordpro` = MimeType(\"application/vnd.lotus-wordpro\", \"lwp\")\n  val `application/vnd.macports.portpkg` = MimeType(\"application/vnd.macports.portpkg\", \"portpkg\")\n  val `application/vnd.marlin.drm.actiontoken+xml` = MimeType(\"application/vnd.marlin.drm.actiontoken+xml\")\n  val `application/vnd.marlin.drm.conftoken+xml` = MimeType(\"application/vnd.marlin.drm.conftoken+xml\")\n  val `application/vnd.marlin.drm.license+xml` = MimeType(\"application/vnd.marlin.drm.license+xml\")\n  val `application/vnd.marlin.drm.mdcf` = MimeType(\"application/vnd.marlin.drm.mdcf\")\n  val `application/vnd.mcd` = MimeType(\"application/vnd.mcd\", \"mcd\")\n  val `application/vnd.medcalcdata` = MimeType(\"application/vnd.medcalcdata\", \"mc1\")\n  val `application/vnd.mediastation.cdkey` = MimeType(\"application/vnd.mediastation.cdkey\", \"cdkey\")\n  val `application/vnd.meridian-slingshot` = MimeType(\"application/vnd.meridian-slingshot\")\n  val `application/vnd.mfer` = MimeType(\"application/vnd.mfer\", \"mwf\")\n  val `application/vnd.mfmp` = MimeType(\"application/vnd.mfmp\", \"mfm\")\n  val `application/vnd.micrografx.flo` = MimeType(\"application/vnd.micrografx.flo\", \"flo\")\n  val `application/vnd.micrografx.igx` = MimeType(\"application/vnd.micrografx.igx\", \"igx\")\n  val `application/vnd.mif` = MimeType(\"application/vnd.mif\", \"mif\")\n  val `application/vnd.minisoft-hp3000-save` = MimeType(\"application/vnd.minisoft-hp3000-save\")\n\n  val `application/vnd.mitsubishi.misty-guard.trustweb` = MimeType(\"application/vnd.mitsubishi.misty-guard.trustweb\")\n\n  val `application/vnd.mobius.daf` = MimeType(\"application/vnd.mobius.daf\", \"daf\")\n  val `application/vnd.mobius.dis` = MimeType(\"application/vnd.mobius.dis\", \"dis\")\n  val `application/vnd.mobius.mbk` = MimeType(\"application/vnd.mobius.mbk\", \"mbk\")\n  val `application/vnd.mobius.mqy` = MimeType(\"application/vnd.mobius.mqy\", \"mqy\")\n  val `application/vnd.mobius.msl` = MimeType(\"application/vnd.mobius.msl\", \"msl\")\n  val `application/vnd.mobius.plc` = MimeType(\"application/vnd.mobius.plc\", \"plc\")\n  val `application/vnd.mobius.txf` = MimeType(\"application/vnd.mobius.txf\", \"txf\")\n  val `application/vnd.mophun.application` = MimeType(\"application/vnd.mophun.application\", \"mpn\")\n  val `application/vnd.mophun.certificate` = MimeType(\"application/vnd.mophun.certificate\", \"mpc\")\n  val `application/vnd.motorola.flexsuite` = MimeType(\"application/vnd.motorola.flexsuite\")\n  val `application/vnd.motorola.flexsuite.adsi` = MimeType(\"application/vnd.motorola.flexsuite.adsi\")\n  val `application/vnd.motorola.flexsuite.fis` = MimeType(\"application/vnd.motorola.flexsuite.fis\")\n  val `application/vnd.motorola.flexsuite.gotap` = MimeType(\"application/vnd.motorola.flexsuite.gotap\")\n  val `application/vnd.motorola.flexsuite.kmr` = MimeType(\"application/vnd.motorola.flexsuite.kmr\")\n  val `application/vnd.motorola.flexsuite.ttc` = MimeType(\"application/vnd.motorola.flexsuite.ttc\")\n  val `application/vnd.motorola.flexsuite.wem` = MimeType(\"application/vnd.motorola.flexsuite.wem\")\n  val `application/vnd.motorola.iprm` = MimeType(\"application/vnd.motorola.iprm\")\n  val `application/vnd.mozilla.xul+xml` = MimeType(\"application/vnd.mozilla.xul+xml\", \"xul\")\n  val `application/vnd.ms-artgalry` = MimeType(\"application/vnd.ms-artgalry\", \"cil\")\n  val `application/vnd.ms-asf` = MimeType(\"application/vnd.ms-asf\")\n  val `application/vnd.ms-cab-compressed` = MimeType(\"application/vnd.ms-cab-compressed\", \"cab\")\n\n  val `application/vnd.ms-excel` =\n    MimeType(\"application/vnd.ms-excel\", \"xla\", \"xlb\", \"xlc\", \"xlm\", \"xls\", \"xlt\", \"xlw\")\n\n  val `application/vnd.ms-excel.addin.macroenabled.12` =\n    MimeType(\"application/vnd.ms-excel.addin.macroenabled.12\", \"xlam\")\n\n  val `application/vnd.ms-excel.sheet.binary.macroenabled.12` =\n    MimeType(\"application/vnd.ms-excel.sheet.binary.macroenabled.12\", \"xlsb\")\n\n  val `application/vnd.ms-excel.sheet.macroenabled.12` =\n    MimeType(\"application/vnd.ms-excel.sheet.macroenabled.12\", \"xlsm\")\n\n  val `application/vnd.ms-excel.template.macroenabled.12` =\n    MimeType(\"application/vnd.ms-excel.template.macroenabled.12\", \"xltm\")\n\n  val `application/vnd.ms-fontobject` = MimeType(\"application/vnd.ms-fontobject\", \"eot\")\n  val `application/vnd.ms-htmlhelp` = MimeType(\"application/vnd.ms-htmlhelp\", \"chm\")\n  val `application/vnd.ms-ims` = MimeType(\"application/vnd.ms-ims\", \"ims\")\n  val `application/vnd.ms-lrm` = MimeType(\"application/vnd.ms-lrm\", \"lrm\")\n  val `application/vnd.ms-pki.seccat` = MimeType(\"application/vnd.ms-pki.seccat\", \"cat\")\n  val `application/vnd.ms-pki.stl` = MimeType(\"application/vnd.ms-pki.stl\", \"stl\")\n  val `application/vnd.ms-playready.initiator+xml` = MimeType(\"application/vnd.ms-playready.initiator+xml\")\n  val `application/vnd.ms-powerpoint` = MimeType(\"application/vnd.ms-powerpoint\", \"pot\", \"pps\", \"ppt\")\n\n  val `application/vnd.ms-powerpoint.addin.macroenabled.12` =\n    MimeType(\"application/vnd.ms-powerpoint.addin.macroenabled.12\", \"ppam\")\n\n  val `application/vnd.ms-powerpoint.presentation.macroenabled.12` =\n    MimeType(\"application/vnd.ms-powerpoint.presentation.macroenabled.12\", \"pptm\")\n\n  val `application/vnd.ms-powerpoint.slide.macroenabled.12` =\n    MimeType(\"application/vnd.ms-powerpoint.slide.macroenabled.12\", \"sldm\")\n\n  val `application/vnd.ms-powerpoint.slideshow.macroenabled.12` =\n    MimeType(\"application/vnd.ms-powerpoint.slideshow.macroenabled.12\", \"ppsm\")\n\n  val `application/vnd.ms-powerpoint.template.macroenabled.12` =\n    MimeType(\"application/vnd.ms-powerpoint.template.macroenabled.12\", \"potm\")\n\n  val `application/vnd.ms-project` = MimeType(\"application/vnd.ms-project\", \"mpp\", \"mpt\")\n  val `application/vnd.ms-tnef` = MimeType(\"application/vnd.ms-tnef\")\n  val `application/vnd.ms-wmdrm.lic-chlg-req` = MimeType(\"application/vnd.ms-wmdrm.lic-chlg-req\")\n  val `application/vnd.ms-wmdrm.lic-resp` = MimeType(\"application/vnd.ms-wmdrm.lic-resp\")\n  val `application/vnd.ms-wmdrm.meter-chlg-req` = MimeType(\"application/vnd.ms-wmdrm.meter-chlg-req\")\n  val `application/vnd.ms-wmdrm.meter-resp` = MimeType(\"application/vnd.ms-wmdrm.meter-resp\")\n\n  val `application/vnd.ms-word.document.macroenabled.12` =\n    MimeType(\"application/vnd.ms-word.document.macroenabled.12\", \"docm\")\n\n  val `application/vnd.ms-word.template.macroenabled.12` =\n    MimeType(\"application/vnd.ms-word.template.macroenabled.12\", \"dotm\")\n\n  val `application/vnd.ms-works` = MimeType(\"application/vnd.ms-works\", \"wcm\", \"wdb\", \"wks\", \"wps\")\n  val `application/vnd.ms-wpl` = MimeType(\"application/vnd.ms-wpl\", \"wpl\")\n  val `application/vnd.ms-xpsdocument` = MimeType(\"application/vnd.ms-xpsdocument\", \"xps\")\n  val `application/vnd.mseq` = MimeType(\"application/vnd.mseq\", \"mseq\")\n  val `application/vnd.msign` = MimeType(\"application/vnd.msign\")\n  val `application/vnd.multiad.creator` = MimeType(\"application/vnd.multiad.creator\")\n  val `application/vnd.multiad.creator.cif` = MimeType(\"application/vnd.multiad.creator.cif\")\n  val `application/vnd.music-niff` = MimeType(\"application/vnd.music-niff\")\n  val `application/vnd.musician` = MimeType(\"application/vnd.musician\", \"mus\")\n  val `application/vnd.muvee.style` = MimeType(\"application/vnd.muvee.style\", \"msty\")\n  val `application/vnd.ncd.control` = MimeType(\"application/vnd.ncd.control\")\n  val `application/vnd.ncd.reference` = MimeType(\"application/vnd.ncd.reference\")\n  val `application/vnd.nervana` = MimeType(\"application/vnd.nervana\")\n  val `application/vnd.netfpx` = MimeType(\"application/vnd.netfpx\")\n  val `application/vnd.neurolanguage.nlu` = MimeType(\"application/vnd.neurolanguage.nlu\", \"nlu\")\n  val `application/vnd.noblenet-directory` = MimeType(\"application/vnd.noblenet-directory\", \"nnd\")\n  val `application/vnd.noblenet-sealer` = MimeType(\"application/vnd.noblenet-sealer\", \"nns\")\n  val `application/vnd.noblenet-web` = MimeType(\"application/vnd.noblenet-web\", \"nnw\")\n  val `application/vnd.nokia.catalogs` = MimeType(\"application/vnd.nokia.catalogs\")\n  val `application/vnd.nokia.conml+wbxml` = MimeType(\"application/vnd.nokia.conml+wbxml\")\n  val `application/vnd.nokia.conml+xml` = MimeType(\"application/vnd.nokia.conml+xml\")\n  val `application/vnd.nokia.iptv.config+xml` = MimeType(\"application/vnd.nokia.iptv.config+xml\")\n  val `application/vnd.nokia.isds-radio-presets` = MimeType(\"application/vnd.nokia.isds-radio-presets\")\n  val `application/vnd.nokia.landmark+wbxml` = MimeType(\"application/vnd.nokia.landmark+wbxml\")\n  val `application/vnd.nokia.landmark+xml` = MimeType(\"application/vnd.nokia.landmark+xml\")\n  val `application/vnd.nokia.landmarkcollection+xml` = MimeType(\"application/vnd.nokia.landmarkcollection+xml\")\n  val `application/vnd.nokia.n-gage.ac+xml` = MimeType(\"application/vnd.nokia.n-gage.ac+xml\")\n  val `application/vnd.nokia.n-gage.data` = MimeType(\"application/vnd.nokia.n-gage.data\", \"ngdat\")\n\n  val `application/vnd.nokia.n-gage.symbian.install` =\n    MimeType(\"application/vnd.nokia.n-gage.symbian.install\", \"n\", \"-gage\")\n\n  val `application/vnd.nokia.ncd` = MimeType(\"application/vnd.nokia.ncd\")\n  val `application/vnd.nokia.pcd+wbxml` = MimeType(\"application/vnd.nokia.pcd+wbxml\")\n  val `application/vnd.nokia.pcd+xml` = MimeType(\"application/vnd.nokia.pcd+xml\")\n  val `application/vnd.nokia.radio-preset` = MimeType(\"application/vnd.nokia.radio-preset\", \"rpst\")\n  val `application/vnd.nokia.radio-presets` = MimeType(\"application/vnd.nokia.radio-presets\", \"rpss\")\n  val `application/vnd.novadigm.edm` = MimeType(\"application/vnd.novadigm.edm\", \"edm\")\n  val `application/vnd.novadigm.edx` = MimeType(\"application/vnd.novadigm.edx\", \"edx\")\n  val `application/vnd.novadigm.ext` = MimeType(\"application/vnd.novadigm.ext\", \"ext\")\n  val `application/vnd.oasis.opendocument.chart` = MimeType(\"application/vnd.oasis.opendocument.chart\", \"odc\")\n\n  val `application/vnd.oasis.opendocument.chart-template` =\n    MimeType(\"application/vnd.oasis.opendocument.chart-template\", \"otc\")\n\n  val `application/vnd.oasis.opendocument.database` = MimeType(\"application/vnd.oasis.opendocument.database\", \"odb\")\n  val `application/vnd.oasis.opendocument.formula` = MimeType(\"application/vnd.oasis.opendocument.formula\", \"odf\")\n\n  val `application/vnd.oasis.opendocument.formula-template` =\n    MimeType(\"application/vnd.oasis.opendocument.formula-template\", \"odft\")\n\n  val `application/vnd.oasis.opendocument.graphics` = MimeType(\"application/vnd.oasis.opendocument.graphics\", \"odg\")\n\n  val `application/vnd.oasis.opendocument.graphics-template` =\n    MimeType(\"application/vnd.oasis.opendocument.graphics-template\", \"otg\")\n\n  val `application/vnd.oasis.opendocument.image` = MimeType(\"application/vnd.oasis.opendocument.image\", \"odi\")\n\n  val `application/vnd.oasis.opendocument.image-template` =\n    MimeType(\"application/vnd.oasis.opendocument.image-template\", \"oti\")\n\n  val `application/vnd.oasis.opendocument.presentation` =\n    MimeType(\"application/vnd.oasis.opendocument.presentation\", \"odp\")\n\n  val `application/vnd.oasis.opendocument.presentation-template` =\n    MimeType(\"application/vnd.oasis.opendocument.presentation-template\", \"otp\")\n\n  val `application/vnd.oasis.opendocument.spreadsheet` =\n    MimeType(\"application/vnd.oasis.opendocument.spreadsheet\", \"ods\")\n\n  val `application/vnd.oasis.opendocument.spreadsheet-template` =\n    MimeType(\"application/vnd.oasis.opendocument.spreadsheet-template\", \"ots\")\n\n  val `application/vnd.oasis.opendocument.text` = MimeType(\"application/vnd.oasis.opendocument.text\", \"odt\")\n\n  val `application/vnd.oasis.opendocument.text-master` =\n    MimeType(\"application/vnd.oasis.opendocument.text-master\", \"odm\", \"otm\")\n\n  val `application/vnd.oasis.opendocument.text-template` =\n    MimeType(\"application/vnd.oasis.opendocument.text-template\", \"ott\")\n\n  val `application/vnd.oasis.opendocument.text-web` = MimeType(\"application/vnd.oasis.opendocument.text-web\", \"oth\")\n  val `application/vnd.obn` = MimeType(\"application/vnd.obn\")\n  val `application/vnd.olpc-sugar` = MimeType(\"application/vnd.olpc-sugar\", \"xo\")\n  val `application/vnd.oma-scws-config` = MimeType(\"application/vnd.oma-scws-config\")\n  val `application/vnd.oma-scws-http-request` = MimeType(\"application/vnd.oma-scws-http-request\")\n  val `application/vnd.oma-scws-http-response` = MimeType(\"application/vnd.oma-scws-http-response\")\n\n  val `application/vnd.oma.bcast.associated-procedure-parameter+xml` = MimeType(\n      \"application/vnd.oma.bcast.associated-procedure-parameter+xml\")\n\n  val `application/vnd.oma.bcast.drm-trigger+xml` = MimeType(\"application/vnd.oma.bcast.drm-trigger+xml\")\n  val `application/vnd.oma.bcast.imd+xml` = MimeType(\"application/vnd.oma.bcast.imd+xml\")\n  val `application/vnd.oma.bcast.ltkm` = MimeType(\"application/vnd.oma.bcast.ltkm\")\n  val `application/vnd.oma.bcast.notification+xml` = MimeType(\"application/vnd.oma.bcast.notification+xml\")\n  val `application/vnd.oma.bcast.provisioningtrigger` = MimeType(\"application/vnd.oma.bcast.provisioningtrigger\")\n  val `application/vnd.oma.bcast.sgboot` = MimeType(\"application/vnd.oma.bcast.sgboot\")\n  val `application/vnd.oma.bcast.sgdd+xml` = MimeType(\"application/vnd.oma.bcast.sgdd+xml\")\n  val `application/vnd.oma.bcast.sgdu` = MimeType(\"application/vnd.oma.bcast.sgdu\")\n\n  val `application/vnd.oma.bcast.simple-symbol-container` = MimeType(\n      \"application/vnd.oma.bcast.simple-symbol-container\")\n\n  val `application/vnd.oma.bcast.smartcard-trigger+xml` = MimeType(\"application/vnd.oma.bcast.smartcard-trigger+xml\")\n\n  val `application/vnd.oma.bcast.sprov+xml` = MimeType(\"application/vnd.oma.bcast.sprov+xml\")\n  val `application/vnd.oma.bcast.stkm` = MimeType(\"application/vnd.oma.bcast.stkm\")\n  val `application/vnd.oma.dcd` = MimeType(\"application/vnd.oma.dcd\")\n  val `application/vnd.oma.dcdc` = MimeType(\"application/vnd.oma.dcdc\")\n  val `application/vnd.oma.dd2+xml` = MimeType(\"application/vnd.oma.dd2+xml\", \"dd2\")\n  val `application/vnd.oma.drm.risd+xml` = MimeType(\"application/vnd.oma.drm.risd+xml\")\n  val `application/vnd.oma.group-usage-list+xml` = MimeType(\"application/vnd.oma.group-usage-list+xml\")\n\n  val `application/vnd.oma.poc.detailed-progress-report+xml` = MimeType(\n      \"application/vnd.oma.poc.detailed-progress-report+xml\")\n\n  val `application/vnd.oma.poc.final-report+xml` = MimeType(\"application/vnd.oma.poc.final-report+xml\")\n  val `application/vnd.oma.poc.groups+xml` = MimeType(\"application/vnd.oma.poc.groups+xml\")\n\n  val `application/vnd.oma.poc.invocation-descriptor+xml` = MimeType(\n      \"application/vnd.oma.poc.invocation-descriptor+xml\")\n\n  val `application/vnd.oma.poc.optimized-progress-report+xml` = MimeType(\n      \"application/vnd.oma.poc.optimized-progress-report+xml\")\n\n  val `application/vnd.oma.xcap-directory+xml` = MimeType(\"application/vnd.oma.xcap-directory+xml\")\n  val `application/vnd.omads-email+xml` = MimeType(\"application/vnd.omads-email+xml\")\n  val `application/vnd.omads-file+xml` = MimeType(\"application/vnd.omads-file+xml\")\n  val `application/vnd.omads-folder+xml` = MimeType(\"application/vnd.omads-folder+xml\")\n  val `application/vnd.omaloc-supl-init` = MimeType(\"application/vnd.omaloc-supl-init\")\n  val `application/vnd.openofficeorg.extension` = MimeType(\"application/vnd.openofficeorg.extension\", \"oxt\")\n\n  val `application/vnd.openxmlformats-officedocument.presentationml.presentation` =\n    MimeType(\"application/vnd.openxmlformats-officedocument.presentationml.presentation\", \"pptx\")\n\n  val `application/vnd.openxmlformats-officedocument.presentationml.slide` =\n    MimeType(\"application/vnd.openxmlformats-officedocument.presentationml.slide\", \"sldx\")\n\n  val `application/vnd.openxmlformats-officedocument.presentationml.slideshow` =\n    MimeType(\"application/vnd.openxmlformats-officedocument.presentationml.slideshow\", \"ppsx\")\n\n  val `application/vnd.openxmlformats-officedocument.presentationml.template` =\n    MimeType(\"application/vnd.openxmlformats-officedocument.presentationml.template\", \"potx\")\n\n  val `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` =\n    MimeType(\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\", \"xlsx\")\n\n  val `application/vnd.openxmlformats-officedocument.spreadsheetml.template` =\n    MimeType(\"application/vnd.openxmlformats-officedocument.spreadsheetml.template\", \"xltx\")\n\n  val `application/vnd.openxmlformats-officedocument.wordprocessingml.document` =\n    MimeType(\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\", \"docx\")\n\n  val `application/vnd.openxmlformats-officedocument.wordprocessingml.template` =\n    MimeType(\"application/vnd.openxmlformats-officedocument.wordprocessingml.template\", \"dotx\")\n\n  val `application/vnd.osa.netdeploy` = MimeType(\"application/vnd.osa.netdeploy\")\n  val `application/vnd.osgi.bundle` = MimeType(\"application/vnd.osgi.bundle\")\n  val `application/vnd.osgi.dp` = MimeType(\"application/vnd.osgi.dp\", \"dp\")\n  val `application/vnd.otps.ct-kip+xml` = MimeType(\"application/vnd.otps.ct-kip+xml\")\n  val `application/vnd.palm` = MimeType(\"application/vnd.palm\", \"oprc\", \"pdb\", \"pqa\")\n  val `application/vnd.paos.xml` = MimeType(\"application/vnd.paos.xml\")\n  val `application/vnd.pg.format` = MimeType(\"application/vnd.pg.format\", \"str\")\n  val `application/vnd.pg.osasli` = MimeType(\"application/vnd.pg.osasli\", \"ei6\")\n  val `application/vnd.piaccess.application-licence` = MimeType(\"application/vnd.piaccess.application-licence\")\n  val `application/vnd.picsel` = MimeType(\"application/vnd.picsel\", \"efif\")\n  val `application/vnd.poc.group-advertisement+xml` = MimeType(\"application/vnd.poc.group-advertisement+xml\")\n  val `application/vnd.pocketlearn` = MimeType(\"application/vnd.pocketlearn\", \"plf\")\n  val `application/vnd.powerbuilder6` = MimeType(\"application/vnd.powerbuilder6\", \"pbd\")\n  val `application/vnd.powerbuilder6-s` = MimeType(\"application/vnd.powerbuilder6-s\")\n  val `application/vnd.powerbuilder7` = MimeType(\"application/vnd.powerbuilder7\")\n  val `application/vnd.powerbuilder7-s` = MimeType(\"application/vnd.powerbuilder7-s\")\n  val `application/vnd.powerbuilder75` = MimeType(\"application/vnd.powerbuilder75\")\n  val `application/vnd.powerbuilder75-s` = MimeType(\"application/vnd.powerbuilder75-s\")\n  val `application/vnd.preminet` = MimeType(\"application/vnd.preminet\")\n  val `application/vnd.previewsystems.box` = MimeType(\"application/vnd.previewsystems.box\", \"box\")\n  val `application/vnd.proteus.magazine` = MimeType(\"application/vnd.proteus.magazine\", \"mgz\")\n  val `application/vnd.publishare-delta-tree` = MimeType(\"application/vnd.publishare-delta-tree\", \"qps\")\n  val `application/vnd.pvi.ptid1` = MimeType(\"application/vnd.pvi.ptid1\", \"ptid\")\n  val `application/vnd.pwg-multiplexed` = MimeType(\"application/vnd.pwg-multiplexed\")\n  val `application/vnd.pwg-xhtml-print+xml` = MimeType(\"application/vnd.pwg-xhtml-print+xml\")\n  val `application/vnd.qualcomm.brew-app-res` = MimeType(\"application/vnd.qualcomm.brew-app-res\")\n\n  val `application/vnd.quark.quarkxpress` =\n    MimeType(\"application/vnd.quark.quarkxpress\", \"qwd\", \"qwt\", \"qxb\", \"qxd\", \"qxl\", \"qxt\")\n\n  val `application/vnd.rapid` = MimeType(\"application/vnd.rapid\")\n  val `application/vnd.recordare.musicxml` = MimeType(\"application/vnd.recordare.musicxml\", \"mxl\")\n  val `application/vnd.recordare.musicxml+xml` = MimeType(\"application/vnd.recordare.musicxml+xml\", \"musicxml\")\n  val `application/vnd.renlearn.rlprint` = MimeType(\"application/vnd.renlearn.rlprint\")\n  val `application/vnd.rim.cod` = MimeType(\"application/vnd.rim.cod\", \"cod\")\n  val `application/vnd.rn-realmedia` = MimeType(\"application/vnd.rn-realmedia\", \"rm\")\n  val `application/vnd.route66.link66+xml` = MimeType(\"application/vnd.route66.link66+xml\", \"link66\")\n  val `application/vnd.ruckus.download` = MimeType(\"application/vnd.ruckus.download\")\n  val `application/vnd.s3sms` = MimeType(\"application/vnd.s3sms\")\n  val `application/vnd.sbm.cid` = MimeType(\"application/vnd.sbm.cid\")\n  val `application/vnd.sbm.mid2` = MimeType(\"application/vnd.sbm.mid2\")\n  val `application/vnd.scribus` = MimeType(\"application/vnd.scribus\")\n  val `application/vnd.sealed.3df` = MimeType(\"application/vnd.sealed.3df\")\n  val `application/vnd.sealed.csf` = MimeType(\"application/vnd.sealed.csf\")\n  val `application/vnd.sealed.doc` = MimeType(\"application/vnd.sealed.doc\")\n  val `application/vnd.sealed.eml` = MimeType(\"application/vnd.sealed.eml\")\n  val `application/vnd.sealed.mht` = MimeType(\"application/vnd.sealed.mht\")\n  val `application/vnd.sealed.net` = MimeType(\"application/vnd.sealed.net\")\n  val `application/vnd.sealed.ppt` = MimeType(\"application/vnd.sealed.ppt\")\n  val `application/vnd.sealed.tiff` = MimeType(\"application/vnd.sealed.tiff\")\n  val `application/vnd.sealed.xls` = MimeType(\"application/vnd.sealed.xls\")\n  val `application/vnd.sealedmedia.softseal.html` = MimeType(\"application/vnd.sealedmedia.softseal.html\")\n  val `application/vnd.sealedmedia.softseal.pdf` = MimeType(\"application/vnd.sealedmedia.softseal.pdf\")\n  val `application/vnd.seemail` = MimeType(\"application/vnd.seemail\", \"see\")\n  val `application/vnd.sema` = MimeType(\"application/vnd.sema\", \"sema\")\n  val `application/vnd.semd` = MimeType(\"application/vnd.semd\", \"semd\")\n  val `application/vnd.semf` = MimeType(\"application/vnd.semf\", \"semf\")\n  val `application/vnd.shana.informed.formdata` = MimeType(\"application/vnd.shana.informed.formdata\", \"ifm\")\n  val `application/vnd.shana.informed.formtemplate` = MimeType(\"application/vnd.shana.informed.formtemplate\", \"itp\")\n  val `application/vnd.shana.informed.interchange` = MimeType(\"application/vnd.shana.informed.interchange\", \"iif\")\n  val `application/vnd.shana.informed.package` = MimeType(\"application/vnd.shana.informed.package\", \"ipk\")\n  val `application/vnd.simtech-mindmapper` = MimeType(\"application/vnd.simtech-mindmapper\", \"twd\", \"twds\")\n  val `application/vnd.smaf` = MimeType(\"application/vnd.smaf\", \"mmf\")\n  val `application/vnd.smart.teacher` = MimeType(\"application/vnd.smart.teacher\", \"teacher\")\n  val `application/vnd.software602.filler.form+xml` = MimeType(\"application/vnd.software602.filler.form+xml\")\n\n  val `application/vnd.software602.filler.form-xml-zip` = MimeType(\"application/vnd.software602.filler.form-xml-zip\")\n\n  val `application/vnd.solent.sdkm+xml` = MimeType(\"application/vnd.solent.sdkm+xml\", \"sdkd\", \"sdkm\")\n  val `application/vnd.spotfire.dxp` = MimeType(\"application/vnd.spotfire.dxp\", \"dxp\")\n  val `application/vnd.spotfire.sfs` = MimeType(\"application/vnd.spotfire.sfs\", \"sfs\")\n  val `application/vnd.sss-cod` = MimeType(\"application/vnd.sss-cod\")\n  val `application/vnd.sss-dtf` = MimeType(\"application/vnd.sss-dtf\")\n  val `application/vnd.sss-ntf` = MimeType(\"application/vnd.sss-ntf\")\n  val `application/vnd.stardivision.calc` = MimeType(\"application/vnd.stardivision.calc\", \"sdc\")\n  val `application/vnd.stardivision.draw` = MimeType(\"application/vnd.stardivision.draw\", \"sda\")\n  val `application/vnd.stardivision.impress` = MimeType(\"application/vnd.stardivision.impress\", \"sdd\", \"sdp\")\n  val `application/vnd.stardivision.math` = MimeType(\"application/vnd.stardivision.math\", \"sdf\", \"smf\")\n  val `application/vnd.stardivision.writer` = MimeType(\"application/vnd.stardivision.writer\", \"sdw\", \"vor\")\n  val `application/vnd.stardivision.writer-global` = MimeType(\"application/vnd.stardivision.writer-global\", \"sgl\")\n  val `application/vnd.street-stream` = MimeType(\"application/vnd.street-stream\")\n  val `application/vnd.sun.wadl+xml` = MimeType(\"application/vnd.sun.wadl+xml\")\n  val `application/vnd.sun.xml.calc` = MimeType(\"application/vnd.sun.xml.calc\", \"sxc\")\n  val `application/vnd.sun.xml.calc.template` = MimeType(\"application/vnd.sun.xml.calc.template\", \"stc\")\n  val `application/vnd.sun.xml.draw` = MimeType(\"application/vnd.sun.xml.draw\", \"sxd\")\n  val `application/vnd.sun.xml.draw.template` = MimeType(\"application/vnd.sun.xml.draw.template\", \"std\")\n  val `application/vnd.sun.xml.impress` = MimeType(\"application/vnd.sun.xml.impress\", \"sxi\")\n  val `application/vnd.sun.xml.impress.template` = MimeType(\"application/vnd.sun.xml.impress.template\", \"sti\")\n  val `application/vnd.sun.xml.math` = MimeType(\"application/vnd.sun.xml.math\", \"sxm\")\n  val `application/vnd.sun.xml.writer` = MimeType(\"application/vnd.sun.xml.writer\", \"sxw\")\n  val `application/vnd.sun.xml.writer.global` = MimeType(\"application/vnd.sun.xml.writer.global\", \"sxg\")\n  val `application/vnd.sun.xml.writer.template` = MimeType(\"application/vnd.sun.xml.writer.template\", \"stw\")\n  val `application/vnd.sus-calendar` = MimeType(\"application/vnd.sus-calendar\", \"sus\", \"susp\")\n  val `application/vnd.svd` = MimeType(\"application/vnd.svd\", \"svd\")\n  val `application/vnd.swiftview-ics` = MimeType(\"application/vnd.swiftview-ics\")\n  val `application/vnd.symbian.install` = MimeType(\"application/vnd.symbian.install\", \"sis\", \"sisx\")\n  val `application/vnd.syncml+xml` = MimeType(\"application/vnd.syncml+xml\", \"xsm\")\n  val `application/vnd.syncml.dm+wbxml` = MimeType(\"application/vnd.syncml.dm+wbxml\", \"bdm\")\n  val `application/vnd.syncml.dm+xml` = MimeType(\"application/vnd.syncml.dm+xml\", \"xdm\")\n  val `application/vnd.syncml.dm.notification` = MimeType(\"application/vnd.syncml.dm.notification\")\n  val `application/vnd.syncml.ds.notification` = MimeType(\"application/vnd.syncml.ds.notification\")\n  val `application/vnd.tao.intent-module-archive` = MimeType(\"application/vnd.tao.intent-module-archive\", \"tao\")\n  val `application/vnd.tmobile-livetv` = MimeType(\"application/vnd.tmobile-livetv\", \"tmo\")\n  val `application/vnd.trid.tpt` = MimeType(\"application/vnd.trid.tpt\", \"tpt\")\n  val `application/vnd.triscape.mxs` = MimeType(\"application/vnd.triscape.mxs\", \"mxs\")\n  val `application/vnd.trueapp` = MimeType(\"application/vnd.trueapp\", \"tra\")\n  val `application/vnd.truedoc` = MimeType(\"application/vnd.truedoc\")\n  val `application/vnd.ufdl` = MimeType(\"application/vnd.ufdl\", \"ufd\", \"ufdl\")\n  val `application/vnd.uiq.theme` = MimeType(\"application/vnd.uiq.theme\", \"utz\")\n  val `application/vnd.umajin` = MimeType(\"application/vnd.umajin\", \"umj\")\n  val `application/vnd.unity` = MimeType(\"application/vnd.unity\", \"unityweb\")\n  val `application/vnd.uoml+xml` = MimeType(\"application/vnd.uoml+xml\", \"uoml\")\n  val `application/vnd.uplanet.alert` = MimeType(\"application/vnd.uplanet.alert\")\n  val `application/vnd.uplanet.alert-wbxml` = MimeType(\"application/vnd.uplanet.alert-wbxml\")\n  val `application/vnd.uplanet.bearer-choice` = MimeType(\"application/vnd.uplanet.bearer-choice\")\n  val `application/vnd.uplanet.bearer-choice-wbxml` = MimeType(\"application/vnd.uplanet.bearer-choice-wbxml\")\n  val `application/vnd.uplanet.cacheop` = MimeType(\"application/vnd.uplanet.cacheop\")\n  val `application/vnd.uplanet.cacheop-wbxml` = MimeType(\"application/vnd.uplanet.cacheop-wbxml\")\n  val `application/vnd.uplanet.channel` = MimeType(\"application/vnd.uplanet.channel\")\n  val `application/vnd.uplanet.channel-wbxml` = MimeType(\"application/vnd.uplanet.channel-wbxml\")\n  val `application/vnd.uplanet.list` = MimeType(\"application/vnd.uplanet.list\")\n  val `application/vnd.uplanet.list-wbxml` = MimeType(\"application/vnd.uplanet.list-wbxml\")\n  val `application/vnd.uplanet.listcmd` = MimeType(\"application/vnd.uplanet.listcmd\")\n  val `application/vnd.uplanet.listcmd-wbxml` = MimeType(\"application/vnd.uplanet.listcmd-wbxml\")\n  val `application/vnd.uplanet.signal` = MimeType(\"application/vnd.uplanet.signal\")\n  val `application/vnd.vcx` = MimeType(\"application/vnd.vcx\", \"vcx\")\n  val `application/vnd.vd-study` = MimeType(\"application/vnd.vd-study\")\n  val `application/vnd.vectorworks` = MimeType(\"application/vnd.vectorworks\")\n  val `application/vnd.vidsoft.vidconference` = MimeType(\"application/vnd.vidsoft.vidconference\")\n  val `application/vnd.visio` = MimeType(\"application/vnd.visio\", \"vsd\", \"vss\", \"vst\", \"vsw\")\n  val `application/vnd.visionary` = MimeType(\"application/vnd.visionary\", \"vis\")\n  val `application/vnd.vividence.scriptfile` = MimeType(\"application/vnd.vividence.scriptfile\")\n  val `application/vnd.vsf` = MimeType(\"application/vnd.vsf\", \"vsf\")\n  val `application/vnd.wap.sic` = MimeType(\"application/vnd.wap.sic\")\n  val `application/vnd.wap.slc` = MimeType(\"application/vnd.wap.slc\")\n  val `application/vnd.wap.wbxml` = MimeType(\"application/vnd.wap.wbxml\", \"wbxml\")\n  val `application/vnd.wap.wmlc` = MimeType(\"application/vnd.wap.wmlc\", \"wmlc\")\n  val `application/vnd.wap.wmlscriptc` = MimeType(\"application/vnd.wap.wmlscriptc\", \"wmlsc\")\n  val `application/vnd.webturbo` = MimeType(\"application/vnd.webturbo\", \"wtb\")\n  val `application/vnd.wfa.wsc` = MimeType(\"application/vnd.wfa.wsc\")\n  val `application/vnd.wmc` = MimeType(\"application/vnd.wmc\")\n  val `application/vnd.wmf.bootstrap` = MimeType(\"application/vnd.wmf.bootstrap\")\n  val `application/vnd.wordperfect` = MimeType(\"application/vnd.wordperfect\", \"wpd\")\n  val `application/vnd.wqd` = MimeType(\"application/vnd.wqd\", \"wqd\")\n  val `application/vnd.wrq-hp3000-labelled` = MimeType(\"application/vnd.wrq-hp3000-labelled\")\n  val `application/vnd.wt.stf` = MimeType(\"application/vnd.wt.stf\", \"stf\")\n  val `application/vnd.wv.csp+wbxml` = MimeType(\"application/vnd.wv.csp+wbxml\")\n  val `application/vnd.wv.csp+xml` = MimeType(\"application/vnd.wv.csp+xml\")\n  val `application/vnd.wv.ssp+xml` = MimeType(\"application/vnd.wv.ssp+xml\")\n  val `application/vnd.xara` = MimeType(\"application/vnd.xara\", \"xar\")\n  val `application/vnd.xfdl` = MimeType(\"application/vnd.xfdl\", \"xfdl\")\n  val `application/vnd.xfdl.webform` = MimeType(\"application/vnd.xfdl.webform\")\n  val `application/vnd.xmi+xml` = MimeType(\"application/vnd.xmi+xml\")\n  val `application/vnd.xmpie.cpkg` = MimeType(\"application/vnd.xmpie.cpkg\")\n  val `application/vnd.xmpie.dpkg` = MimeType(\"application/vnd.xmpie.dpkg\")\n  val `application/vnd.xmpie.plan` = MimeType(\"application/vnd.xmpie.plan\")\n  val `application/vnd.xmpie.ppkg` = MimeType(\"application/vnd.xmpie.ppkg\")\n  val `application/vnd.xmpie.xlim` = MimeType(\"application/vnd.xmpie.xlim\")\n  val `application/vnd.yamaha.hv-dic` = MimeType(\"application/vnd.yamaha.hv-dic\", \"hvd\")\n  val `application/vnd.yamaha.hv-script` = MimeType(\"application/vnd.yamaha.hv-script\", \"hvs\")\n  val `application/vnd.yamaha.hv-voice` = MimeType(\"application/vnd.yamaha.hv-voice\", \"hvp\")\n  val `application/vnd.yamaha.openscoreformat` = MimeType(\"application/vnd.yamaha.openscoreformat\", \"osf\")\n\n  val `application/vnd.yamaha.openscoreformat.osfpvg+xml` =\n    MimeType(\"application/vnd.yamaha.openscoreformat.osfpvg+xml\", \"osfpvg\")\n\n  val `application/vnd.yamaha.smaf-audio` = MimeType(\"application/vnd.yamaha.smaf-audio\", \"saf\")\n  val `application/vnd.yamaha.smaf-phrase` = MimeType(\"application/vnd.yamaha.smaf-phrase\", \"spf\")\n  val `application/vnd.yellowriver-custom-menu` = MimeType(\"application/vnd.yellowriver-custom-menu\", \"cmp\")\n  val `application/vnd.zul` = MimeType(\"application/vnd.zul\", \"zir\", \"zirz\")\n  val `application/vnd.zzazz.deck+xml` = MimeType(\"application/vnd.zzazz.deck+xml\", \"zaz\")\n  val `application/voicexml+xml` = MimeType(\"application/voicexml+xml\", \"vxml\")\n  val `application/watcherinfo+xml` = MimeType(\"application/watcherinfo+xml\")\n  val `application/whoispp-query` = MimeType(\"application/whoispp-query\")\n  val `application/whoispp-response` = MimeType(\"application/whoispp-response\")\n  val `application/winhlp` = MimeType(\"application/winhlp\", \"hlp\")\n  val `application/wita` = MimeType(\"application/wita\")\n  val `application/wordperfect` = MimeType(\"application/wordperfect\", \"wpd\")\n  val `application/wordperfect5.1` = MimeType(\"application/wordperfect5.1\", \"wp5\")\n  val `application/wsdl+xml` = MimeType(\"application/wsdl+xml\", \"wsdl\")\n  val `application/wspolicy+xml` = MimeType(\"application/wspolicy+xml\", \"wspolicy\")\n  val `application/x-123` = MimeType(\"application/x-123\", \"wk\")\n  val `application/x-abiword` = MimeType(\"application/x-abiword\", \"abw\")\n  val `application/x-ace-compressed` = MimeType(\"application/x-ace-compressed\", \"ace\")\n  val `application/x-apple-diskimage` = MimeType(\"application/x-apple-diskimage\", \"dmg\")\n  val `application/x-authorware-bin` = MimeType(\"application/x-authorware-bin\", \"aab\", \"u32\", \"vox\", \"x32\")\n  val `application/x-authorware-map` = MimeType(\"application/x-authorware-map\", \"aam\")\n  val `application/x-authorware-seg` = MimeType(\"application/x-authorware-seg\", \"aas\")\n  val `application/x-bcpio` = MimeType(\"application/x-bcpio\", \"bcpio\")\n  val `application/x-bittorrent` = MimeType(\"application/x-bittorrent\", \"torrent\")\n  val `application/x-bzip` = MimeType(\"application/x-bzip\", \"bz\")\n  val `application/x-bzip2` = MimeType(\"application/x-bzip2\", \"boz\", \"bz2\")\n  val `application/x-cdf` = MimeType(\"application/x-cdf\", \"cdf\")\n  val `application/x-cdlink` = MimeType(\"application/x-cdlink\", \"vcd\")\n  val `application/x-chat` = MimeType(\"application/x-chat\", \"chat\")\n  val `application/x-chess-pgn` = MimeType(\"application/x-chess-pgn\", \"pgn\")\n  val `application/x-compress` = MimeType(\"application/x-compress\")\n  val `application/x-cpio` = MimeType(\"application/x-cpio\", \"cpio\")\n  val `application/x-csh` = MimeType(\"application/x-csh\", \"csh\")\n  val `application/x-debian-package` = MimeType(\"application/x-debian-package\", \"deb\", \"udeb\")\n\n  val `application/x-director` =\n    MimeType(\"application/x-director\", \"cct\", \"cst\", \"cxt\", \"dcr\", \"dir\", \"dxr\", \"fgd\", \"swa\", \"w3d\")\n\n  val `application/x-dms` = MimeType(\"application/x-dms\", \"dms\")\n  val `application/x-doom` = MimeType(\"application/x-doom\", \"wad\")\n  val `application/x-dtbncx+xml` = MimeType(\"application/x-dtbncx+xml\", \"ncx\")\n  val `application/x-dtbook+xml` = MimeType(\"application/x-dtbook+xml\", \"dtb\")\n  val `application/x-dtbresource+xml` = MimeType(\"application/x-dtbresource+xml\", \"res\")\n  val `application/x-dvi` = MimeType(\"application/x-dvi\", \"dvi\")\n  val `application/x-flac` = MimeType(\"application/x-flac\", \"flac\")\n  val `application/x-font` = MimeType(\"application/x-font\", \"gsf\", \"pcf\", \"pcf\", \".Z\", \"pfa\", \"pfb\")\n  val `application/x-font-bdf` = MimeType(\"application/x-font-bdf\", \"bdf\")\n  val `application/x-font-dos` = MimeType(\"application/x-font-dos\")\n  val `application/x-font-framemaker` = MimeType(\"application/x-font-framemaker\")\n  val `application/x-font-ghostscript` = MimeType(\"application/x-font-ghostscript\", \"gsf\")\n  val `application/x-font-libgrx` = MimeType(\"application/x-font-libgrx\")\n  val `application/x-font-linux-psf` = MimeType(\"application/x-font-linux-psf\", \"psf\")\n  val `application/x-font-otf` = MimeType(\"application/x-font-otf\", \"otf\")\n  val `application/x-font-pcf` = MimeType(\"application/x-font-pcf\", \"pcf\")\n  val `application/x-font-snf` = MimeType(\"application/x-font-snf\", \"snf\")\n  val `application/x-font-speedo` = MimeType(\"application/x-font-speedo\")\n  val `application/x-font-sunos-news` = MimeType(\"application/x-font-sunos-news\")\n  val `application/x-font-ttf` = MimeType(\"application/x-font-ttf\", \"ttc\", \"ttf\")\n  val `application/x-font-type1` = MimeType(\"application/x-font-type1\", \"afm\", \"pfa\", \"pfb\", \"pfm\")\n  val `application/x-font-vfont` = MimeType(\"application/x-font-vfont\")\n  val `application/x-freemind` = MimeType(\"application/x-freemind\", \"mm\")\n  val `application/x-futuresplash` = MimeType(\"application/x-futuresplash\", \"spl\")\n  val `application/x-gnumeric` = MimeType(\"application/x-gnumeric\", \"gnumeric\")\n  val `application/x-go-sgf` = MimeType(\"application/x-go-sgf\", \"sgf\")\n  val `application/x-graphing-calculator` = MimeType(\"application/x-graphing-calculator\", \"gcf\")\n  val `application/x-gtar` = MimeType(\"application/x-gtar\", \"gtar\", \"taz\", \"tgz\")\n  val `application/x-gzip` = MimeType(\"application/x-gzip\")\n  val `application/x-hdf` = MimeType(\"application/x-hdf\", \"hdf\")\n  val `application/x-ica` = MimeType(\"application/x-ica\", \"ica\")\n  val `application/x-internet-signup` = MimeType(\"application/x-internet-signup\", \"ins\", \"isp\")\n  val `application/x-iphone` = MimeType(\"application/x-iphone\", \"iii\")\n  val `application/x-iso9660-image` = MimeType(\"application/x-iso9660-image\", \"iso\")\n  val `application/x-java-jnlp-file` = MimeType(\"application/x-java-jnlp-file\", \"jnlp\")\n  val `application/x-javascript` = MimeType(\"application/x-javascript\", \"js\")\n  val `application/x-jmol` = MimeType(\"application/x-jmol\", \"jmz\")\n  val `application/x-kchart` = MimeType(\"application/x-kchart\", \"chrt\")\n  val `application/x-killustrator` = MimeType(\"application/x-killustrator\", \"kil\")\n  val `application/x-koan` = MimeType(\"application/x-koan\", \"skd\", \"skm\", \"skp\", \"skt\")\n  val `application/x-kpresenter` = MimeType(\"application/x-kpresenter\", \"kpr\", \"kpt\")\n  val `application/x-kspread` = MimeType(\"application/x-kspread\", \"ksp\")\n  val `application/x-kword` = MimeType(\"application/x-kword\", \"kwd\", \"kwt\")\n  val `application/x-latex` = MimeType(\"application/x-latex\", \"latex\")\n  val `application/x-lha` = MimeType(\"application/x-lha\", \"lha\")\n  val `application/x-lzh` = MimeType(\"application/x-lzh\", \"lzh\")\n  val `application/x-lzx` = MimeType(\"application/x-lzx\", \"lzx\")\n  val `application/x-maker` = MimeType(\"application/x-maker\", \"book\", \"fb\", \"fbdoc\", \"fm\", \"frame\", \"frm\", \"maker\")\n  val `application/x-mif` = MimeType(\"application/x-mif\", \"mif\")\n  val `application/x-mobipocket-ebook` = MimeType(\"application/x-mobipocket-ebook\", \"mobi\", \"prc\")\n  val `application/x-ms-application` = MimeType(\"application/x-ms-application\", \"application\")\n  val `application/x-ms-wmd` = MimeType(\"application/x-ms-wmd\", \"wmd\")\n  val `application/x-ms-wmz` = MimeType(\"application/x-ms-wmz\", \"wmz\")\n  val `application/x-ms-xbap` = MimeType(\"application/x-ms-xbap\", \"xbap\")\n  val `application/x-msaccess` = MimeType(\"application/x-msaccess\", \"mdb\")\n  val `application/x-msbinder` = MimeType(\"application/x-msbinder\", \"obd\")\n  val `application/x-mscardfile` = MimeType(\"application/x-mscardfile\", \"crd\")\n  val `application/x-msclip` = MimeType(\"application/x-msclip\", \"clp\")\n  val `application/x-msdos-program` = MimeType(\"application/x-msdos-program\", \"bat\", \"com\", \"dll\", \"exe\")\n  val `application/x-msdownload` = MimeType(\"application/x-msdownload\", \"bat\", \"com\", \"dll\", \"exe\", \"msi\")\n  val `application/x-msi` = MimeType(\"application/x-msi\", \"msi\")\n  val `application/x-msmediaview` = MimeType(\"application/x-msmediaview\", \"m13\", \"m14\", \"mvb\")\n  val `application/x-msmetafile` = MimeType(\"application/x-msmetafile\", \"wmf\")\n  val `application/x-msmoney` = MimeType(\"application/x-msmoney\", \"mny\")\n  val `application/x-mspublisher` = MimeType(\"application/x-mspublisher\", \"pub\")\n  val `application/x-msschedule` = MimeType(\"application/x-msschedule\", \"scd\")\n  val `application/x-msterminal` = MimeType(\"application/x-msterminal\", \"trm\")\n  val `application/x-mswrite` = MimeType(\"application/x-mswrite\", \"wri\")\n  val `application/x-netcdf` = MimeType(\"application/x-netcdf\", \"cdf\", \"nc\")\n  val `application/x-ns-proxy-autoconfig` = MimeType(\"application/x-ns-proxy-autoconfig\", \"pac\")\n  val `application/x-nwc` = MimeType(\"application/x-nwc\", \"nwc\")\n  val `application/x-object` = MimeType(\"application/x-object\", \"o\")\n  val `application/x-oz-application` = MimeType(\"application/x-oz-application\", \"oza\")\n  val `application/x-pkcs12` = MimeType(\"application/x-pkcs12\", \"p12\", \"pfx\")\n  val `application/x-pkcs7-certificates` = MimeType(\"application/x-pkcs7-certificates\", \"p7b\", \"spc\")\n  val `application/x-pkcs7-certreqresp` = MimeType(\"application/x-pkcs7-certreqresp\", \"p7r\")\n  val `application/x-pkcs7-crl` = MimeType(\"application/x-pkcs7-crl\", \"crl\")\n  val `application/x-python-code` = MimeType(\"application/x-python-code\", \"pyc\", \"pyo\")\n  val `application/x-quicktimeplayer` = MimeType(\"application/x-quicktimeplayer\", \"qtl\")\n  val `application/x-rar-compressed` = MimeType(\"application/x-rar-compressed\", \"rar\")\n  val `application/x-redhat-package-manager` = MimeType(\"application/x-redhat-package-manager\", \"rpm\")\n  val `application/x-sh` = MimeType(\"application/x-sh\", \"sh\")\n  val `application/x-shar` = MimeType(\"application/x-shar\", \"shar\")\n  val `application/x-shockwave-flash` = MimeType(\"application/x-shockwave-flash\", \"swf\", \"swfl\")\n  val `application/x-silverlight-app` = MimeType(\"application/x-silverlight-app\", \"xap\")\n  val `application/x-stuffit` = MimeType(\"application/x-stuffit\", \"sit\", \"sitx\")\n  val `application/x-stuffitx` = MimeType(\"application/x-stuffitx\", \"sitx\")\n  val `application/x-sv4cpio` = MimeType(\"application/x-sv4cpio\", \"sv4cpio\")\n  val `application/x-sv4crc` = MimeType(\"application/x-sv4crc\", \"sv4crc\")\n  val `application/x-tar` = MimeType(\"application/x-tar\", \"tar\")\n  val `application/x-tcl` = MimeType(\"application/x-tcl\", \"tcl\")\n  val `application/x-tex` = MimeType(\"application/x-tex\", \"tex\")\n  val `application/x-tex-gf` = MimeType(\"application/x-tex-gf\", \"gf\")\n  val `application/x-tex-pk` = MimeType(\"application/x-tex-pk\", \"pk\")\n  val `application/x-tex-tfm` = MimeType(\"application/x-tex-tfm\", \"tfm\")\n  val `application/x-texinfo` = MimeType(\"application/x-texinfo\", \"texi\", \"texinfo\")\n  val `application/x-trash` = MimeType(\"application/x-trash\", \"%\", \"bak\", \"old\", \"sik\", \"~\")\n  val `application/x-troff` = MimeType(\"application/x-troff\", \"roff\", \"t\", \"tr\")\n  val `application/x-troff-man` = MimeType(\"application/x-troff-man\", \"man\")\n  val `application/x-troff-me` = MimeType(\"application/x-troff-me\", \"me\")\n  val `application/x-troff-ms` = MimeType(\"application/x-troff-ms\", \"ms\")\n  val `application/x-ustar` = MimeType(\"application/x-ustar\", \"ustar\")\n  val `application/x-wais-source` = MimeType(\"application/x-wais-source\", \"src\")\n  val `application/x-wingz` = MimeType(\"application/x-wingz\", \"wz\")\n  val `application/x-x509-ca-cert` = MimeType(\"application/x-x509-ca-cert\", \"crt\", \"der\")\n  val `application/x-xcf` = MimeType(\"application/x-xcf\", \"xcf\")\n  val `application/x-xfig` = MimeType(\"application/x-xfig\", \"fig\")\n  val `application/x-xpinstall` = MimeType(\"application/x-xpinstall\", \"xpi\")\n  val `application/x400-bp` = MimeType(\"application/x400-bp\")\n  val `application/xcap-att+xml` = MimeType(\"application/xcap-att+xml\")\n  val `application/xcap-caps+xml` = MimeType(\"application/xcap-caps+xml\")\n  val `application/xcap-el+xml` = MimeType(\"application/xcap-el+xml\")\n  val `application/xcap-error+xml` = MimeType(\"application/xcap-error+xml\")\n  val `application/xcap-ns+xml` = MimeType(\"application/xcap-ns+xml\")\n  val `application/xcon-conference-info+xml` = MimeType(\"application/xcon-conference-info+xml\")\n  val `application/xcon-conference-info-diff+xml` = MimeType(\"application/xcon-conference-info-diff+xml\")\n  val `application/xenc+xml` = MimeType(\"application/xenc+xml\", \"xenc\")\n  val `application/xhtml+xml` = MimeType(\"application/xhtml+xml\", \"xht\", \"xhtml\")\n  val `application/xhtml-voice+xml` = MimeType(\"application/xhtml-voice+xml\")\n  val `application/xml` = MimeType(\"application/xml\", \"xml\", \"xsl\")\n  val `application/xml-dtd` = MimeType(\"application/xml-dtd\", \"dtd\")\n  val `application/xml-external-parsed-entity` = MimeType(\"application/xml-external-parsed-entity\")\n  val `application/xmpp+xml` = MimeType(\"application/xmpp+xml\")\n  val `application/xop+xml` = MimeType(\"application/xop+xml\", \"xop\")\n  val `application/xslt+xml` = MimeType(\"application/xslt+xml\", \"xslt\")\n  val `application/xspf+xml` = MimeType(\"application/xspf+xml\", \"xspf\")\n  val `application/xv+xml` = MimeType(\"application/xv+xml\", \"mxml\", \"xhvml\", \"xvm\", \"xvml\")\n  val `application/zip` = MimeType(\"application/zip\", \"zip\")\n  val `audio/32kadpcm` = MimeType(\"audio/32kadpcm\")\n  val `audio/3gpp` = MimeType(\"audio/3gpp\")\n  val `audio/3gpp2` = MimeType(\"audio/3gpp2\")\n  val `audio/ac3` = MimeType(\"audio/ac3\")\n  val `audio/adpcm` = MimeType(\"audio/adpcm\", \"adp\")\n  val `audio/amr` = MimeType(\"audio/amr\")\n  val `audio/amr-wb` = MimeType(\"audio/amr-wb\")\n  val `audio/amr-wb+` = MimeType(\"audio/amr-wb+\")\n  val `audio/asc` = MimeType(\"audio/asc\")\n  val `audio/basic` = MimeType(\"audio/basic\", \"au\", \"snd\")\n  val `audio/bv16` = MimeType(\"audio/bv16\")\n  val `audio/bv32` = MimeType(\"audio/bv32\")\n  val `audio/clearmode` = MimeType(\"audio/clearmode\")\n  val `audio/cn` = MimeType(\"audio/cn\")\n  val `audio/dat12` = MimeType(\"audio/dat12\")\n  val `audio/dls` = MimeType(\"audio/dls\")\n  val `audio/dsr-es201108` = MimeType(\"audio/dsr-es201108\")\n  val `audio/dsr-es202050` = MimeType(\"audio/dsr-es202050\")\n  val `audio/dsr-es202211` = MimeType(\"audio/dsr-es202211\")\n  val `audio/dsr-es202212` = MimeType(\"audio/dsr-es202212\")\n  val `audio/dvi4` = MimeType(\"audio/dvi4\")\n  val `audio/eac3` = MimeType(\"audio/eac3\")\n  val `audio/evrc` = MimeType(\"audio/evrc\")\n  val `audio/evrc-qcp` = MimeType(\"audio/evrc-qcp\")\n  val `audio/evrc0` = MimeType(\"audio/evrc0\")\n  val `audio/evrc1` = MimeType(\"audio/evrc1\")\n  val `audio/evrcb` = MimeType(\"audio/evrcb\")\n  val `audio/evrcb0` = MimeType(\"audio/evrcb0\")\n  val `audio/evrcb1` = MimeType(\"audio/evrcb1\")\n  val `audio/evrcwb` = MimeType(\"audio/evrcwb\")\n  val `audio/evrcwb0` = MimeType(\"audio/evrcwb0\")\n  val `audio/evrcwb1` = MimeType(\"audio/evrcwb1\")\n  val `audio/example` = MimeType(\"audio/example\")\n  val `audio/g719` = MimeType(\"audio/g719\")\n  val `audio/g722` = MimeType(\"audio/g722\")\n  val `audio/g7221` = MimeType(\"audio/g7221\")\n  val `audio/g723` = MimeType(\"audio/g723\")\n  val `audio/g726-16` = MimeType(\"audio/g726-16\")\n  val `audio/g726-24` = MimeType(\"audio/g726-24\")\n  val `audio/g726-32` = MimeType(\"audio/g726-32\")\n  val `audio/g726-40` = MimeType(\"audio/g726-40\")\n  val `audio/g728` = MimeType(\"audio/g728\")\n  val `audio/g729` = MimeType(\"audio/g729\")\n  val `audio/g7291` = MimeType(\"audio/g7291\")\n  val `audio/g729d` = MimeType(\"audio/g729d\")\n  val `audio/g729e` = MimeType(\"audio/g729e\")\n  val `audio/gsm` = MimeType(\"audio/gsm\")\n  val `audio/gsm-efr` = MimeType(\"audio/gsm-efr\")\n  val `audio/ilbc` = MimeType(\"audio/ilbc\")\n  val `audio/l16` = MimeType(\"audio/l16\")\n  val `audio/l20` = MimeType(\"audio/l20\")\n  val `audio/l24` = MimeType(\"audio/l24\")\n  val `audio/l8` = MimeType(\"audio/l8\")\n  val `audio/lpc` = MimeType(\"audio/lpc\")\n  val `audio/midi` = MimeType(\"audio/midi\", \"kar\", \"mid\", \"midi\", \"rmi\")\n  val `audio/mobile-xmf` = MimeType(\"audio/mobile-xmf\")\n  val `audio/mp4` = MimeType(\"audio/mp4\", \"mp4a\")\n  val `audio/mp4a-latm` = MimeType(\"audio/mp4a-latm\")\n  val `audio/mpa` = MimeType(\"audio/mpa\")\n  val `audio/mpa-robust` = MimeType(\"audio/mpa-robust\")\n  val `audio/mpeg` = MimeType(\"audio/mpeg\", \"m2a\", \"m3a\", \"m4a\", \"mp2\", \"mp2a\", \"mp3\", \"mpega\", \"mpga\")\n  val `audio/mpeg4-generic` = MimeType(\"audio/mpeg4-generic\")\n  val `audio/mpegurl` = MimeType(\"audio/mpegurl\", \"m3u\")\n  val `audio/ogg` = MimeType(\"audio/ogg\", \"oga\", \"ogg\", \"spx\")\n  val `audio/parityfec` = MimeType(\"audio/parityfec\")\n  val `audio/pcma` = MimeType(\"audio/pcma\")\n  val `audio/pcma-wb` = MimeType(\"audio/pcma-wb\")\n  val `audio/pcmu` = MimeType(\"audio/pcmu\")\n  val `audio/pcmu-wb` = MimeType(\"audio/pcmu-wb\")\n  val `audio/prs.sid` = MimeType(\"audio/prs.sid\", \"sid\")\n  val `audio/qcelp` = MimeType(\"audio/qcelp\")\n  val `audio/red` = MimeType(\"audio/red\")\n  val `audio/rtp-enc-aescm128` = MimeType(\"audio/rtp-enc-aescm128\")\n  val `audio/rtp-midi` = MimeType(\"audio/rtp-midi\")\n  val `audio/rtx` = MimeType(\"audio/rtx\")\n  val `audio/smv` = MimeType(\"audio/smv\")\n  val `audio/smv-qcp` = MimeType(\"audio/smv-qcp\")\n  val `audio/smv0` = MimeType(\"audio/smv0\")\n  val `audio/sp-midi` = MimeType(\"audio/sp-midi\")\n  val `audio/t140c` = MimeType(\"audio/t140c\")\n  val `audio/t38` = MimeType(\"audio/t38\")\n  val `audio/telephone-event` = MimeType(\"audio/telephone-event\")\n  val `audio/tone` = MimeType(\"audio/tone\")\n  val `audio/ulpfec` = MimeType(\"audio/ulpfec\")\n  val `audio/vdvi` = MimeType(\"audio/vdvi\")\n  val `audio/vmr-wb` = MimeType(\"audio/vmr-wb\")\n  val `audio/vnd.3gpp.iufp` = MimeType(\"audio/vnd.3gpp.iufp\")\n  val `audio/vnd.4sb` = MimeType(\"audio/vnd.4sb\")\n  val `audio/vnd.audiokoz` = MimeType(\"audio/vnd.audiokoz\")\n  val `audio/vnd.celp` = MimeType(\"audio/vnd.celp\")\n  val `audio/vnd.cisco.nse` = MimeType(\"audio/vnd.cisco.nse\")\n  val `audio/vnd.cmles.radio-events` = MimeType(\"audio/vnd.cmles.radio-events\")\n  val `audio/vnd.cns.anp1` = MimeType(\"audio/vnd.cns.anp1\")\n  val `audio/vnd.cns.inf1` = MimeType(\"audio/vnd.cns.inf1\")\n  val `audio/vnd.digital-winds` = MimeType(\"audio/vnd.digital-winds\", \"eol\")\n  val `audio/vnd.dlna.adts` = MimeType(\"audio/vnd.dlna.adts\")\n  val `audio/vnd.dolby.heaac.1` = MimeType(\"audio/vnd.dolby.heaac.1\")\n  val `audio/vnd.dolby.heaac.2` = MimeType(\"audio/vnd.dolby.heaac.2\")\n  val `audio/vnd.dolby.mlp` = MimeType(\"audio/vnd.dolby.mlp\")\n  val `audio/vnd.dolby.mps` = MimeType(\"audio/vnd.dolby.mps\")\n  val `audio/vnd.dolby.pl2` = MimeType(\"audio/vnd.dolby.pl2\")\n  val `audio/vnd.dolby.pl2x` = MimeType(\"audio/vnd.dolby.pl2x\")\n  val `audio/vnd.dolby.pl2z` = MimeType(\"audio/vnd.dolby.pl2z\")\n  val `audio/vnd.dts` = MimeType(\"audio/vnd.dts\", \"dts\")\n  val `audio/vnd.dts.hd` = MimeType(\"audio/vnd.dts.hd\", \"dtshd\")\n  val `audio/vnd.everad.plj` = MimeType(\"audio/vnd.everad.plj\")\n  val `audio/vnd.hns.audio` = MimeType(\"audio/vnd.hns.audio\")\n  val `audio/vnd.lucent.voice` = MimeType(\"audio/vnd.lucent.voice\", \"lvp\")\n  val `audio/vnd.ms-playready.media.pya` = MimeType(\"audio/vnd.ms-playready.media.pya\", \"pya\")\n  val `audio/vnd.nokia.mobile-xmf` = MimeType(\"audio/vnd.nokia.mobile-xmf\")\n  val `audio/vnd.nortel.vbk` = MimeType(\"audio/vnd.nortel.vbk\")\n  val `audio/vnd.nuera.ecelp4800` = MimeType(\"audio/vnd.nuera.ecelp4800\", \"ecelp4800\")\n  val `audio/vnd.nuera.ecelp7470` = MimeType(\"audio/vnd.nuera.ecelp7470\", \"ecelp7470\")\n  val `audio/vnd.nuera.ecelp9600` = MimeType(\"audio/vnd.nuera.ecelp9600\", \"ecelp9600\")\n  val `audio/vnd.octel.sbc` = MimeType(\"audio/vnd.octel.sbc\")\n  val `audio/vnd.qcelp` = MimeType(\"audio/vnd.qcelp\")\n  val `audio/vnd.rhetorex.32kadpcm` = MimeType(\"audio/vnd.rhetorex.32kadpcm\")\n  val `audio/vnd.sealedmedia.softseal.mpeg` = MimeType(\"audio/vnd.sealedmedia.softseal.mpeg\")\n  val `audio/vnd.vmx.cvsd` = MimeType(\"audio/vnd.vmx.cvsd\")\n  val `audio/vorbis` = MimeType(\"audio/vorbis\")\n  val `audio/vorbis-config` = MimeType(\"audio/vorbis-config\")\n  val `audio/x-aac` = MimeType(\"audio/x-aac\", \"aac\")\n  val `audio/x-aiff` = MimeType(\"audio/x-aiff\", \"aif\", \"aifc\", \"aiff\")\n  val `audio/x-gsm` = MimeType(\"audio/x-gsm\", \"gsm\")\n  val `audio/x-mpegurl` = MimeType(\"audio/x-mpegurl\", \"m3u\")\n  val `audio/x-ms-wax` = MimeType(\"audio/x-ms-wax\", \"wax\")\n  val `audio/x-ms-wma` = MimeType(\"audio/x-ms-wma\", \"wma\")\n  val `audio/x-pn-realaudio` = MimeType(\"audio/x-pn-realaudio\", \"ra\", \"ram\", \"rm\")\n  val `audio/x-pn-realaudio-plugin` = MimeType(\"audio/x-pn-realaudio-plugin\", \"rmp\")\n  val `audio/x-realaudio` = MimeType(\"audio/x-realaudio\", \"ra\")\n  val `audio/x-scpls` = MimeType(\"audio/x-scpls\", \"pls\")\n  val `audio/x-sd2` = MimeType(\"audio/x-sd2\", \"sd2\")\n  val `audio/x-wav` = MimeType(\"audio/x-wav\", \"wav\")\n  val `chemical/x-alchemy` = MimeType(\"chemical/x-alchemy\", \"alc\")\n  val `chemical/x-cache` = MimeType(\"chemical/x-cache\", \"cac\", \"cache\")\n  val `chemical/x-cache-csf` = MimeType(\"chemical/x-cache-csf\", \"csf\")\n  val `chemical/x-cactvs-binary` = MimeType(\"chemical/x-cactvs-binary\", \"cascii\", \"cbin\", \"ctab\")\n  val `chemical/x-cdx` = MimeType(\"chemical/x-cdx\", \"cdx\")\n  val `chemical/x-cerius` = MimeType(\"chemical/x-cerius\", \"cer\")\n  val `chemical/x-chem3d` = MimeType(\"chemical/x-chem3d\", \"c3d\")\n  val `chemical/x-chemdraw` = MimeType(\"chemical/x-chemdraw\", \"chm\")\n  val `chemical/x-cif` = MimeType(\"chemical/x-cif\", \"cif\")\n  val `chemical/x-cmdf` = MimeType(\"chemical/x-cmdf\", \"cmdf\")\n  val `chemical/x-cml` = MimeType(\"chemical/x-cml\", \"cml\")\n  val `chemical/x-compass` = MimeType(\"chemical/x-compass\", \"cpa\")\n  val `chemical/x-crossfire` = MimeType(\"chemical/x-crossfire\", \"bsd\")\n  val `chemical/x-csml` = MimeType(\"chemical/x-csml\", \"csm\", \"csml\")\n  val `chemical/x-ctx` = MimeType(\"chemical/x-ctx\", \"ctx\")\n  val `chemical/x-cxf` = MimeType(\"chemical/x-cxf\", \"cef\", \"cxf\")\n  val `chemical/x-embl-dl-nucleotide` = MimeType(\"chemical/x-embl-dl-nucleotide\", \"emb\", \"embl\")\n  val `chemical/x-galactic-spc` = MimeType(\"chemical/x-galactic-spc\", \"spc\")\n  val `chemical/x-gamess-input` = MimeType(\"chemical/x-gamess-input\", \"gam\", \"gamin\", \"inp\")\n  val `chemical/x-gaussian-checkpoint` = MimeType(\"chemical/x-gaussian-checkpoint\", \"fch\", \"fchk\")\n  val `chemical/x-gaussian-cube` = MimeType(\"chemical/x-gaussian-cube\", \"cub\")\n  val `chemical/x-gaussian-input` = MimeType(\"chemical/x-gaussian-input\", \"gau\", \"gjc\", \"gjf\")\n  val `chemical/x-gaussian-log` = MimeType(\"chemical/x-gaussian-log\", \"gal\")\n  val `chemical/x-gcg8-sequence` = MimeType(\"chemical/x-gcg8-sequence\", \"gcg\")\n  val `chemical/x-genbank` = MimeType(\"chemical/x-genbank\", \"gen\")\n  val `chemical/x-hin` = MimeType(\"chemical/x-hin\", \"hin\")\n  val `chemical/x-isostar` = MimeType(\"chemical/x-isostar\", \"ist\", \"istr\")\n  val `chemical/x-jcamp-dx` = MimeType(\"chemical/x-jcamp-dx\", \"dx\", \"jdx\")\n  val `chemical/x-kinemage` = MimeType(\"chemical/x-kinemage\", \"kin\")\n  val `chemical/x-macmolecule` = MimeType(\"chemical/x-macmolecule\", \"mcm\")\n  val `chemical/x-macromodel-input` = MimeType(\"chemical/x-macromodel-input\", \"mmd\", \"mmod\")\n  val `chemical/x-mdl-molfile` = MimeType(\"chemical/x-mdl-molfile\", \"mol\")\n  val `chemical/x-mdl-rdfile` = MimeType(\"chemical/x-mdl-rdfile\", \"rd\")\n  val `chemical/x-mdl-rxnfile` = MimeType(\"chemical/x-mdl-rxnfile\", \"rxn\")\n  val `chemical/x-mdl-sdfile` = MimeType(\"chemical/x-mdl-sdfile\", \"sd\", \"sdf\")\n  val `chemical/x-mdl-tgf` = MimeType(\"chemical/x-mdl-tgf\", \"tgf\")\n  val `chemical/x-mmcif` = MimeType(\"chemical/x-mmcif\", \"mcif\")\n  val `chemical/x-mol2` = MimeType(\"chemical/x-mol2\", \"mol2\")\n  val `chemical/x-molconn-Z` = MimeType(\"chemical/x-molconn-Z\", \"b\")\n  val `chemical/x-mopac-graph` = MimeType(\"chemical/x-mopac-graph\", \"gpt\")\n  val `chemical/x-mopac-input` = MimeType(\"chemical/x-mopac-input\", \"dat\", \"mop\", \"mopcrt\", \"mpc\", \"zmt\")\n  val `chemical/x-mopac-out` = MimeType(\"chemical/x-mopac-out\", \"moo\")\n  val `chemical/x-mopac-vib` = MimeType(\"chemical/x-mopac-vib\", \"mvb\")\n  val `chemical/x-ncbi-asn1` = MimeType(\"chemical/x-ncbi-asn1\", \"asn\")\n  val `chemical/x-ncbi-asn1-ascii` = MimeType(\"chemical/x-ncbi-asn1-ascii\", \"ent\", \"prt\")\n  val `chemical/x-ncbi-asn1-binary` = MimeType(\"chemical/x-ncbi-asn1-binary\", \"aso\", \"val\")\n  val `chemical/x-ncbi-asn1-spec` = MimeType(\"chemical/x-ncbi-asn1-spec\", \"asn\")\n  val `chemical/x-pdb` = MimeType(\"chemical/x-pdb\", \"ent\", \"pdb\")\n  val `chemical/x-rosdal` = MimeType(\"chemical/x-rosdal\", \"ros\")\n  val `chemical/x-swissprot` = MimeType(\"chemical/x-swissprot\", \"sw\")\n  val `chemical/x-vamas-iso14976` = MimeType(\"chemical/x-vamas-iso14976\", \"vms\")\n  val `chemical/x-vmd` = MimeType(\"chemical/x-vmd\", \"vmd\")\n  val `chemical/x-xtel` = MimeType(\"chemical/x-xtel\", \"xtel\")\n  val `chemical/x-xyz` = MimeType(\"chemical/x-xyz\", \"xyz\")\n  val `image/bmp` = MimeType(\"image/bmp\", \"bmp\")\n  val `image/cgm` = MimeType(\"image/cgm\", \"cgm\")\n  val `image/example` = MimeType(\"image/example\")\n  val `image/fits` = MimeType(\"image/fits\")\n  val `image/g3fax` = MimeType(\"image/g3fax\", \"g3\")\n  val `image/gif` = MimeType(\"image/gif\", \"gif\")\n  val `image/ief` = MimeType(\"image/ief\", \"ief\")\n  val `image/jp2` = MimeType(\"image/jp2\")\n  val `image/jpeg` = MimeType(\"image/jpeg\", \"jpe\", \"jpeg\", \"jpg\")\n  val `image/jpm` = MimeType(\"image/jpm\")\n  val `image/jpx` = MimeType(\"image/jpx\")\n  val `image/naplps` = MimeType(\"image/naplps\")\n  val `image/pcx` = MimeType(\"image/pcx\", \"pcx\")\n  val `image/png` = MimeType(\"image/png\", \"png\")\n  val `image/prs.btif` = MimeType(\"image/prs.btif\", \"btif\")\n  val `image/prs.pti` = MimeType(\"image/prs.pti\")\n  val `image/svg+xml` = MimeType(\"image/svg+xml\", \"svg\", \"svgz\")\n  val `image/t38` = MimeType(\"image/t38\")\n  val `image/tiff` = MimeType(\"image/tiff\", \"tif\", \"tiff\")\n  val `image/tiff-fx` = MimeType(\"image/tiff-fx\")\n  val `image/vnd.adobe.photoshop` = MimeType(\"image/vnd.adobe.photoshop\", \"psd\")\n  val `image/vnd.cns.inf2` = MimeType(\"image/vnd.cns.inf2\")\n  val `image/vnd.djvu` = MimeType(\"image/vnd.djvu\", \"djv\", \"djvu\")\n  val `image/vnd.dwg` = MimeType(\"image/vnd.dwg\", \"dwg\")\n  val `image/vnd.dxf` = MimeType(\"image/vnd.dxf\", \"dxf\")\n  val `image/vnd.fastbidsheet` = MimeType(\"image/vnd.fastbidsheet\", \"fbs\")\n  val `image/vnd.fpx` = MimeType(\"image/vnd.fpx\", \"fpx\")\n  val `image/vnd.fst` = MimeType(\"image/vnd.fst\", \"fst\")\n  val `image/vnd.fujixerox.edmics-mmr` = MimeType(\"image/vnd.fujixerox.edmics-mmr\", \"mmr\")\n  val `image/vnd.fujixerox.edmics-rlc` = MimeType(\"image/vnd.fujixerox.edmics-rlc\", \"rlc\")\n  val `image/vnd.globalgraphics.pgb` = MimeType(\"image/vnd.globalgraphics.pgb\")\n  val `image/vnd.microsoft.icon` = MimeType(\"image/vnd.microsoft.icon\")\n  val `image/vnd.mix` = MimeType(\"image/vnd.mix\")\n  val `image/vnd.ms-modi` = MimeType(\"image/vnd.ms-modi\", \"mdi\")\n  val `image/vnd.net-fpx` = MimeType(\"image/vnd.net-fpx\", \"npx\")\n  val `image/vnd.radiance` = MimeType(\"image/vnd.radiance\")\n  val `image/vnd.sealed.png` = MimeType(\"image/vnd.sealed.png\")\n  val `image/vnd.sealedmedia.softseal.gif` = MimeType(\"image/vnd.sealedmedia.softseal.gif\")\n  val `image/vnd.sealedmedia.softseal.jpg` = MimeType(\"image/vnd.sealedmedia.softseal.jpg\")\n  val `image/vnd.svf` = MimeType(\"image/vnd.svf\")\n  val `image/vnd.wap.wbmp` = MimeType(\"image/vnd.wap.wbmp\", \"wbmp\")\n  val `image/vnd.xiff` = MimeType(\"image/vnd.xiff\", \"xif\")\n  val `image/x-cmu-raster` = MimeType(\"image/x-cmu-raster\", \"ras\")\n  val `image/x-cmx` = MimeType(\"image/x-cmx\", \"cmx\")\n  val `image/x-coreldraw` = MimeType(\"image/x-coreldraw\", \"cdr\")\n  val `image/x-coreldrawpattern` = MimeType(\"image/x-coreldrawpattern\", \"pat\")\n  val `image/x-coreldrawtemplate` = MimeType(\"image/x-coreldrawtemplate\", \"cdt\")\n  val `image/x-corelphotopaint` = MimeType(\"image/x-corelphotopaint\", \"cpt\")\n  val `image/x-freehand` = MimeType(\"image/x-freehand\", \"fh\", \"fh4\", \"fh5\", \"fh7\", \"fhc\")\n  val `image/x-icon` = MimeType(\"image/x-icon\", \"ico\")\n  val `image/x-jg` = MimeType(\"image/x-jg\", \"art\")\n  val `image/x-jng` = MimeType(\"image/x-jng\", \"jng\")\n  val `image/x-ms-bmp` = MimeType(\"image/x-ms-bmp\", \"bmp\")\n  val `image/x-pcx` = MimeType(\"image/x-pcx\", \"pcx\")\n  val `image/x-photoshop` = MimeType(\"image/x-photoshop\", \"psd\")\n  val `image/x-pict` = MimeType(\"image/x-pict\", \"pct\", \"pic\")\n  val `image/x-portable-anymap` = MimeType(\"image/x-portable-anymap\", \"pnm\")\n  val `image/x-portable-bitmap` = MimeType(\"image/x-portable-bitmap\", \"pbm\")\n  val `image/x-portable-graymap` = MimeType(\"image/x-portable-graymap\", \"pgm\")\n  val `image/x-portable-pixmap` = MimeType(\"image/x-portable-pixmap\", \"ppm\")\n  val `image/x-rgb` = MimeType(\"image/x-rgb\", \"rgb\")\n  val `image/x-xbitmap` = MimeType(\"image/x-xbitmap\", \"xbm\")\n  val `image/x-xpixmap` = MimeType(\"image/x-xpixmap\", \"xpm\")\n  val `image/x-xwindowdump` = MimeType(\"image/x-xwindowdump\", \"xwd\")\n  val `message/cpim` = MimeType(\"message/cpim\")\n  val `message/delivery-status` = MimeType(\"message/delivery-status\")\n  val `message/disposition-notification` = MimeType(\"message/disposition-notification\")\n  val `message/example` = MimeType(\"message/example\")\n  val `message/external-body` = MimeType(\"message/external-body\")\n  val `message/global` = MimeType(\"message/global\")\n  val `message/global-delivery-status` = MimeType(\"message/global-delivery-status\")\n  val `message/global-disposition-notification` = MimeType(\"message/global-disposition-notification\")\n  val `message/global-headers` = MimeType(\"message/global-headers\")\n  val `message/http` = MimeType(\"message/http\")\n  val `message/imdn+xml` = MimeType(\"message/imdn+xml\")\n  val `message/news` = MimeType(\"message/news\")\n  val `message/partial` = MimeType(\"message/partial\")\n  val `message/rfc822` = MimeType(\"message/rfc822\", \"eml\", \"mime\")\n  val `message/s-http` = MimeType(\"message/s-http\")\n  val `message/sip` = MimeType(\"message/sip\")\n  val `message/sipfrag` = MimeType(\"message/sipfrag\")\n  val `message/tracking-status` = MimeType(\"message/tracking-status\")\n  val `message/vnd.si.simp` = MimeType(\"message/vnd.si.simp\")\n  val `model/example` = MimeType(\"model/example\")\n  val `model/iges` = MimeType(\"model/iges\", \"iges\", \"igs\")\n  val `model/mesh` = MimeType(\"model/mesh\", \"mesh\", \"msh\", \"silo\")\n  val `model/vnd.dwf` = MimeType(\"model/vnd.dwf\", \"dwf\")\n  val `model/vnd.flatland.3dml` = MimeType(\"model/vnd.flatland.3dml\")\n  val `model/vnd.gdl` = MimeType(\"model/vnd.gdl\", \"gdl\")\n  val `model/vnd.gs-gdl` = MimeType(\"model/vnd.gs-gdl\")\n  val `model/vnd.gs.gdl` = MimeType(\"model/vnd.gs.gdl\")\n  val `model/vnd.gtw` = MimeType(\"model/vnd.gtw\", \"gtw\")\n  val `model/vnd.moml+xml` = MimeType(\"model/vnd.moml+xml\")\n  val `model/vnd.mts` = MimeType(\"model/vnd.mts\", \"mts\")\n  val `model/vnd.parasolid.transmit.binary` = MimeType(\"model/vnd.parasolid.transmit.binary\")\n  val `model/vnd.parasolid.transmit.text` = MimeType(\"model/vnd.parasolid.transmit.text\")\n  val `model/vnd.vtu` = MimeType(\"model/vnd.vtu\", \"vtu\")\n  val `model/vrml` = MimeType(\"model/vrml\", \"vrml\", \"wrl\")\n  val `multipart/alternative` = MimeType(\"multipart/alternative\")\n  val `multipart/appledouble` = MimeType(\"multipart/appledouble\")\n  val `multipart/byteranges` = MimeType(\"multipart/byteranges\")\n  val `multipart/digest` = MimeType(\"multipart/digest\")\n  val `multipart/encrypted` = MimeType(\"multipart/encrypted\")\n  val `multipart/example` = MimeType(\"multipart/example\")\n  val `multipart/form-data` = MimeType(\"multipart/form-data\")\n  val `multipart/header-set` = MimeType(\"multipart/header-set\")\n  val `multipart/mixed` = MimeType(\"multipart/mixed\")\n  val `multipart/parallel` = MimeType(\"multipart/parallel\")\n  val `multipart/related` = MimeType(\"multipart/related\")\n  val `multipart/report` = MimeType(\"multipart/report\")\n  val `multipart/signed` = MimeType(\"multipart/signed\")\n  val `multipart/voice-message` = MimeType(\"multipart/voice-message\")\n  val `text/calendar` = MimeType(\"text/calendar\", \"ics\", \"icz\", \"ifb\")\n  val `text/comma-separated-values` = MimeType(\"text/comma-separated-values\", \"csv\")\n  val `text/css` = MimeType(\"text/css\", \"css\")\n  val `text/csv` = MimeType(\"text/csv\", \"csv\")\n  val `text/directory` = MimeType(\"text/directory\")\n  val `text/dns` = MimeType(\"text/dns\")\n  val `text/ecmascript` = MimeType(\"text/ecmascript\")\n  val `text/enriched` = MimeType(\"text/enriched\")\n  val `text/example` = MimeType(\"text/example\")\n  val `text/h323` = MimeType(\"text/h323\", \"323\")\n  val `text/html` = MimeType(\"text/html\", \"htm\", \"html\", \"shtml\")\n  val `text/iuls` = MimeType(\"text/iuls\", \"uls\")\n  val `text/javascript` = MimeType(\"text/javascript\")\n  val `text/mathml` = MimeType(\"text/mathml\", \"mml\")\n  val `text/parityfec` = MimeType(\"text/parityfec\")\n  val `text/prs.fallenstein.rst` = MimeType(\"text/prs.fallenstein.rst\")\n  val `text/prs.lines.tag` = MimeType(\"text/prs.lines.tag\", \"dsc\")\n  val `text/red` = MimeType(\"text/red\")\n  val `text/rfc822-headers` = MimeType(\"text/rfc822-headers\")\n  val `text/richtext` = MimeType(\"text/richtext\", \"rtx\")\n  val `text/rtf` = MimeType(\"text/rtf\", \"rtf\")\n  val `text/rtp-enc-aescm128` = MimeType(\"text/rtp-enc-aescm128\")\n  val `text/rtx` = MimeType(\"text/rtx\")\n  val `text/scriptlet` = MimeType(\"text/scriptlet\", \"sct\", \"wsc\")\n  val `text/sgml` = MimeType(\"text/sgml\", \"sgm\", \"sgml\")\n  val `text/t140` = MimeType(\"text/t140\")\n  val `text/tab-separated-values` = MimeType(\"text/tab-separated-values\", \"tsv\")\n  val `text/texmacs` = MimeType(\"text/texmacs\", \"tm\", \"ts\")\n  val `text/troff` = MimeType(\"text/troff\", \"man\", \"me\", \"ms\", \"roff\", \"t\", \"tr\")\n  val `text/ulpfec` = MimeType(\"text/ulpfec\")\n  val `text/uri-list` = MimeType(\"text/uri-list\", \"uri\", \"uris\", \"urls\")\n  val `text/vnd.abc` = MimeType(\"text/vnd.abc\")\n  val `text/vnd.curl` = MimeType(\"text/vnd.curl\", \"curl\")\n  val `text/vnd.curl.dcurl` = MimeType(\"text/vnd.curl.dcurl\", \"dcurl\")\n  val `text/vnd.curl.mcurl` = MimeType(\"text/vnd.curl.mcurl\", \"mcurl\")\n  val `text/vnd.curl.scurl` = MimeType(\"text/vnd.curl.scurl\", \"scurl\")\n  val `text/vnd.dmclientscript` = MimeType(\"text/vnd.dmclientscript\")\n  val `text/vnd.esmertec.theme-descriptor` = MimeType(\"text/vnd.esmertec.theme-descriptor\")\n  val `text/vnd.fly` = MimeType(\"text/vnd.fly\", \"fly\")\n  val `text/vnd.fmi.flexstor` = MimeType(\"text/vnd.fmi.flexstor\", \"flx\")\n  val `text/vnd.graphviz` = MimeType(\"text/vnd.graphviz\", \"gv\")\n  val `text/vnd.in3d.3dml` = MimeType(\"text/vnd.in3d.3dml\", \"3dml\")\n  val `text/vnd.in3d.spot` = MimeType(\"text/vnd.in3d.spot\", \"spot\")\n  val `text/vnd.iptc.newsml` = MimeType(\"text/vnd.iptc.newsml\")\n  val `text/vnd.iptc.nitf` = MimeType(\"text/vnd.iptc.nitf\")\n  val `text/vnd.latex-z` = MimeType(\"text/vnd.latex-z\")\n  val `text/vnd.motorola.reflex` = MimeType(\"text/vnd.motorola.reflex\")\n  val `text/vnd.ms-mediapackage` = MimeType(\"text/vnd.ms-mediapackage\")\n  val `text/vnd.net2phone.commcenter.command` = MimeType(\"text/vnd.net2phone.commcenter.command\")\n  val `text/vnd.si.uricatalogue` = MimeType(\"text/vnd.si.uricatalogue\")\n  val `text/vnd.sun.j2me.app-descriptor` = MimeType(\"text/vnd.sun.j2me.app-descriptor\", \"jad\")\n  val `text/vnd.trolltech.linguist` = MimeType(\"text/vnd.trolltech.linguist\")\n  val `text/vnd.wap.si` = MimeType(\"text/vnd.wap.si\")\n  val `text/vnd.wap.sl` = MimeType(\"text/vnd.wap.sl\")\n  val `text/vnd.wap.wml` = MimeType(\"text/vnd.wap.wml\", \"wml\")\n  val `text/vnd.wap.wmlscript` = MimeType(\"text/vnd.wap.wmlscript\", \"wmls\")\n  val `text/x-asm` = MimeType(\"text/x-asm\", \"asm\", \"s\")\n  val `text/x-bibtex` = MimeType(\"text/x-bibtex\", \"bib\")\n  val `text/x-c` = MimeType(\"text/x-c\", \"c\", \"cc\", \"cpp\", \"cxx\", \"dic\", \"h\", \"hh\")\n  val `text/x-c++hdr` = MimeType(\"text/x-c++hdr\", \"h\", \"++\", \"hh\", \"hpp\", \"hxx\")\n  val `text/x-c++src` = MimeType(\"text/x-c++src\", \"c\", \"++\", \"cc\", \"cpp\", \"cxx\")\n  val `text/x-chdr` = MimeType(\"text/x-chdr\", \"h\")\n  val `text/x-csh` = MimeType(\"text/x-csh\", \"csh\")\n  val `text/x-csrc` = MimeType(\"text/x-csrc\", \"c\")\n  val `text/x-fortran` = MimeType(\"text/x-fortran\", \"f\", \"f77\", \"f90\", \"for\")\n  val `text/x-haskell` = MimeType(\"text/x-haskell\", \"hs\")\n  val `text/x-java` = MimeType(\"text/x-java\", \"java\")\n  val `text/x-java-source` = MimeType(\"text/x-java-source\", \"java\")\n  val `text/x-literate-haskell` = MimeType(\"text/x-literate-haskell\", \"lhs\")\n  val `text/x-moc` = MimeType(\"text/x-moc\", \"moc\")\n  val `text/x-pascal` = MimeType(\"text/x-pascal\", \"p\", \"pas\")\n  val `text/x-pcs-gcd` = MimeType(\"text/x-pcs-gcd\", \"gcd\")\n  val `text/x-perl` = MimeType(\"text/x-perl\", \"pl\", \"pm\")\n  val `text/x-psp` = MimeType(\"text/x-psp\", \"psp\")\n  val `text/x-python` = MimeType(\"text/x-python\", \"py\")\n  val `text/x-setext` = MimeType(\"text/x-setext\", \"etx\")\n  val `text/x-sh` = MimeType(\"text/x-sh\", \"sh\")\n  val `text/x-tcl` = MimeType(\"text/x-tcl\", \"tcl\", \"tk\")\n  val `text/x-tex` = MimeType(\"text/x-tex\", \"cls\", \"ltx\", \"sty\", \"tex\")\n  val `text/x-uuencode` = MimeType(\"text/x-uuencode\", \"uu\")\n  val `text/x-vcalendar` = MimeType(\"text/x-vcalendar\", \"vcs\")\n  val `text/x-vcard` = MimeType(\"text/x-vcard\", \"vcf\")\n  val `text/xml` = MimeType(\"text/xml\")\n  val `text/xml-external-parsed-entity` = MimeType(\"text/xml-external-parsed-entity\")\n  val `video/3gpp` = MimeType(\"video/3gpp\", \"3gp\")\n  val `video/3gpp-tt` = MimeType(\"video/3gpp-tt\")\n  val `video/3gpp2` = MimeType(\"video/3gpp2\", \"3g2\")\n  val `video/bmpeg` = MimeType(\"video/bmpeg\")\n  val `video/bt656` = MimeType(\"video/bt656\")\n  val `video/celb` = MimeType(\"video/celb\")\n  val `video/dl` = MimeType(\"video/dl\", \"dl\")\n  val `video/dv` = MimeType(\"video/dv\", \"dif\", \"dv\")\n  val `video/example` = MimeType(\"video/example\")\n  val `video/fli` = MimeType(\"video/fli\", \"fli\")\n  val `video/gl` = MimeType(\"video/gl\", \"gl\")\n  val `video/h261` = MimeType(\"video/h261\", \"h261\")\n  val `video/h263` = MimeType(\"video/h263\", \"h263\")\n  val `video/h263-1998` = MimeType(\"video/h263-1998\")\n  val `video/h263-2000` = MimeType(\"video/h263-2000\")\n  val `video/h264` = MimeType(\"video/h264\", \"h264\")\n  val `video/jpeg` = MimeType(\"video/jpeg\", \"jpgv\")\n  val `video/jpeg2000` = MimeType(\"video/jpeg2000\")\n  val `video/jpm` = MimeType(\"video/jpm\", \"jpgm\", \"jpm\")\n  val `video/mj2` = MimeType(\"video/mj2\", \"mj2\", \"mjp2\")\n  val `video/mp1s` = MimeType(\"video/mp1s\")\n  val `video/mp2p` = MimeType(\"video/mp2p\")\n  val `video/mp2t` = MimeType(\"video/mp2t\")\n  val `video/mp4` = MimeType(\"video/mp4\", \"mp4\", \"mp4v\", \"mpg4\")\n  val `video/mp4v-es` = MimeType(\"video/mp4v-es\")\n  val `video/mpeg` = MimeType(\"video/mpeg\", \"m1v\", \"m2v\", \"mpe\", \"mpeg\", \"mpg\")\n  val `video/mpeg4-generic` = MimeType(\"video/mpeg4-generic\")\n  val `video/mpv` = MimeType(\"video/mpv\")\n  val `video/nv` = MimeType(\"video/nv\")\n  val `video/ogg` = MimeType(\"video/ogg\", \"ogv\")\n  val `video/parityfec` = MimeType(\"video/parityfec\")\n  val `video/pointer` = MimeType(\"video/pointer\")\n  val `video/quicktime` = MimeType(\"video/quicktime\", \"mov\", \"qt\")\n  val `video/raw` = MimeType(\"video/raw\")\n  val `video/rtp-enc-aescm128` = MimeType(\"video/rtp-enc-aescm128\")\n  val `video/rtx` = MimeType(\"video/rtx\")\n  val `video/smpte292m` = MimeType(\"video/smpte292m\")\n  val `video/ulpfec` = MimeType(\"video/ulpfec\")\n  val `video/vc1` = MimeType(\"video/vc1\")\n  val `video/vnd.cctv` = MimeType(\"video/vnd.cctv\")\n  val `video/vnd.dlna.mpeg-tts` = MimeType(\"video/vnd.dlna.mpeg-tts\")\n  val `video/vnd.fvt` = MimeType(\"video/vnd.fvt\", \"fvt\")\n  val `video/vnd.hns.video` = MimeType(\"video/vnd.hns.video\")\n  val `video/vnd.iptvforum.1dparityfec-1010` = MimeType(\"video/vnd.iptvforum.1dparityfec-1010\")\n  val `video/vnd.iptvforum.1dparityfec-2005` = MimeType(\"video/vnd.iptvforum.1dparityfec-2005\")\n  val `video/vnd.iptvforum.2dparityfec-1010` = MimeType(\"video/vnd.iptvforum.2dparityfec-1010\")\n  val `video/vnd.iptvforum.2dparityfec-2005` = MimeType(\"video/vnd.iptvforum.2dparityfec-2005\")\n  val `video/vnd.iptvforum.ttsavc` = MimeType(\"video/vnd.iptvforum.ttsavc\")\n  val `video/vnd.iptvforum.ttsmpeg2` = MimeType(\"video/vnd.iptvforum.ttsmpeg2\")\n  val `video/vnd.motorola.video` = MimeType(\"video/vnd.motorola.video\")\n  val `video/vnd.motorola.videop` = MimeType(\"video/vnd.motorola.videop\")\n  val `video/vnd.mpegurl` = MimeType(\"video/vnd.mpegurl\", \"m4u\", \"mxu\")\n  val `video/vnd.ms-playready.media.pyv` = MimeType(\"video/vnd.ms-playready.media.pyv\", \"pyv\")\n  val `video/vnd.nokia.interleaved-multimedia` = MimeType(\"video/vnd.nokia.interleaved-multimedia\")\n  val `video/vnd.nokia.videovoip` = MimeType(\"video/vnd.nokia.videovoip\")\n  val `video/vnd.objectvideo` = MimeType(\"video/vnd.objectvideo\")\n  val `video/vnd.sealed.mpeg1` = MimeType(\"video/vnd.sealed.mpeg1\")\n  val `video/vnd.sealed.mpeg4` = MimeType(\"video/vnd.sealed.mpeg4\")\n  val `video/vnd.sealed.swf` = MimeType(\"video/vnd.sealed.swf\")\n  val `video/vnd.sealedmedia.softseal.mov` = MimeType(\"video/vnd.sealedmedia.softseal.mov\")\n  val `video/vnd.vivo` = MimeType(\"video/vnd.vivo\", \"viv\")\n  val `video/x-f4v` = MimeType(\"video/x-f4v\", \"f4v\")\n  val `video/x-fli` = MimeType(\"video/x-fli\", \"fli\")\n  val `video/x-flv` = MimeType(\"video/x-flv\", \"flv\")\n  val `video/x-la-asf` = MimeType(\"video/x-la-asf\", \"lsf\", \"lsx\")\n  val `video/x-m4v` = MimeType(\"video/x-m4v\", \"m4v\")\n  val `video/x-mng` = MimeType(\"video/x-mng\", \"mng\")\n  val `video/x-ms-asf` = MimeType(\"video/x-ms-asf\", \"asf\", \"asx\")\n  val `video/x-ms-wm` = MimeType(\"video/x-ms-wm\", \"wm\")\n  val `video/x-ms-wmv` = MimeType(\"video/x-ms-wmv\", \"wmv\")\n  val `video/x-ms-wmx` = MimeType(\"video/x-ms-wmx\", \"wmx\")\n  val `video/x-ms-wvx` = MimeType(\"video/x-ms-wvx\", \"wvx\")\n  val `video/x-msvideo` = MimeType(\"video/x-msvideo\", \"avi\")\n  val `video/x-sgi-movie` = MimeType(\"video/x-sgi-movie\", \"movie\")\n  val `x-conference/x-cooltalk` = MimeType(\"x-conference/x-cooltalk\", \"ice\")\n  val `x-world/x-vrml` = MimeType(\"x-world/x-vrml\", \"vrm\", \"vrml\", \"wrl\")\n\n  val mimeTypesMap = new javax.activation.MimetypesFileTypeMap()\n\n  types.values foreach { t =>\n    mimeTypesMap.addMimeTypes(t.name + \" \" + t.extensions.mkString(\" \"))\n  }\n}\n"
  },
  {
    "path": "net/shared/src/main/scala/rapture/net/browser.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.net\nimport rapture.core._\nimport rapture.io._\nimport rapture.uri._\n\nimport java.text.SimpleDateFormat\nimport java.util.Locale\n\nimport scala.collection.mutable\n\ncase class Cookie[I, D](domain: String,\n                        name: String,\n                        value: String,\n                        path: RootedPath,\n                        expiry: Option[I],\n                        secure: Boolean)(implicit ts: TimeSystem[I, D]) {\n  lazy val pathString = path.toString\n}\n\nclass Browser[I: TimeSystem.ByInstant]() {\n  val browserString = \"Rapture Browser 2.0.0\"\n  private val Rfc1036Pattern = \"EEE, dd-MMM-yyyy HH:mm:ss zzz\"\n\n  val ts = ?[TimeSystem.ByInstant[I]]\n\n  val cookies: mutable.HashMap[(String, String, RootedPath), Cookie[I, _]] =\n    new mutable.HashMap[(String, String, RootedPath), Cookie[I, _]]\n\n  def parseCookie(s: String, domain: String): Cookie[I, _] = {\n    val ps = s.split(\";\").map(_.trim.split(\"=\")) map { a =>\n      a(0) -> (if (a.length > 1) a(1).urlDecode else \"\")\n    }\n    val details = ps.tail.toMap\n\n    Cookie(details.getOrElse(\"domain\", domain),\n           ps.head._1,\n           ps.head._2,\n           RootedPath.parse(details.getOrElse(\"path\", \"\")).getOrElse(RootedPath(Vector())),\n           details.get(\"expires\") map { exp =>\n             ts.instant(new SimpleDateFormat(Rfc1036Pattern, Locale.US).parse(exp).getTime)\n           },\n           details.contains(\"secure\"))\n  }\n\n  def domainCookies(domain: String, secure: Boolean, path: String): String = {\n    val now = System.currentTimeMillis\n    cookies foreach { c =>\n      if (c._2.expiry.exists(e => ts.fromInstant(e) < now))\n        cookies.remove((c._2.domain, c._2.name, c._2.path))\n    }\n\n    cookies.toList\n      .filter(secure || !_._2.secure)\n      .filter(domain endsWith\n            _._2.domain)\n      .filter(path startsWith _._2.pathString)\n      .map(_._2)\n      .groupBy(_.name) map { c =>\n      c._1 + \"=\" + c._2.maxBy(_.pathString.length).value.urlEncode\n    } mkString \"; \"\n  }\n\n  def accept[I2, D](c: Cookie[I2, D]): Boolean = c.domain.split(\"\\\\.\").length > 1\n\n  /*class BrowserUrl(url: HttpUrl) {\n\n    def httpGet[D]()(implicit httpTimeout: HttpTimeout, httpCertificateConfig: HttpCertificateConfig,\n        httpRedirectConfig: HttpRedirectConfig) = url.httpGet()\n    \n    def httpPost[C: PostType, D](\n      content: C,\n      headers: Map[String, String] = Map())\n    (implicit mode: Mode[`BrowserUrl#httpPost`], httpTimeout: HttpTimeout, httpCertificateConfig: HttpCertificateConfig, httpRedirectConfig: HttpRedirectConfig, httpBasicAuthentication: HttpBasicAuthentication): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode.wrap {\n        implicit val m = mode.generic\n        // FIXME: Reimplement this with recursion\n        var u = url\n        var retries = 0\n        var response: HttpResponse = null\n\n        do {\n          response = mode.unwrap(u.httpPost[C, D](content, headers + (\"Cookie\" -> domainCookies(u.hostname, u.ssl, u.pathString))))\n\n          val newCookies = response.headers.get(\"Set-Cookie\").getOrElse(Nil) map { c =>\n            parseCookie(c, u.hostname)\n          } filter { c: Cookie[I, _] => accept(c) }\n        \n          for(c <- newCookies) cookies((c.domain, c.name, c.path)) = c\n\n          if(response.status/100 == 3) {\n            retries += 1\n            if(retries > 5) throw TooManyRedirects()\n            val dest = response.headers(\"Location\").headOption.getOrElse(throw BadHttpResponse())\n\n            u = if(dest.startsWith(\"http\")) Http.parse(dest)\n                else if(dest.startsWith(\"/\")) Http / u.hostname / RootedPath.parse(dest)\n                // FIXME: This doesn't handle ascent in relative paths\n                else u / RootedPath.parse(dest)\n          }\n        } while(response.status/100 == 3)\n        \n        response\n    }\n  }\n\n  def apply(url: HttpUrl): BrowserUrl = new BrowserUrl(url)*/\n}\n"
  },
  {
    "path": "net/shared/src/main/scala/rapture/net/exceptions.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.net\n\nsealed trait HttpExceptions extends Exception\ncase class TooManyRedirects() extends HttpExceptions\ncase class BadHttpResponse() extends HttpExceptions\n"
  },
  {
    "path": "net/shared/src/main/scala/rapture/net/http.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.net\n\nimport rapture.io._\nimport rapture.uri._\nimport rapture.core._\n\nimport java.io._\nimport java.net._\nimport javax.net.ssl._\n\nobject HttpSupport {\n  class Capability[Res](res: Res) {\n    def httpPut[C: PostType](\n        content: C,\n        headers: Map[String, String] = Map()\n    )(\n        implicit httpSupport: HttpSupport[Res],\n        mode: Mode[`NetUrl#httpPut`],\n        httpTimeout: HttpTimeout,\n        httpRedirectConfig: HttpRedirectConfig,\n        httpCertificateConfig: HttpCertificateConfig,\n        httpBasicAuthentication: HttpBasicAuthentication\n    ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode.wrap(httpSupport.doHttp(res, content, headers, \"PUT\"))\n\n    def httpHead(\n        headers: Map[String, String] = Map()\n    )(\n        implicit httpSupport: HttpSupport[Res],\n        mode: Mode[`NetUrl#httpHead`],\n        httpTimeout: HttpTimeout,\n        httpRedirectConfig: HttpRedirectConfig,\n        httpCertificateConfig: HttpCertificateConfig,\n        httpBasicAuthentication: HttpBasicAuthentication\n    ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode.wrap(httpSupport.doHttp(res, None, headers, \"HEAD\"))\n\n    def httpGet(\n        headers: Map[String, String] = Map()\n    )(\n        implicit httpSupport: HttpSupport[Res],\n        mode: Mode[`NetUrl#httpHead`],\n        httpTimeout: HttpTimeout,\n        httpRedirectConfig: HttpRedirectConfig,\n        httpCertificateConfig: HttpCertificateConfig,\n        httpBasicAuthentication: HttpBasicAuthentication\n    ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode.wrap(httpSupport.doHttp(res, None, headers, \"GET\"))\n\n    def httpPost[C: PostType](\n        content: C,\n        headers: Map[String, String] = Map()\n    )(\n        implicit httpSupport: HttpSupport[Res],\n        mode: Mode[`NetUrl#httpPut`],\n        httpTimeout: HttpTimeout,\n        httpRedirectConfig: HttpRedirectConfig,\n        httpCertificateConfig: HttpCertificateConfig,\n        httpBasicAuthentication: HttpBasicAuthentication\n    ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode.wrap(httpSupport.doHttp(res, content, headers, \"POST\"))\n\n    def httpDelete(\n        headers: Map[String, String] = Map()\n    )(\n        implicit httpSupport: HttpSupport[Res],\n        mode: Mode[`NetUrl#httpPut`],\n        httpTimeout: HttpTimeout,\n        httpRedirectConfig: HttpRedirectConfig,\n        httpCertificateConfig: HttpCertificateConfig,\n        httpBasicAuthentication: HttpBasicAuthentication\n    ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode.wrap(httpSupport.doHttp(res, None, headers, \"DELETE\"))\n\n    def httpOptions(\n        headers: Map[String, String] = Map()\n    )(\n        implicit httpSupport: HttpSupport[Res],\n        mode: Mode[`NetUrl#httpPut`],\n        httpTimeout: HttpTimeout,\n        httpRedirectConfig: HttpRedirectConfig,\n        httpCertificateConfig: HttpCertificateConfig,\n        httpBasicAuthentication: HttpBasicAuthentication\n    ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode.wrap(httpSupport.doHttp(res, None, headers, \"OPTIONS\"))\n\n    def httpTrace(\n        headers: Map[String, String] = Map()\n    )(\n        implicit httpSupport: HttpSupport[Res],\n        mode: Mode[`NetUrl#httpPut`],\n        httpTimeout: HttpTimeout,\n        httpRedirectConfig: HttpRedirectConfig,\n        httpCertificateConfig: HttpCertificateConfig,\n        httpBasicAuthentication: HttpBasicAuthentication\n    ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode.wrap(httpSupport.doHttp(res, None, headers, \"TRACE\"))\n  }\n\n  implicit def basicHttpSupport[H: UriCapable]: HttpSupport[H] = new HttpSupport[H] {\n\n    def doHttp[C: PostType, T](\n        res: H,\n        content: C,\n        headers: Map[String, String],\n        method: String\n    )(\n        implicit mode: Mode[`NetUrl#httpPost`],\n        httpTimeout: HttpTimeout,\n        httpRedirectConfig: HttpRedirectConfig,\n        httpCertificateConfig: HttpCertificateConfig,\n        httpBasicAuthentication: HttpBasicAuthentication\n    ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode wrap {\n        // FIXME: This will produce a race condition if creating multiple URL connections with\n        // different values for followRedirects in parallel\n        HttpURLConnection.setFollowRedirects(httpRedirectConfig.follow)\n        val conn: URLConnection = new URL(implicitly[UriCapable[H]].uri(res).toString).openConnection()\n        conn.setConnectTimeout(httpTimeout.duration)\n        conn match {\n          case c: HttpsURLConnection =>\n            if (httpCertificateConfig.ignoreIfInvalid) {\n              c.setSSLSocketFactory(NetUrl.sslContext.getSocketFactory)\n              c.setHostnameVerifier(NetUrl.allHostsValid)\n            }\n            c.setRequestMethod(method)\n            if (content != None) c.setDoOutput(true)\n            c.setUseCaches(false)\n          case c: HttpURLConnection =>\n            c.setRequestMethod(method)\n            if (content != None) c.setDoOutput(true)\n            c.setUseCaches(false)\n        }\n\n        // FIXME: What an ugly way of writing this.\n        httpBasicAuthentication.credentials foreach {\n          case (username, password) =>\n            conn.setRequestProperty(\"Authorization\",\n                                    \"Basic \" + NetUrl.base64.encode(s\"$username:$password\".getBytes(\"UTF-8\")).mkString)\n        }\n\n        ?[PostType[C]].contentType foreach { ct =>\n          conn.setRequestProperty(\"Content-Type\", ct.name)\n        }\n        for ((k, v) <- headers) conn.setRequestProperty(k, v)\n\n        if (content != None)\n          ensuring(OutputStreamBuilder.output(conn.getOutputStream)) { out =>\n            ?[PostType[C]].sender(content) > out\n          }\n\n        import scala.collection.JavaConverters._\n\n        val statusCode = conn match {\n          case c: HttpsURLConnection => c.getResponseCode()\n          case c: HttpURLConnection => c.getResponseCode()\n        }\n\n        val is = try conn.getInputStream()\n        catch {\n          case e: IOException =>\n            conn match {\n              case c: HttpsURLConnection => c.getErrorStream()\n              case c: HttpURLConnection => c.getErrorStream()\n            }\n        }\n\n        new HttpResponse(mapAsScalaMapConverter(conn.getHeaderFields()).asScala.toMap\n          .mapValues(collectionAsScalaIterableConverter(_).asScala.to[List]), statusCode, is)\n      }\n  }\n}\n\ntrait HttpSupport[Res] {\n\n  def doHttp[C: PostType, T](\n      res: Res,\n      content: C,\n      headers: Map[String, String],\n      method: String\n  )(\n      implicit mode: Mode[`NetUrl#httpPost`],\n      httpTimeout: HttpTimeout,\n      httpRedirectConfig: HttpRedirectConfig,\n      httpCertificateConfig: HttpCertificateConfig,\n      httpBasicAuthentication: HttpBasicAuthentication\n  ): mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws]\n}\n"
  },
  {
    "path": "net/shared/src/main/scala/rapture/net/ip.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.net\n\nimport rapture.core._\nimport rapture.codec._\n\nobject Ipv6 {\n  def parse(s: String)(implicit mode: Mode[`Ipv6.parse`]): mode.Wrap[Ipv6, Exception] =\n    mode.wrap {\n      val groups: Array[String] = s.split(\"::\").map(_.split(\":\")) match {\n        case Array() => Array.fill(8)(\"\")\n        case Array(xs) => xs.padTo(8, \"\")\n        case Array(Array(\"\"), xs) => Array.fill(8 - xs.length)(\"\") ++ xs\n        case Array(xs, ys) => xs ++ Array.fill(8 - xs.length - ys.length)(\"\") ++ ys\n      }\n      val gs = groups map (decode[Hex](_).bytes) map {\n        case Array() => 0\n        case Array(le) => le\n        case Array(be, le) => (be << 8) + le\n      }\n\n      Ipv6(gs(0), gs(1), gs(2), gs(3), gs(4), gs(5), gs(6), gs(7))\n    }\n}\n\nobject Ipv4 {\n\n  def parse(s: String) = {\n    val vs = s.split(\"\\\\.\").map(_.toInt)\n    Ipv4(vs(0), vs(1), vs(2), vs(3))\n  }\n\n  def fromLong(lng: Long) =\n    Ipv4((lng >> 24 & 255L).toInt, (lng >> 16 & 255L).toInt, (lng >> 8 & 255L).toInt, (lng & 255L).toInt)\n\n  lazy val privateSubnets =\n    List(Ipv4(10, 0, 0, 0) / 8, Ipv4(192, 168, 0, 0) / 16, Ipv4(172, 16, 0, 0) / 12, Ipv4(127, 0, 0, 0) / 8)\n}\n\ncase class Ipv6(s1: Int, s2: Int, s3: Int, s4: Int, s5: Int, s6: Int, s7: Int, s8: Int) {\n\n  def groups = Vector(s1, s2, s3, s4, s5, s6, s7, s8)\n\n  def expanded =\n    groups map { s =>\n      Bytes(Array(((s >> 8) & 0xff).toByte, (s & 0xff).toByte)).encode[Hex]\n    } mkString \":\"\n\n  override def toString = expanded.replaceAll(\"^0+\", \"\").replaceAll(\":0+\", \":\").replaceAll(\"::+\", \"::\")\n}\ncase class Ipv4(b1: Int, b2: Int, b3: Int, b4: Int) {\n\n  if (b1 > 255 || b2 > 255 || b3 > 255 || b4 > 255 || b1 < 0 || b2 < 0 || b3 < 0 || b4 < 0)\n    throw new InstantiationException(\"The components of the IP address must be in the range 0-255\")\n\n  def asLong = (b1.toLong << 24) + (b2 << 16) + (b3 << 8) + b4\n  def /(i: Int): Subnet = new Subnet(this, i)\n  def in(subnet: Subnet) = subnet contains this\n  override def toString() = b1 + \".\" + b2 + \".\" + b3 + \".\" + b4\n  def isPrivate = Ipv4.privateSubnets.exists(in)\n\n  override def equals(that: Any): Boolean = that match {\n    case that: Ipv4 => b1 == that.b1 && b2 == that.b2 && b3 == that.b3 && b4 == that.b4\n    case _ => false\n  }\n\n  override def hashCode = b1 << 24 | b2 << 16 | b3 << 8 | b4\n}\n\nobject Subnet {\n  def parse(s: String) = {\n    val x = s.split(\"\\\\/\")\n    new Subnet(Ipv4.parse(x(0)), x(1).toInt)\n  }\n}\n\nclass Subnet(baseIp: Ipv4, val bits: Int) extends Iterable[Ipv4] {\n  if (bits < 0 || bits > 32)\n    throw new InstantiationException(\"The subnet size must be in the range 0-32\")\n\n  def iterator: Iterator[Ipv4] = new Iterator[Ipv4] {\n    private var current = baseIp.asLong - 1\n    def hasNext = current < maximum.asLong\n    def next = {\n      current += 1\n      Ipv4.fromLong(current)\n    }\n  }\n\n  def maximum = Ipv4.fromLong((((baseIp.asLong >> (32 - bits)) + 1) << (32 - bits)) - 1)\n  val ip = Ipv4.fromLong((baseIp.asLong >> (32 - bits)) << (32 - bits))\n  override def size = 1 << (32 - bits)\n  override def toString() = ip.toString + \"/\" + bits\n  def contains(ip2: Ipv4) = Ipv4.fromLong((ip2.asLong >> (32 - bits)) << (32 - bits)) == ip\n\n  override def equals(that: Any) = that match {\n    case that: Subnet => ip == that.ip && bits == that.bits\n    case _ => false\n  }\n\n  override def hashCode = ip.hashCode | bits\n}\n\nobject Localhost extends Ipv4(127, 0, 0, 1)\n"
  },
  {
    "path": "net/shared/src/main/scala/rapture/net/net.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.net\n\nimport rapture.io._\nimport rapture.uri._\nimport rapture.mime._\nimport rapture.core._\nimport rapture.codec._\n\nimport java.io._\nimport javax.net.ssl._\n\ncase class TimeoutException() extends Exception(\"Timeout\")\ncase class InvalidCertificateException() extends Exception(\"Timeout\")\n\nobject HttpTimeout {\n  implicit val defaultHttpTimeout: HttpTimeout { type Throws = TimeoutException } = new HttpTimeout(10000) {\n    type Throws = TimeoutException\n  }\n\n  def apply[T: TimeSystem.ByDuration](timeout: T) =\n    new HttpTimeout(Math.min(Int.MaxValue, ?[TimeSystem.ByDuration[T]].fromDuration(timeout)).toInt) {\n      type Throws = TimeoutException\n    }\n}\nclass HttpTimeout(val duration: Int) {\n  type Throws <: Exception\n}\n\nclass HttpCertificateConfig(val ignoreIfInvalid: Boolean) {\n  type Throws <: Exception\n}\n\nobject HttpCertificateConfig {\n  implicit val defaultHttpCertificateConfig: HttpCertificateConfig { type Throws = InvalidCertificateException } =\n    new HttpCertificateConfig(true) { type Throws = InvalidCertificateException }\n}\nobject HttpRedirectConfig {\n  implicit val defaultHttpRedirectConfig: HttpRedirectConfig = new HttpRedirectConfig(true)\n}\nclass HttpRedirectConfig(val follow: Boolean)\n\nobject HttpBasicAuthentication {\n  implicit val defaultHttpBasicAuthentication: HttpBasicAuthentication = new HttpBasicAuthentication(None)\n}\nclass HttpBasicAuthentication(val credentials: Option[(String, String)]) {\n  type Throws\n}\n\nobject httpOptions {\n  object noTimeout {\n    implicit val implicitHttpTimeout: HttpTimeout { type Throws = Nothing } = new HttpTimeout(-1) {\n      type Throws = Nothing\n    }\n  }\n\n  object ignoreInvalidCertificates {\n    implicit val implicitCertificateConfig: HttpCertificateConfig = new HttpCertificateConfig(true)\n  }\n\n  object doNotFollowRedirects {\n    implicit val implicitFollowRedirects: HttpRedirectConfig = new HttpRedirectConfig(false)\n  }\n}\n\nobject HttpMethods {\n\n  private val methods = new scala.collection.mutable.HashMap[String, Method]\n\n  sealed class Method(val string: String) {\n\n    def unapply(r: String) = r == string\n    override def toString = string\n\n    methods += string -> this\n  }\n\n  trait FormMethod { this: Method => }\n\n  def method(s: String) = methods(s)\n\n  val Get = new Method(\"GET\") with FormMethod\n  val Put = new Method(\"PUT\")\n  val Post = new Method(\"POST\") with FormMethod\n  val Delete = new Method(\"DELETE\")\n  val Trace = new Method(\"TRACE\")\n  val Options = new Method(\"OPTIONS\")\n  val Head = new Method(\"HEAD\")\n  val Connect = new Method(\"CONNECT\")\n  val Patch = new Method(\"PATCH\")\n\n}\n\nclass HttpResponse(val headers: Map[String, List[String]], val status: Int, is: InputStream) {\n  def input[Data](implicit ib: InputBuilder[InputStream, Data],\n                  mode: Mode[`HttpResponse#input`]): mode.Wrap[Input[Data], Exception] =\n    mode.wrap(ib.input(is))\n}\n\nobject PostType {\n  implicit val nonePostType: PostType[None.type] = new PostType[None.type] {\n    def contentType = Some(MimeTypes.`application/x-www-form-urlencoded`)\n    def sender(content: None.type) = ByteArrayInput(Array[Byte](0))\n  }\n\n  implicit def formPostType: PostType[Map[Symbol, String]] = new PostType[Map[Symbol, String]] {\n    def contentType = Some(MimeTypes.`application/x-www-form-urlencoded`)\n    def sender(content: Map[Symbol, String]) =\n      ByteArrayInput((content map {\n            case (k, v) =>\n              java.net.URLEncoder.encode(k.name, \"UTF-8\") + \"=\" + java.net.URLEncoder.encode(v, \"UTF-8\")\n          } mkString \"&\").getBytes(\"UTF-8\"))\n  }\n\n  implicit def stringPostType[S: StringSerializer](implicit enc: Encoding): PostType[S] = new PostType[S] {\n    def contentType = Some(MimeTypes.`text/plain`)\n    def sender(content: S) = implicitly[StringSerializer[S]].serialize(content).input[Byte]\n  }\n}\ntrait PostType[-C] {\n  def contentType: Option[MimeTypes.MimeType]\n  def sender(content: C): Input[Byte]\n}\n\nobject NetUrl {\n  val sslContext = SSLContext.getInstance(\"SSL\")\n  val allHostsValid = new HostnameVerifier {\n    def verify(hostname: String, session: SSLSession) = true\n  }\n\n  trait Base64Padded extends CodecType\n  implicit val base64: ByteCodec[Base64Padded] = new Base64Codec[Base64Padded](endPadding = true)\n\n}\n\ntrait NetUrl {\n\n  private val trustAllCertificates = {\n    Array[TrustManager](new X509TrustManager {\n      override def getAcceptedIssuers(): Array[java.security.cert.X509Certificate] = null\n\n      def checkClientTrusted(certs: Array[java.security.cert.X509Certificate], authType: String): Unit = ()\n\n      def checkServerTrusted(certs: Array[java.security.cert.X509Certificate], authType: String): Unit = ()\n    })\n  }\n\n  NetUrl.sslContext.init(null, trustAllCertificates, new java.security.SecureRandom())\n\n  def hostname: String\n  def port: Int\n  def ssl: Boolean\n  def canonicalPort: Int\n}\n\nobject HttpUrl {\n  implicit val hasResourceName: HasResourceName[HttpUrl] = new HasResourceName[HttpUrl] {\n    def resourceName(httpUrl: HttpUrl): String = httpUrl.elements.lastOption.getOrElse(httpUrl.root.hostname)\n  }\n\n  implicit val parser: StringParser[HttpUrl] = new StringParser[HttpUrl] {\n    type Throws = ParseException\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[HttpUrl, Throws] = mode.wrap(Http.parse(s))\n  }\n\n  implicit val serializer: StringSerializer[HttpUrl] = new StringSerializer[HttpUrl] {\n    def serialize(h: HttpUrl): String = h.toString\n  }\n\n  implicit def uriCapable: UriCapable[HttpUrl] = new UriCapable[HttpUrl] {\n    def uri(cp: HttpUrl) = {\n      val portString = if (cp.ssl && cp.port == 443 || !cp.ssl && cp.port == 80) \"\" else s\":${cp.port}\"\n      Uri(if (cp.ssl) \"https\" else \"http\", s\"//${cp.hostname}${portString}/${cp.elements.mkString(\"/\")}\")\n    }\n  }\n\n  implicit def urlSlashRootedPath[RP <: RootedPath]: Dereferenceable[HttpUrl, RP, HttpUrl] =\n    new Dereferenceable[HttpUrl, RP, HttpUrl] {\n      def dereference(p1: HttpUrl, p2: RP) = {\n        val start = if (p1.elements.lastOption == Some(\"\")) p1.elements.init else p1.elements\n        HttpUrl(p1.root, start ++ p2.elements)\n      }\n    }\n\n  implicit def urlSlashRelativePath[RP <: RelativePath]: Dereferenceable[HttpUrl, RP, HttpUrl] =\n    new Dereferenceable[HttpUrl, RP, HttpUrl] {\n      def dereference(p1: HttpUrl, p2: RP) =\n        HttpUrl(p1.root, p1.elements.dropRight(p2.ascent) ++ p2.elements)\n    }\n\n  implicit def urlSlashString: Dereferenceable[HttpUrl, String, HttpUrl] =\n    new Dereferenceable[HttpUrl, String, HttpUrl] {\n      def dereference(p1: HttpUrl, p2: String) = {\n        val start = if (p1.elements.lastOption == Some(\"\")) p1.elements.init else p1.elements\n        HttpUrl(p1.root, start :+ p2)\n      }\n    }\n\n  implicit def urlParentable: Parentable[HttpUrl, HttpUrl] = new Parentable[HttpUrl, HttpUrl] {\n    def parent(httpUrl: HttpUrl): HttpUrl = HttpUrl(httpUrl.root, httpUrl.elements.dropRight(1))\n  }\n}\n\n/** Represets a URL with the http scheme */\ncase class HttpUrl(root: HttpDomain, elements: Vector[String]) extends NetUrl {\n\n  override def toString = HttpUrl.uriCapable.uri(this).toString\n\n  def hostname = root.hostname\n  def port = root.port\n  def canonicalPort = if (root.ssl) 443 else 80\n  def ssl = root.ssl\n\n  def query[Q: Query](q: Q): HttpQuery = HttpQuery(this, ?[Query[Q]].queryString(q))\n\n}\n\ntrait Query[-T] {\n  def queryString(t: T): String\n}\n\nobject Query {\n  implicit def mapQuery[K: StringSerializer, V: StringSerializer]: Query[Map[K, V]] = new Query[Map[K, V]] {\n    def queryString(m: Map[K, V]): String =\n      m.map {\n        case (k, v) =>\n          val key = java.net.URLEncoder.encode(?[StringSerializer[K]].serialize(k), \"UTF-8\")\n          val value = java.net.URLEncoder.encode(?[StringSerializer[V]].serialize(v), \"UTF-8\")\n          s\"$key=$value\"\n      }.mkString(\"&\")\n  }\n}\n\nobject HttpQuery {\n  implicit val serializer: StringSerializer[HttpQuery] = new StringSerializer[HttpQuery] {\n    def serialize(h: HttpQuery): String = h.toString\n  }\n\n  implicit val httpUrlParser: StringParser[HttpUrl] = new StringParser[HttpUrl] {\n    type Throws = ParseException\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[HttpUrl, Throws] =\n      mode.wrap(Http.parse(s))\n  }\n\n  implicit val httpQueryParser: StringParser[HttpQuery] = new StringParser[HttpQuery] {\n    type Throws = ParseException\n    def parse(s: String, mode: Mode[_ <: MethodConstraint]): mode.Wrap[HttpQuery, Throws] =\n      mode.wrap(HttpQuery.parse(s))\n  }\n\n  implicit def uriCapable: UriCapable[HttpQuery] = new UriCapable[HttpQuery] {\n    def uri(hq: HttpQuery) = {\n      val httpUrlUri = HttpUrl.uriCapable.uri(hq.httpUrl)\n      Uri(httpUrlUri.scheme, s\"${httpUrlUri.schemeSpecificPart}?${hq.queryString}\")\n    }\n  }\n\n  private val UrlRegex = \"\"\"(https?):\\/\\/([\\.\\-a-z0-9]+)(:[1-9][0-9]*)?(\\/?([^\\?]*)(\\?([^\\?]*))?)\"\"\".r\n\n  def parse(s: String): HttpQuery = s match {\n    case UrlRegex(scheme, server, port, _, path, _, after) =>\n      val rp = RootedPath(path.split(\"/\").to[Vector])\n\n      val httpUrl = scheme match {\n        case \"http\" =>\n          Http(server, if (port == null) 80 else port.substring(1).toInt) / rp\n        case \"https\" =>\n          Https(server, if (port == null) 443 else port.substring(1).toInt) / rp\n        case _ => throw new Exception(s)\n      }\n\n      HttpQuery(httpUrl, Option(after).getOrElse(\"\"))\n\n    case _ => throw new Exception(s)\n  }\n}\n\ncase class HttpQuery(httpUrl: HttpUrl, queryString: String) {\n  override def toString = {\n    val httpUrlUri = HttpUrl.uriCapable.uri(httpUrl)\n    if (queryString == \"\") httpUrlUri.toString else s\"$httpUrlUri?$queryString\"\n  }\n}\n\nobject HttpDomain {\n  implicit def cpSlashString: Dereferenceable[HttpDomain, String, HttpUrl] =\n    new Dereferenceable[HttpDomain, String, HttpUrl] {\n      def dereference(p1: HttpDomain, p2: String) = HttpUrl(p1, Vector(p2))\n    }\n\n  implicit def cpSlashRelativePath[RP <: RelativePath]: Dereferenceable[HttpDomain, RP, HttpUrl] =\n    new Dereferenceable[HttpDomain, RP, HttpUrl] {\n      def dereference(p1: HttpDomain, p2: RP) = HttpUrl(p1, p2.elements)\n    }\n\n  implicit def cpSlashRootedPath[RRP <: RootedPath]: Dereferenceable[HttpDomain, RRP, HttpUrl] =\n    new Dereferenceable[HttpDomain, RRP, HttpUrl] {\n      def dereference(p1: HttpDomain, p2: RRP) = HttpUrl(p1, p2.elements)\n    }\n\n  implicit def uriCapable: UriCapable[HttpDomain] = new UriCapable[HttpDomain] {\n    def uri(cp: HttpDomain) = {\n      val portString = if (cp.ssl && cp.port == 443 || !cp.ssl && cp.port == 80) \"\" else s\":${cp.port}\"\n      Uri(if (cp.ssl) \"https\" else \"http\", s\"//${cp.hostname}$portString\")\n    }\n  }\n\n}\n\ncase class HttpDomain(hostname: String, port: Int, ssl: Boolean) {\n  override def toString = HttpDomain.uriCapable.uri(this).toString\n}\n\nobject Http {\n\n  def apply(hostname: String, port: Int = services.tcp.http.portNo) =\n    HttpDomain(hostname, port, false)\n\n  def parse(s: String): HttpUrl = HttpQuery.parse(s).httpUrl\n\n}\n\nobject Https {\n\n  def apply(hostname: String, port: Int = services.tcp.https.portNo) =\n    HttpDomain(hostname, port, true)\n\n  def parse(s: String): HttpUrl = HttpQuery.parse(s).httpUrl\n}\n"
  },
  {
    "path": "net/shared/src/main/scala/rapture/net/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.net\nimport rapture.io._\nimport rapture.uri._\nimport rapture.core._\nimport rapture.base._\nimport rapture.codec._\nimport java.io.{Reader => _, Writer => _, _}\n\nimport scala.language.implicitConversions\nimport scala.language.experimental.macros\n\ntrait `NetUrl#httpGet` extends MethodConstraint\ntrait `NetUrl#httpPost` extends MethodConstraint\ntrait `NetUrl#httpHead` extends MethodConstraint\ntrait `NetUrl#httpPut` extends MethodConstraint\ntrait `Tcp.listen` extends MethodConstraint\ntrait `BrowserUrl#httpPost` extends MethodConstraint\ntrait `Ftp.parse` extends MethodConstraint\ntrait `HttpResponse#input` extends MethodConstraint\ntrait `Ipv6.parse` extends MethodConstraint\n\nobject `package` {\n\n  implicit class EnrichedHttpUriContext(uc: UriContext.type) {\n    def http(constants: List[String])(variables: List[String]): Any = macro NetMacros.httpUrlMacro\n    def https(constants: List[String])(variables: List[String]): Any = macro NetMacros.httpsUrlMacro\n  }\n\n  implicit def httpUrlSizable(implicit httpTimeout: HttpTimeout, toUri: UriCapable[HttpUrl]): Sizable[HttpUrl, Byte] =\n    new Sizable[HttpUrl, Byte] {\n      type ExceptionType = HttpExceptions\n      HttpSupport.basicHttpSupport\n      def size(url: HttpUrl): Long = url.httpHead().headers.get(\"Content-Length\").get.head.toLong\n    }\n\n  implicit def httpCapable[Res: HttpSupport](res: Res): HttpSupport.Capability[Res] =\n    new HttpSupport.Capability[Res](res)\n\n  implicit val httpStreamByteReader: JavaInputStreamReader[HttpUrl] = new JavaInputStreamReader[HttpUrl]({ u =>\n    new java.net.URL(u.uri.toString).openConnection.asInstanceOf[java.net.HttpURLConnection].getInputStream\n  })\n\n  implicit val httpQueryStreamByteReader: JavaInputStreamReader[HttpQuery] = new JavaInputStreamReader[HttpQuery]({\n    u =>\n      new java.net.URL(u.uri.toString).openConnection.asInstanceOf[java.net.HttpURLConnection].getInputStream\n  })\n\n  implicit val httpResponseCharReader: Reader[HttpResponse, Char] = new Reader[HttpResponse, Char] {\n    def input(response: HttpResponse): Input[Char] = {\n      import encodings.`UTF-8`._\n      response.input[Char]\n    }\n  }\n\n  implicit val httpResponseByteReader: Reader[HttpResponse, Byte] = new Reader[HttpResponse, Byte] {\n    def input(response: HttpResponse): Input[Byte] =\n      response.input[Byte](?[InputBuilder[InputStream, Byte]], modes.throwExceptions())\n  }\n\n  implicit val socketStreamByteReader: JavaInputStreamReader[SocketUri] =\n    new JavaInputStreamReader[SocketUri](_.javaSocket.getInputStream)\n\n  implicit val socketStreamByteWriter: JavaOutputStreamWriter[SocketUri] =\n    new JavaOutputStreamWriter[SocketUri](_.javaSocket.getOutputStream)\n\n  implicit val socketStreamByteAppender: JavaOutputAppender[SocketUri] =\n    new JavaOutputAppender[SocketUri](_.javaSocket.getOutputStream)\n}\n\nobject NetMacros {\n\n  def httpUrlMacro(c: WhiteboxContext)(constants: c.Expr[List[String]])(variables: c.Expr[List[String]]): c.Expr[Any] = {\n    import c.universe._\n\n    constants.tree match {\n      case Apply(_, List(rawParts@_*)) =>\n        val httpQuery = q\"\"\"_root_.rapture.net.HttpQuery.parse(\"http:\" + $constants.zip($variables :+ \"\").map { case (a, b) => a + b }.mkString)\"\"\"\n        if(rawParts.mkString contains \"?\") c.Expr(httpQuery)\n        else c.Expr(q\"$httpQuery.httpUrl\")\n    }\n  }\n  \n  def httpsUrlMacro(c: WhiteboxContext)(constants: c.Expr[List[String]])(variables: c.Expr[List[String]]): c.Expr[Any] = {\n    import c.universe._\n\n    constants.tree match {\n      case Apply(_, List(rawParts@_*)) =>\n        val httpQuery = q\"\"\"_root_.rapture.net.HttpQuery.parse(\"https:\" + $constants.zip($variables :+ \"\").map { case (a, b) => a + b }.mkString)\"\"\"\n        if(rawParts.mkString contains \"?\") c.Expr(httpQuery)\n        else c.Expr(q\"$httpQuery.httpUrl\")\n    }\n  }\n}\n"
  },
  {
    "path": "net/shared/src/main/scala/rapture/net/services.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.net\nimport rapture.core._\n\n/** Provides a typesafe list of network services mapping from port number to service name.  This\n  * is based on [http://www.iana.org/assignments/port-numbers] and\n  * [http://www.freebsd.org/cgi/cvsweb.cgi/src/etc/services] */\nobject services {\n  object tcp {\n\n    private lazy val serviceNames: Map[String, Port] = enumerateMembers[Port](this).map { p =>\n      p.name -> p\n    }.toMap\n\n    def apply(name: String) = serviceNames(name)\n\n    case class Port(portNo: Int)(implicit assigned: AssignedName) { def name = assigned.name }\n\n    val tcpmux = Port(1)\n    val compressnet = Port(2)\n    val compressnet2 = Port(3)\n    val rje = Port(5)\n    val echo = Port(7)\n    val discard = Port(9)\n    val systat = Port(11)\n    val daytime = Port(13)\n    val qotd = Port(17)\n    val msp = Port(18)\n    val chargen = Port(19)\n    val `ftp-data` = Port(20)\n    val ftp = Port(21)\n    val ssh = Port(22)\n    val telnet = Port(23)\n    val smtp = Port(25)\n    val `nsw-fe` = Port(27)\n    val `msg-icp` = Port(29)\n    val `msg-auth` = Port(31)\n    val dsp = Port(33)\n    val time = Port(37)\n    val rap = Port(38)\n    val rlp = Port(39)\n    val graphics = Port(41)\n    val nameserver = Port(42)\n    val nicname = Port(43)\n    val `mpm-flags` = Port(44)\n    val mpm = Port(45)\n    val `mpm-snd` = Port(46)\n    val `ni-ftp` = Port(47)\n    val auditd = Port(48)\n    val tacacs = Port(49)\n    val `re-mail-ck` = Port(50)\n    val domain = Port(53)\n    val `xns-ch` = Port(54)\n    val `isi-gl` = Port(55)\n    val `xns-auth` = Port(56)\n    val `xns-mail` = Port(58)\n    val `ni-mail` = Port(61)\n    val acas = Port(62)\n    val `whois++` = Port(63)\n    val covia = Port(64)\n    val `tacacs-ds` = Port(65)\n    val `sql*net` = Port(66)\n    val bootps = Port(67)\n    val bootpc = Port(68)\n    val tftp = Port(69)\n    val gopher = Port(70)\n    val `netrjs-1` = Port(71)\n    val `netrjs-2` = Port(72)\n    val `netrjs-3` = Port(73)\n    val `netrjs-4` = Port(74)\n    val deos = Port(76)\n    val vettcp = Port(78)\n    val finger = Port(79)\n    val http = Port(80)\n    val `hosts2-ns` = Port(81)\n    val xfer = Port(82)\n    val `mit-ml-dev` = Port(83)\n    val ctf = Port(84)\n    val `mit-ml-dev2` = Port(85)\n    val mfcobol = Port(86)\n    val kerberos = Port(88)\n    val `su-mit-tg` = Port(89)\n    val dnsix = Port(90)\n    val `mit-dov` = Port(91)\n    val npp = Port(92)\n    val dcp = Port(93)\n    val objcall = Port(94)\n    val supdup = Port(95)\n    val dixie = Port(96)\n    val `swift-rvf` = Port(97)\n    val tacnews = Port(98)\n    val metagram = Port(99)\n    val hostname = Port(101)\n    val `iso-tsap` = Port(102)\n    val gppitnp = Port(103)\n    val `acr-nema` = Port(104)\n    val cso = Port(105)\n    val `3com-tsmux` = Port(106)\n    val rtelnet = Port(107)\n    val snagas = Port(108)\n    val pop2 = Port(109)\n    val pop3 = Port(110)\n    val sunrpc = Port(111)\n    val mcidas = Port(112)\n    val auth = Port(113)\n    val sftp = Port(115)\n    val ansanotify = Port(116)\n    val `uucp-path` = Port(117)\n    val sqlserv = Port(118)\n    val nntp = Port(119)\n    val cfdptkt = Port(120)\n    val erpc = Port(121)\n    val smakynet = Port(122)\n    val ntp = Port(123)\n    val ansatrader = Port(124)\n    val `locus-map` = Port(125)\n    val nxedit = Port(126)\n    val `locus-con` = Port(127)\n    val `gss-xlicen` = Port(128)\n    val pwdgen = Port(129)\n    val `cisco-fna` = Port(130)\n    val `cisco-tna` = Port(131)\n    val `cisco-sys` = Port(132)\n    val statsrv = Port(133)\n    val `ingres-net` = Port(134)\n    val epmap = Port(135)\n    val profile = Port(136)\n    val `netbios-ns` = Port(137)\n    val `netbios-dgm` = Port(138)\n    val `netbios-ssn` = Port(139)\n    val `emfis-data` = Port(140)\n    val `emfis-cntl` = Port(141)\n    val imap = Port(143)\n    val uma = Port(144)\n    val uaac = Port(145)\n    val `iso-tp0` = Port(146)\n    val `iso-ip` = Port(147)\n    val jargon = Port(148)\n    val `aed-512` = Port(149)\n    val `sql-net` = Port(150)\n    val hems = Port(151)\n    val bftp = Port(152)\n    val sgmp = Port(153)\n    val `netsc-prod` = Port(154)\n    val `netsc-dev` = Port(155)\n    val sqlsrv = Port(156)\n    val `knet-cmp` = Port(157)\n    val `pcmail-srv` = Port(158)\n    val `nss-routing` = Port(159)\n    val `sgmp-traps` = Port(160)\n    val snmp = Port(161)\n    val snmptrap = Port(162)\n    val `cmip-man` = Port(163)\n    val `cmip-agent` = Port(164)\n    val `xns-courier` = Port(165)\n    val `s-net` = Port(166)\n    val namp = Port(167)\n    val rsvd = Port(168)\n    val send = Port(169)\n    val `print-srv` = Port(170)\n    val multiplex = Port(171)\n    val `xyplex-mux` = Port(173)\n    val mailq = Port(174)\n    val vmnet = Port(175)\n    val `genrad-mux` = Port(176)\n    val xdmcp = Port(177)\n    val nextstep = Port(178)\n    val bgp = Port(179)\n    val ris = Port(180)\n    val unify = Port(181)\n    val audit = Port(182)\n    val ocbinder = Port(183)\n    val ocserver = Port(184)\n    val `remote-kis` = Port(185)\n    val kis = Port(186)\n    val aci = Port(187)\n    val mumps = Port(188)\n    val qft = Port(189)\n    val gacp = Port(190)\n    val prospero = Port(191)\n    val `osu-nms` = Port(192)\n    val srmp = Port(193)\n    val irc = Port(194)\n    val `dn6-nlm-aud` = Port(195)\n    val `dn6-smm-red` = Port(196)\n    val dls = Port(197)\n    val `dls-mon` = Port(198)\n    val smux = Port(199)\n    val src = Port(200)\n    val `at-rtmp` = Port(201)\n    val `at-nbp` = Port(202)\n    val `at-echo` = Port(204)\n    val `at-zis` = Port(206)\n    val qmtp = Port(209)\n    val `z39.50` = Port(210)\n    val anet = Port(212)\n    val ipx = Port(213)\n    val imap3 = Port(220)\n    val link = Port(245)\n    val pawserv = Port(345)\n    val zserv = Port(346)\n    val fatserv = Port(347)\n    val scoi2odialog = Port(360)\n    val semantix = Port(361)\n    val srssend = Port(362)\n    val rsvp_tunnel = Port(363)\n    val `aurora-cmgr` = Port(364)\n    val dtk = Port(365)\n    val odmr = Port(366)\n    val rpc2portmap = Port(369)\n    val codaauth2 = Port(370)\n    val clearcase = Port(371)\n    val ulistproc = Port(372)\n    val ldap = Port(389)\n    val imsp = Port(406)\n    val svrloc = Port(427)\n    val `mobileip-agent` = Port(434)\n    val `mobilip-mn` = Port(435)\n    val https = Port(443)\n    val snpp = Port(444)\n    val `microsoft-ds` = Port(445)\n    val kpasswd = Port(464)\n    val urd = Port(465)\n    val photuris = Port(468)\n    val rcp = Port(469)\n    val saft = Port(487)\n    val `gss-http` = Port(488)\n    val `pim-rp-disc` = Port(496)\n    val isakmp = Port(500)\n    val exec = Port(512)\n    val login = Port(513)\n    val shell = Port(514)\n    val printer = Port(515)\n    val videotex = Port(516)\n    val talk = Port(517)\n    val ntalk = Port(518)\n    val utime = Port(519)\n    val efs = Port(520)\n    val ripng = Port(521)\n    val ulp = Port(522)\n    val `ibm-db2` = Port(523)\n    val ncp = Port(524)\n    val timed = Port(525)\n    val tempo = Port(526)\n    val courier = Port(530)\n    val conference = Port(531)\n    val netnews = Port(532)\n    val netwall = Port(533)\n    val `mm-admin` = Port(534)\n    val iiop = Port(535)\n    val `opalis-rdv` = Port(536)\n    val nmsp = Port(537)\n    val gdomap = Port(538)\n    val uucp = Port(540)\n    val klogin = Port(543)\n    val kshell = Port(544)\n    val appleqtcsrvr = Port(545)\n    val `dhcpv6-client` = Port(546)\n    val `dhcpv6-server` = Port(547)\n    val afpovertcp = Port(548)\n    val rtsp = Port(554)\n    val dsf = Port(555)\n    val remotefs = Port(556)\n    val nntps = Port(563)\n    val `9pfs` = Port(564)\n    val whoami = Port(565)\n    val submission = Port(587)\n    val `http-alt` = Port(591)\n    val nqs = Port(607)\n    val `npmp-local` = Port(610)\n    val `npmp-gui` = Port(611)\n    val `hmmp-ind` = Port(612)\n    val cryptoadmin = Port(624)\n    val dec_dlm = Port(625)\n    val asia = Port(626)\n    val `passgo-tivoli` = Port(627)\n    val qmqp = Port(628)\n    val `3com-amp3` = Port(629)\n    val rda = Port(630)\n    val ipp = Port(631)\n    val ldaps = Port(636)\n    val tinc = Port(655)\n    val acap = Port(674)\n    val asipregistry = Port(687)\n    val `realm-rusd` = Port(688)\n    val nmap = Port(689)\n    val `ha-cluster` = Port(694)\n    val epp = Port(700)\n    val `iris-beep` = Port(702)\n    val silc = Port(706)\n    val `kerberos-adm` = Port(749)\n    val `kerberos-iv` = Port(750)\n    val pump = Port(751)\n    val qrh = Port(752)\n    val rrh = Port(753)\n    val tell = Port(754)\n    val nlogin = Port(758)\n    val con = Port(759)\n    val ns = Port(760)\n    val webster = Port(765)\n    val phonebook = Port(767)\n    val rsync = Port(873)\n    val `ftps-data` = Port(989)\n    val ftps = Port(990)\n    val nas = Port(991)\n    val telnets = Port(992)\n    val imaps = Port(993)\n    val ircs = Port(994)\n    val pop3s = Port(995)\n    val imgames = Port(1077)\n    val socks = Port(1080)\n    val rmiregistry = Port(1099)\n    val bnetgame = Port(1119)\n    val bnetfile = Port(1120)\n    val hpvmmcontrol = Port(1124)\n    val hpvmmagent = Port(1125)\n    val hpvmmdata = Port(1126)\n    val resacommunity = Port(1154)\n    val `3comnetman` = Port(1181)\n    val `mysql-cluster` = Port(1186)\n    val alias = Port(1187)\n    val openvpn = Port(1194)\n    val kazaa = Port(1214)\n    val bvcontrol = Port(1236)\n    val nessus = Port(1241)\n    val h323hostcallsc = Port(1300)\n    val lotusnote = Port(1352)\n    val `ms-sql-s` = Port(1433)\n    val `ms-sql-m` = Port(1434)\n    val ica = Port(1494)\n    val wins = Port(1512)\n    val ingreslock = Port(1524)\n    val `prospero-np` = Port(1525)\n    val datametrics = Port(1645)\n    val `sa-msg-port` = Port(1646)\n    val rsap = Port(1647)\n    val `concurrent-lm` = Port(1648)\n    val kermit = Port(1649)\n    val l2tp = Port(1701)\n    val h323gatedisc = Port(1718)\n    val h323gatestat = Port(1719)\n    val h323hostcall = Port(1720)\n    val iberiagames = Port(1726)\n    val gamegen1 = Port(1738)\n    val `tftp-mcast` = Port(1758)\n    val hello = Port(1789)\n    val radius = Port(1812)\n    val `radius-acct` = Port(1813)\n    val mtp = Port(1911)\n    val egs = Port(1926)\n    val `unix-status` = Port(1957)\n    val hsrp = Port(1985)\n    val licensedaemon = Port(1986)\n    val `tr-rsrb-p1` = Port(1987)\n    val `tr-rsrb-p2` = Port(1988)\n    val `tr-rsrb-p3` = Port(1989)\n    val `stun-p1` = Port(1990)\n    val `stun-p2` = Port(1991)\n    val `stun-p3` = Port(1992)\n    val `snmp-tcp-port` = Port(1994)\n    val `stun-port` = Port(1995)\n    val `perf-port` = Port(1996)\n    val `gdp-port` = Port(1997)\n    val `x25-svc-port` = Port(1998)\n    val `tcp-id-port` = Port(1999)\n    val `cisco-sccp` = Port(2000)\n    val nfs = Port(2049)\n    val radsec = Port(2083)\n    val gnunet = Port(2086)\n    val `rtcm-sc104` = Port(2101)\n    val `zephyr-srv` = Port(2102)\n    val `zephyr-clt` = Port(2103)\n    val `zephyr-hm` = Port(2104)\n    val eyetv = Port(2170)\n    val `msfw-storage` = Port(2171)\n    val `msfw-s-storage` = Port(2172)\n    val `msfw-replica` = Port(2173)\n    val `msfw-array` = Port(2174)\n    val airsync = Port(2175)\n    val rapi = Port(2176)\n    val qwave = Port(2177)\n    val tivoconnect = Port(2190)\n    val tvbus = Port(2191)\n    val `mysql-im` = Port(2273)\n    val `dict-lookup` = Port(2289)\n    val redstorm_join = Port(2346)\n    val redstorm_find = Port(2347)\n    val redstorm_info = Port(2348)\n    val cvspserver = Port(2401)\n    val venus = Port(2430)\n    val `venus-se` = Port(2431)\n    val codasrv = Port(2432)\n    val `codasrv-se` = Port(2433)\n    val netadmin = Port(2450)\n    val netchat = Port(2451)\n    val snifferclient = Port(2452)\n    val ppcontrol = Port(2505)\n    val lstp = Port(2559)\n    val mon = Port(2583)\n    val hpstgmgr = Port(2600)\n    val `discp-client` = Port(2601)\n    val `discp-server` = Port(2602)\n    val servicemeter = Port(2603)\n    val `nsc-ccs` = Port(2604)\n    val `nsc-posa` = Port(2605)\n    val netmon = Port(2606)\n    val connection = Port(2607)\n    val `wag-service` = Port(2608)\n    val dict = Port(2628)\n    val exce = Port(2769)\n    val `dvr-esm` = Port(2804)\n    val corbaloc = Port(2809)\n    val ndtp = Port(2882)\n    val gamelobby = Port(2914)\n    val gds_db = Port(3050)\n    val xbox = Port(3074)\n    val icpv2 = Port(3130)\n    val `nm-game-admin` = Port(3148)\n    val `nm-game-server` = Port(3149)\n    val mysql = Port(3306)\n    val sftu = Port(3326)\n    val trnsprntproxy = Port(3346)\n    val `ms-wbt-server` = Port(3389)\n    val prsvp = Port(3455)\n    val nut = Port(3493)\n    val ironstorm = Port(3504)\n    val `cctv-port` = Port(3559)\n    val `iw-mmogame` = Port(3596)\n    val distcc = Port(3632)\n    val daap = Port(3689)\n    val svn = Port(3690)\n    val blizwow = Port(3724)\n    val `netboot-pxe` = Port(3928)\n    val `smauth-port` = Port(3929)\n    val treehopper = Port(3959)\n    val cobraclient = Port(3970)\n    val cobraserver = Port(3971)\n    val `pxc-spvr-ft` = Port(4002)\n    val `pxc-splr-ft` = Port(4003)\n    val `pxc-roid` = Port(4004)\n    val `pxc-pin` = Port(4005)\n    val `pxc-spvr` = Port(4006)\n    val `pxc-splr` = Port(4007)\n    val xgrid = Port(4111)\n    val bzr = Port(4155)\n    val rwhois = Port(4321)\n    val epmd = Port(4369)\n    val krb524 = Port(4444)\n    val `ipsec-nat-t` = Port(4500)\n    val hylafax = Port(4559)\n    val piranha1 = Port(4600)\n    val `playsta2-app` = Port(4658)\n    val `playsta2-lob` = Port(4659)\n    val snap = Port(4752)\n    val `radmin-port` = Port(4899)\n    val rfe = Port(5002)\n    val `ita-agent` = Port(5051)\n    val `sdl-ets` = Port(5081)\n    val bzflag = Port(5154)\n    val aol = Port(5190)\n    val `xmpp-client` = Port(5222)\n    val caevms = Port(5251)\n    val `xmpp-server` = Port(5269)\n    val cfengine = Port(5308)\n    val `nat-pmp` = Port(5351)\n    val `dns-llq` = Port(5352)\n    val mdns = Port(5353)\n    val mdnsresponder = Port(5354)\n    val llmnr = Port(5355)\n    val `dj-ice` = Port(5419)\n    val `beyond-remote` = Port(5424)\n    val `br-channel` = Port(5425)\n    val postgresql = Port(5432)\n    val `sgi-eventmond` = Port(5553)\n    val `sgi-esphttp` = Port(5554)\n    val cvsup = Port(5999)\n    val x11 = Port(6000)\n    val `kftp-data` = Port(6620)\n    val kftp = Port(6621)\n    val ktelnet = Port(6623)\n    val `gnutella-svc` = Port(6346)\n    val `gnutella-rtr` = Port(6347)\n    val `sane-port` = Port(6566)\n    val `parsec-game` = Port(6582)\n    val `afs3-fileserver` = Port(7000)\n    val `afs3-callback` = Port(7001)\n    val `afs3-prserver` = Port(7002)\n    val `afs3-vlserver` = Port(7003)\n    val `afs3-kaserver` = Port(7004)\n    val `afs3-volser` = Port(7005)\n    val `afs3-errors` = Port(7006)\n    val `afs3-bos` = Port(7007)\n    val `afs3-update` = Port(7008)\n    val `afs3-rmtsys` = Port(7009)\n    val `font-service` = Port(7100)\n    val sncp = Port(7560)\n    val `soap-http` = Port(7627)\n    val `http-alt2` = Port(8008)\n    val `http-alt3` = Port(8080)\n    val sunproxyadmin = Port(8081)\n    val pichat = Port(9009)\n    val `bacula-dir` = Port(9101)\n    val `bacula-fd` = Port(9102)\n    val `bacula-sd` = Port(9103)\n    val dddp = Port(9131)\n    val `wap-wsp` = Port(9200)\n    val `wap-wsp-wtp` = Port(9201)\n    val `wap-wsp-s` = Port(9202)\n    val `wap-wsp-wtp-s` = Port(9203)\n    val `wap-vcard` = Port(9204)\n    val `wap-vcal` = Port(9205)\n    val `wap-vcard-s` = Port(9206)\n    val `wap-vcal-s` = Port(9207)\n    val git = Port(9418)\n    val cba8 = Port(9593)\n    val davsrc = Port(9800)\n    val sqlexec = Port(9088)\n    val `sqlexec-ssl` = Port(9089)\n    val sd = Port(9876)\n    val `cyborg-systems` = Port(9888)\n    val monkeycom = Port(9898)\n    val `sctp-tunneling` = Port(9899)\n    val domaintime = Port(9909)\n    val amanda = Port(10080)\n    val vce = Port(11111)\n    val smsqp = Port(11201)\n    val hkp = Port(11371)\n    val h323callsigalt = Port(11720)\n    val `rets-ssl` = Port(12109)\n    val cawas = Port(12168)\n    val bprd = Port(13720)\n    val bpdbm = Port(13721)\n    val `bpjava-msvc` = Port(13722)\n    val vnetd = Port(13724)\n    val bpcd = Port(13782)\n    val vopied = Port(13783)\n    val xpilot = Port(15345)\n    val wnn6 = Port(22273)\n    val binkp = Port(24554)\n    val quake = Port(26000)\n    val `wnn6-ds` = Port(26208)\n    val tetrinet = Port(31457)\n    val `gamesmith-port` = Port(31765)\n    val traceroute = Port(33434)\n    val candp = Port(42508)\n    val candrp = Port(42509)\n    val caerpc = Port(42510)\n    val kpop = Port(1109)\n    val knetd = Port(2053)\n    val eklogin = Port(2105)\n    val supfilesrv = Port(871)\n    val supfiledbg = Port(1127)\n    val swat = Port(901)\n    val rndc = Port(953)\n    val skkserv = Port(1178)\n    val xtel = Port(1313)\n    val support = Port(1529)\n    val cfinger = Port(2003)\n    val ninstall = Port(2150)\n    val afbackup = Port(2988)\n    val fax = Port(4557)\n    val rplay = Port(5555)\n    val canna = Port(5680)\n    val `x11-ssh` = Port(6010)\n    val ircd = Port(6667)\n    val jetdirect = Port(9100)\n    val kamanda = Port(10081)\n    val amandaidx = Port(10082)\n    val amidxtape = Port(10083)\n    val isdnlog = Port(20011)\n    val vboxd = Port(20012)\n    val wnn4_Cn = Port(22289)\n    val wnn4_Kr = Port(22305)\n    val wnn4_Tw = Port(22321)\n    val asp = Port(27374)\n    val tfido = Port(60177)\n    val fido = Port(60179)\n  }\n}\n"
  },
  {
    "path": "net/shared/src/main/scala/rapture/net/sockets.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.net\nimport rapture.core._\nimport rapture.io._\nimport rapture.uri._\n\nimport java.io._\n\nobject Tcp {\n\n  def listen[K](port: Int)(implicit ib: InputBuilder[InputStream, K],\n                           ob: OutputBuilder[OutputStream, K],\n                           mode: Mode[`Tcp.listen`]): mode.Wrap[(Input[K], Output[K]), Exception] = mode.wrap {\n    val sock = new java.net.ServerSocket(port)\n    val sock2 = sock.accept()\n    (ib.input(sock2.getInputStream), ob.output(sock2.getOutputStream))\n  }\n\n  def handle[K](port: Int)(action: (Input[K], Output[K]) => Unit)(implicit ib: InputBuilder[InputStream, K],\n                                                                  ob: OutputBuilder[OutputStream, K]): Unit = {\n    val sock = new java.net.ServerSocket(port)\n    while (true) {\n      val sock2 = sock.accept()\n      Thread.fork(s\"rapture-port$port\") {\n        action(ib.input(sock2.getInputStream), ob.output(sock2.getOutputStream))\n      }\n    }\n  }\n}\n\nobject SocketUri {\n  implicit val socketUri = new UriCapable[SocketUri] {\n    def uri(su: SocketUri): Uri = Uri(\"socket\", s\"//${su.hostname}:${su.port}\")\n  }\n}\n\ncase class SocketUri(hostname: String, port: Int) {\n\n  lazy val javaSocket: java.net.Socket = new java.net.Socket(hostname, port)\n\n  def schemeSpecificPart = \"//\" + hostname + \":\" + port\n\n  def absolute = true\n\n}\n\nobject Socket {\n  def apply(hostname: String, port: Int): SocketUri = new SocketUri(hostname, port)\n  def apply(hostname: String, svc: services.tcp.Port): SocketUri = new SocketUri(hostname, svc.portNo)\n\n  private val UriMatcher = \"\"\"socket://([a-z0-9\\.]+):([1-9][0-9]*)\"\"\".r\n\n  def parse(uri: String) = uri match {\n    case UriMatcher(host, port) => new SocketUri(host, port.toInt)\n  }\n}\n"
  },
  {
    "path": "net-test/shared/src/test/scala/rapture/net/test/DockerHttpBinServerSpec.scala",
    "content": "package rapture.net.test\n\nimport org.scalatest.concurrent.Eventually._\nimport org.scalatest.concurrent.PatienceConfiguration._\nimport org.scalatest.time.{Seconds, Span}\nimport org.scalatest.{BeforeAndAfter, Suite}\nimport rapture.net._\nimport rapture.net.test.helper.{DockerContainer, ExposePort}\n\ntrait DockerHttpBinServerSpec extends BeforeAndAfter {\n  this: Suite =>\n\n  val SERVER_PORT = 33881\n  val SERVER_URL = s\"http://127.0.0.1:$SERVER_PORT\"\n  private var startedDockerContainer: DockerContainer#StartedDockerContainer = _\n\n  before {\n    startedDockerContainer =\n      new DockerContainer(\"paddycarey/httpbin\", Set(ExposePort(SERVER_PORT.toString, \"8000\"))).startContainer()\n    eventually(Timeout(Span(30, Seconds))) {\n      println(\"Trying to connect....\")\n      assert(Http(\"127.0.0.1\", SERVER_PORT).httpGet().status == 200)\n    }\n  }\n\n  after {\n    startedDockerContainer.killAndRemoveContainer()\n  }\n\n}\n"
  },
  {
    "path": "net-test/shared/src/test/scala/rapture/net/test/HttpClientSpec.scala",
    "content": "package rapture.net.test\n\nimport org.scalatest.{Matchers, WordSpec}\nimport rapture.io._\nimport rapture.json.Json\nimport rapture.json.jsonBackends.circe._\nimport rapture.net.{Http, HttpQuery}\n\nclass HttpClientSpec extends WordSpec with Matchers with DockerHttpBinServerSpec {\n\n  \"Http client\" should {\n    \"make GET request and get 200 OK status\" in {\n      val result = Http.parse(s\"$SERVER_URL/get\").httpGet()\n      result.status shouldEqual 200\n    }\n\n    \"make GET request with query params and get 200 OK status\" in {\n      val result =\n        HttpQuery.parse(s\"$SERVER_URL/get?foo=333&bar=abc\").httpGet(Map(\"Content-Type\" -> \"application/json\"))\n\n      result.status shouldEqual 200\n      val json = Json.parse(result.slurp[Char])\n      json.args.foo.as[String] shouldEqual \"333\"\n      json.args.bar.as[String] shouldEqual \"abc\"\n    }\n\n    \"make GET request with custom headers and get 200 OK\" in {\n      val result = HttpQuery\n        .parse(s\"$SERVER_URL/get\")\n        .httpGet(Map(\"Content-Type\" -> \"application/json\", \"Mytest-Header\" -> \"111-222-333-abc\"))\n\n      result.status shouldEqual 200\n      val json = Json.parse(result.slurp[Char])\n      json.headers.`Mytest-Header`.as[String] shouldEqual \"111-222-333-abc\"\n    }\n  }\n\n}\n"
  },
  {
    "path": "net-test/shared/src/test/scala/rapture/net/test/helper/DockerContainer.scala",
    "content": "package rapture.net.test.helper\n\nimport com.spotify.docker.client.DefaultDockerClient\nimport com.spotify.docker.client.messages.{ContainerConfig, ContainerCreation, HostConfig, PortBinding}\nimport rapture.core.Mode\n\nimport scala.collection.JavaConverters._\n\ncase class ExposePort(externalPort: String, internalPort: String)\n\nclass DockerContainer(image: String, exposedPorts: Set[ExposePort]) {\n  import java.util\n\n  lazy val docker = DefaultDockerClient.fromEnv().build()\n\n  def startContainer()(implicit mode: Mode[_]): mode.Wrap[StartedDockerContainer, Nothing] = mode.wrap {\n    docker.pull(image)\n    val portBindings = new util.HashMap[String, util.List[PortBinding]]\n    exposedPorts.foreach { port =>\n      portBindings.put(port.internalPort, List(PortBinding.of(\"0.0.0.0\", port.externalPort)).asJava)\n    }\n    val containerConfig = ContainerConfig\n      .builder()\n      .hostConfig(HostConfig.builder().portBindings(portBindings).build())\n      .image(image)\n      .exposedPorts(exposedPorts.map(_.internalPort).asJava)\n      .build()\n    val creation = docker.createContainer(containerConfig)\n    docker.startContainer(creation.id())\n    new StartedDockerContainer(image, exposedPorts, creation)\n  }\n\n  class StartedDockerContainer(image: String, exposedPorts: Set[ExposePort], creation: ContainerCreation) {\n\n    def killAndRemoveContainer(): Unit = {\n      docker.killContainer(creation.id)\n      docker.removeContainer(creation.id)\n    }\n  }\n\n}\n"
  },
  {
    "path": "project/build.properties",
    "content": "sbt.version=0.13.13\n"
  },
  {
    "path": "project/plugins.sbt",
    "content": "addSbtPlugin(\"com.jsuereth\"      % \"sbt-pgp\"                % \"1.0.1\")\naddSbtPlugin(\"com.github.gseitz\" % \"sbt-release\"            % \"1.0.4\")\naddSbtPlugin(\"org.scoverage\"     % \"sbt-scoverage\"          % \"1.5.0\")\naddSbtPlugin(\"com.typesafe.sbt\"  % \"sbt-git\"                % \"0.8.5\")\naddSbtPlugin(\"org.scala-js\"      % \"sbt-scalajs\"            % \"0.6.14\")\naddSbtPlugin(\"org.xerial.sbt\"    % \"sbt-sonatype\"           % \"0.5.1\")\n//addSbtPlugin(\"com.geirsson\"      % \"sbt-scalafmt\"           % \"0.2.10\")\n\n"
  },
  {
    "path": "test/shared/src/main/scala/rapture/test/macros.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.test\n\nimport scala.language.experimental.macros\nimport rapture.base._\n\nobject deferTypeErrors {\n  implicit def deferTypeErrorsConvertAnyToAny[T, S](t: T): S = ???\n  implicit def deferTypeErrorsResolveAnyImplicit[T]: T = ???\n}\n\nobject typeMismatch {\n\n  def apply[T](fn: => T): Boolean = macro applyMacro[T]\n\n  def applyMacro[T](c: BlackboxContext)(fn: c.Expr[T]): c.Expr[Boolean] = {\n    import c.universe._\n\n    val found = fn.tree.exists {\n      case Select(_, name) =>\n        name.decodedName.toString match {\n          case \"deferTypeErrorsConvertAnyToAny\" => true\n          case \"deferTypeErrorsResolveAnyImplicit\" => true\n          case _ => false\n        }\n      case _ => false\n    }\n\n    c.Expr[Boolean](q\"$found\")\n  }\n}\n"
  },
  {
    "path": "test/shared/src/main/scala/rapture/test/report.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.test\n\nimport rapture.text._\n\nimport java.io.PrintStream\n\ntrait Reporter {\n\n  type Tag\n\n  def title(text: String)(implicit tty: ansi.Tty)\n  def startTask(text: String)(implicit tty: ansi.Tty): Tag\n  def completeTask(tag: Tag, result: TestResult)(implicit tty: ansi.Tty): Unit\n  def report(text: String, inset: Boolean = false)(implicit tty: ansi.Tty): Unit\n  def summary(status: Int, text: String)(implicit tty: ansi.Tty): Unit\n\n}\n\nclass BasicReporter(width: Int, out: PrintStream) extends Reporter {\n\n  private var spaceAbove = false\n  def mkSpace() = {\n    if (!spaceAbove) out.println()\n    spaceAbove = true\n  }\n  def output(text: String) {\n    out.println(text)\n    spaceAbove = false\n  }\n\n  class Tag(val text: String) {\n    val t0 = System.currentTimeMillis\n  }\n\n  private var activeTags: Set[Tag] = Set()\n\n  def startTask(text: String)(implicit tty: ansi.Tty): Tag = synchronized {\n    val cutText = text.take(width - 20)\n    val tag = new Tag(cutText)\n    out.print(s\"${ansi.normal}${cutText}\")\n    activeTags += tag\n\n    tag\n  }\n\n  def completeTask(tag: Tag, result: TestResult)(implicit tty: ansi.Tty): Unit = synchronized {\n    val t = System.currentTimeMillis - tag.t0\n    out.print(\" \" * (width - tag.text.length - 20))\n    val pad = \" \" * (5 - t.toString.length)\n    val colorText = result match {\n      case Success => s\"${ansi.green}SUCCESS\"\n      case Failure(msg) => s\"${ansi.yellow}FAILURE\"\n      case Error(e) => s\"${ansi.red} ERROR \"\n    }\n\n    output(s\"${ansi.boldBlue}[ ${colorText}${ansi.boldBlue} ]${pad}${t} ms${ansi.normal}\")\n    activeTags -= tag\n  }\n\n  def report(text: String, inset: Boolean = false)(implicit tty: ansi.Tty) = {\n    val indent = if (inset) s\"    ${ansi.boldBlue}\" else ansi.normal\n    text split \"\\n\" flatMap (_.grouped(width - 25)) map (indent + _) foreach output\n  }\n\n  def summary(status: Int, text: String)(implicit tty: ansi.Tty) = {\n    val color = status match {\n      case 1 => ansi.green\n      case 0 => ansi.yellow\n      case _ => ansi.red\n    }\n    text grouped (width - 4) foreach { ln =>\n      output(s\" ${color}* ${ansi.normal}${ln}\")\n    }\n  }\n\n  def title(text: String)(implicit tty: ansi.Tty) =\n    text grouped (width - 4) foreach { ln =>\n      output(s\" ${ansi.green}* ${ansi.normal}${ln}\")\n    }\n}\n"
  },
  {
    "path": "test/shared/src/main/scala/rapture/test/scalatest.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.test\n\nimport language.experimental.macros\n\nclass Programme extends org.scalatest.FunSuite {\n\n  def include[TS <: TestSuite](suite: TS): Unit = macro rapture.test.run.includeMacro[TS]\n\n  def includeAll(tests: List[(String, TestSuite#Test)]): Unit = {\n    tests.foreach {\n      case (n, t) =>\n        test(n) {\n          val result = t.runCheck()\n          assert(result == Success)\n        }\n    }\n  }\n}\n"
  },
  {
    "path": "test/shared/src/main/scala/rapture/test/test.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.test\n\nimport rapture.core._\nimport rapture.text._\nimport rapture.base._\nimport rapture.fs._\n\nimport scala.reflect._\n\nimport java.net.URLClassLoader\n\nimport scala.language.experimental.macros\n\nobject Util {\n  private val entries: collection.mutable.HashMap[FsUrl, Seq[String]] = new collection.mutable.HashMap()\n\n  def entriesFromZip(f: FsUrl): Seq[String] = {\n    import java.util.zip._\n    import scala.collection.JavaConverters._\n    val zf = new ZipFile(f.javaFile)\n    entries.getOrElseUpdate(f,\n                            enumerationAsScalaIteratorConverter(zf.entries).asScala\n                              .to[List]\n                              .filter(_.getName\n                                    endsWith \".class\")\n                              .filter(!_.getName.contains(\"$\"))\n                              .map(_.getName.dropRight(6)))\n  }\n\n  def getAllZipfiles(): List[FsUrl] = {\n    val urls: Array[java.net.URL] =\n      java.lang.Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs\n    urls\n      .to[List]\n      .map { u =>\n        File.parse(\"file://\" + u.getFile)\n      }\n      .filter(_.writable)\n  }\n}\n\n/*object Main extends BackgroundCliApp {\n\n  object Params extends Params(ClasspathParam, SuiteParam, TestParam, ShutdownParam)\n  lazy val ShutdownParam = Param(\"shutdown\", \"K\", \"Shutdown the server\")\n  lazy val ClasspathParam = Param(\"classpath\", \"c\", \"Specify the classpath for the test\")\n  lazy val TestParam = Param(\"test\", \"t\", \"Specify a single test to run\")\n  lazy val SuiteParam = Param(\"suite\", \"s\", \"Specify the suite of tests to run\")\n\n  def handle(line: CmdLine) = line match {\n    case Params(ps) =>\n      val directory = line.pwd.children.filter(_.filename endsWith \".jar\")\n      \n      val cp: List[FsUrl] = ps.get(ClasspathParam, Suggestions.from(directory)(_.filename, f =>\n          (f.size/1024)+\"KB\")).map { f => List(line.pwd / f) }.getOrElse(Util.getAllZipfiles())\n\n      val classes: Seq[String] = cp.flatMap(Util.entriesFromZip).map(_.replaceAll(\"\\\\/\", \".\"))\n\n      val allSuites = ClassLoader(cp).applyTo {\n        classes.filter { n => try { classOf[TestSuite] isAssignableFrom Class.forName(n) } catch {\n          case e: Throwable => false\n        } }\n      }\n      \n      val oneSuite = ps.get(SuiteParam, Suggestions.from(allSuites)(identity)).map(List(_))\n      val suites = oneSuite.getOrElse(allSuites).flatMap { s =>\n        Try(s -> Class.forName(s).newInstance().asInstanceOf[TestSuite]).toOption\n      }\n      \n      exec { out =>\n        val cols = 100\n        implicit val reporter = new BasicReporter(cols, out)\n        for((n, s) <- suites) {\n          out.println(s\"Running test suite ${Ansi.Blue}${n}${Ansi.Normal}\")\n          out.println(s\"${Ansi.BoldBlack}${\"-\"*cols}\")\n          s.runAll()\n          out.println()\n        }\n        if(suites.isEmpty) out.println(\"Usage: rtest [--classpath <classpath>] --suite <suite>\")\n      }\n  }\n}*/\n\nsealed trait TestResult { def message: Option[String] }\n\ncase object Success extends TestResult { def message = None }\ncase class Failure(msg: String) extends TestResult { def message = Some(msg) }\ncase class Error(error: Throwable) extends TestResult {\n  private val stack = error.getStackTrace.map(_.toString).takeWhile(!_.startsWith(\"rapture.test\"))\n\n  private val stackString = stack.mkString(\"    \", \"\\n    \", \"\")\n\n  def message = Some(s\"Exception thrown during test: ${error.toString}\\n${stackString}\")\n}\n\ntrait TestCase\n\ntrait TestSuite {\n\n  abstract class Test extends TestCase { thisTest =>\n\n    type Return\n\n    def dependencies = Set[Test]()\n    def action: () => Return\n    def check(run: () => Return): TestResult\n    def name: String\n    def runCheck(): TestResult =\n      try check(action)\n      catch { case e: Throwable => Error(e) }\n\n    protected def compare[T](x: T, y: T): TestResult =\n      if (x == y) Success\n      else {\n        Failure(s\"Found $x, but expected $y\")\n      }\n\n    def returns(chk: => Return)(implicit assigned: AssignedName) = new Test {\n      type Return = thisTest.Return\n      def name = assigned.name\n      def action: () => Return = thisTest.action\n      def check(run: () => Return): TestResult = {\n        val result = run()\n        val y = chk\n        if (result == y) Success else Failure(s\"Found $result but expected $y\")\n      }\n    }\n\n    def satisfies(chk: Return => Boolean)(implicit assigned: AssignedName) = new Test {\n      type Return = thisTest.Return\n      def name = assigned.name\n      def action: () => Return = thisTest.action\n      def check(run: () => Return): TestResult = {\n        val result = run()\n        if (chk(result)) Success else Failure(s\"Result $result did not satisfy predicate.\")\n      }\n    }\n\n    def throws[E <: Throwable: ClassTag](cls: Class[E])(implicit assigned: AssignedName): Test = new Test {\n      type Return = thisTest.Return\n      def name = assigned.name\n      def action: () => Return = thisTest.action\n      def check(run: () => Return): TestResult =\n        try {\n          run()\n          Failure(\"Expected exception not thrown.\")\n        } catch {\n          case e: E => Success\n          case e: Throwable => Failure(s\"Expected exception of type `${classTag[E]}', but found exception `${e}'.\")\n        }\n    }\n\n    def throws[E <: Throwable](exp: E)(implicit assigned: AssignedName): Test = new Test {\n      type Return = thisTest.Return\n      def name = assigned.name\n      def action: () => Return = thisTest.action\n      def check(run: () => Return): TestResult =\n        try {\n          run()\n          Failure(\"Expected exception not thrown.\")\n        } catch {\n          case e if e == exp => Success\n          case e: Throwable => Failure(s\"Expected exception `$exp`, but found exception `$e`.\")\n        }\n    }\n\n    /*def apply(done: Set[Test] = Set())(implicit reporter: Reporter): TestSummary = {\n      val (_, (success, count)) = dependencies.foldLeft((done, (0, 0))) {\n        case ((d, (s0, n0)), t) =>\n          val (s, n) = if(!d.contains(t)) t(d) else (0, 0)\n          (d + t, (s0 + s, n0 + n))\n      }\n      \n      val tag = reporter.startTask(s\"${name}\")\n      val result = try check(action) catch { case e: Throwable => Error(e) }\n\n      reporter.completeTask(tag, result)\n      result.message foreach { s => reporter.report(s, inset = true) }\n\n      TestSummary(success + (if(result == Success) 1 else 0), count + 1)\n    }*/\n  }\n\n  def test[T](act: => T): Test { type Return = T } = new Test {\n\n    type Return = T\n\n    def name = \"Unnamed test\"\n    def action: () => Return = () => act\n    def check(run: () => Return): TestResult = Success\n  }\n\n}\n\ntrait `run` extends MethodConstraint\n\ncase class TestSummary(successes: Int, failures: Int, errors: Int)\n\nclass BadTestResult(msg: String) extends Exception(msg)\ncase class TestFailure(name: String, error: String) extends BadTestResult(s\"Test `$name` failed with error `$error`\")\n\ncase class TestError(name: String, exception: Throwable)\n    extends BadTestResult(s\"Test `$name` failed with exception `$exception`\")\n\nobject run {\n  def apply[TS <: TestSuite](ts: TS)(implicit mode: Mode[`run`]): Any = macro run.runMacro[TS]\n\n  def doTests(ts: List[TestSuite#Test], mode: Mode[`run`]): mode.Wrap[TestSummary, BadTestResult] = mode.wrap {\n    implicit val reporter: Reporter = new BasicReporter(116, System.out)\n    ansi { implicit tty =>\n      val (successes, failures, errors) = ts.foldLeft((0, 0, 0)) {\n        case ((s, f, e), t) =>\n          val task = reporter.startTask(t.name)\n          val result = t.runCheck()\n          reporter.completeTask(task, result)\n          result.message foreach { msg =>\n            reporter.report(msg, inset = true)\n          }\n          result match {\n            case Success =>\n              (s + 1, f, e)\n            case Failure(msg) =>\n              mode.exception(TestFailure(t.name, msg))\n              (s, f + 1, e)\n            case Error(msg) =>\n              mode.exception(TestError(t.name, msg))\n              (s, f, e + 1)\n          }\n      }\n\n      if (successes + failures + errors == 0) reporter.summary(0, \"No tests found.\")\n      else if (failures + errors == 0) reporter.summary(1, \"All tests passed.\")\n      else if (successes == 0) reporter.summary(-1, \"All tests failed.\")\n      else reporter.summary(0, s\"${successes} out of ${successes + failures + errors} tests passed.\")\n\n      TestSummary(successes, failures, errors)\n    }\n  }\n\n  def runMacro[TS <: TestSuite: c.WeakTypeTag](c: WhiteboxContext)(ts: c.Expr[TS])(\n      mode: c.Expr[Mode[`run`]]): c.Expr[Any] = {\n    import c.universe._\n    import compatibility._\n\n    val cls = weakTypeOf[TS]\n    val allMethods = weakTypeOf[TS].members.to[List].filter(_.isMethod).map(_.asMethod)\n    val matchingMethods = allMethods filter { m =>\n      paramLists(c)(m).isEmpty && m.returnType.weak_<:<(weakTypeOf[TestSuite#Test])\n    }\n    val methodNames = matchingMethods map { m => q\"$ts.${m.name.toTermName}\" }\n\n    c.Expr(q\"\"\"_root_.rapture.test.run.doTests(_root_.scala.List(..$methodNames), $mode)\"\"\")\n  }\n\n  def includeMacro[TS <: TestSuite: c.WeakTypeTag](c: WhiteboxContext)(suite: c.Expr[TS]): c.Expr[Unit] = {\n    import c.universe._\n    import compatibility._\n\n    val cls = weakTypeOf[TS]\n    val allMethods = weakTypeOf[TS].members.to[List].filter(_.isMethod).map(_.asMethod)\n    val matchingMethods = allMethods filter { m =>\n      paramLists(c)(m).isEmpty && m.returnType.weak_<:<(weakTypeOf[TestSuite#Test])\n    }\n    val methodNames = matchingMethods map { m =>\n      val sel = q\"${suite.tree}.${m.name.toTermName}\"\n      val suiteName = cls.toString.replaceAll(\".type$\", \"\").split(\"\\\\.\").last\n      q\"\"\"($suiteName+\" / \"+$sel.name, $sel)\"\"\"\n    }\n\n    c.Expr[Unit](q\"\"\"includeAll(_root_.scala.List(..$methodNames))\"\"\")\n  }\n}\n"
  },
  {
    "path": "text/shared/src/main/scala/rapture/text/ansi.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.text\n\nimport rapture.base._\n\nobject ansi {\n\n  def apply[T](fn: Tty => T) = {\n    val tty = new Tty()\n    try fn(tty)\n    catch {\n      case e: Throwable =>\n        print(normal(tty))\n        throw e\n    } finally print(normal(tty))\n  }\n\n  def esc(implicit tty: Tty) = 27.toChar\n  def normal(implicit tty: Tty) = s\"$esc[0m\"\n  def bold(implicit tty: Tty) = s\"$esc[1m\"\n  def underline(implicit tty: Tty) = s\"$esc[4m\"\n  def blink(implicit tty: Tty) = s\"$esc[5m\"\n  def reverse(implicit tty: Tty) = s\"$esc[7m\"\n  def nondisplayed(implicit tty: Tty) = s\"$esc[8m\"\n  def black(implicit tty: Tty) = s\"$esc[0;30m\"\n  def red(implicit tty: Tty) = s\"$esc[0;31m\"\n  def green(implicit tty: Tty) = s\"$esc[0;32m\"\n  def yellow(implicit tty: Tty) = s\"$esc[0;33m\"\n  def blue(implicit tty: Tty) = s\"$esc[0;34m\"\n  def magenta(implicit tty: Tty) = s\"$esc[0;35m\"\n  def cyan(implicit tty: Tty) = s\"$esc[0;36m\"\n  def white(implicit tty: Tty) = s\"$esc[0;37m\"\n  def boldBlack(implicit tty: Tty) = s\"$esc[1;30m\"\n  def boldRed(implicit tty: Tty) = s\"$esc[1;31m\"\n  def boldGreen(implicit tty: Tty) = s\"$esc[1;32m\"\n  def boldYellow(implicit tty: Tty) = s\"$esc[1;33m\"\n  def boldBlue(implicit tty: Tty) = s\"$esc[1;34m\"\n  def boldMagenta(implicit tty: Tty) = s\"$esc[1;35m\"\n  def boldCyan(implicit tty: Tty) = s\"$esc[1;36m\"\n  def boldWhite(implicit tty: Tty) = s\"$esc[1;37m\"\n\n  def cursor(row: Int, col: Int)(implicit tty: Tty) = s\"$esc[${row};${col}H\"\n  def up(n: Int = 1)(implicit tty: Tty) = s\"$esc[${n}A\"\n  def down(n: Int = 1)(implicit tty: Tty) = s\"$esc[${n}B\"\n  def right(n: Int = 1)(implicit tty: Tty) = s\"$esc[${n}C\"\n  def left(n: Int = 1)(implicit tty: Tty) = s\"$esc[${n}D\"\n\n  def readPassword(prompt: String)(implicit tty: Tty): String = {\n    print(s\"${prompt}$nondisplayed\")\n    val res = compatibility.readLine\n    println(normal)\n    res\n  }\n\n  class Tty private[text] ()\n}\n"
  },
  {
    "path": "text/shared/src/main/scala/rapture/text/text.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.text\n\nobject TextProcess {\n  implicit val defaultTextProcess: TextProcess = unindent()\n}\ntrait TextProcess {\n  def apply(s: String): String\n}\n\nobject unindent {\n  def apply(): TextProcess = implicitTextProcess\n  implicit val implicitTextProcess: TextProcess = new TextProcess {\n    def apply(s: String): String = {\n      val lines = s.split(\"\\n\").dropWhile(_.isEmpty)\n      val indent = lines.headOption.getOrElse(\"\").indexWhere(_ != ' ')\n      lines.map { ln =>\n        if (ln.take(indent).forall(_ == ' ')) ln.drop(indent) else ln.dropWhile(_ == ' ')\n      }.mkString(\"\\n\")\n    }\n  }\n}\n"
  },
  {
    "path": "time/shared/src/main/scala/rapture/time/time.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.time\n\nimport rapture.core._\n\nimport java.util.Calendar\nimport java.text.SimpleDateFormat\n\nobject dateFormats {\n  object shortUs { implicit val implicitDateFormat = DateFormat(\"MM/dd/yy\") }\n  object shortEuropean { implicit val implicitDateFormat = DateFormat(\"dd/MM/yy\") }\n  object longUs { implicit val implicitDateFormat = DateFormat(\"MMMM d, yyyy\") }\n  object longEuropean { implicit val implicitDateFormat = DateFormat(\"d MMMM yyyy\") }\n}\n\nobject timeFormats {\n  object hms { implicit val implicitTimeFormat = TimeFormat(\"HH:mm:ss\") }\n  object hm { implicit val implicitTimeFormat = TimeFormat(\"HH:mm\") }\n  object alternative { implicit val implicitTimeFormat = TimeFormat(\"h.mma\") }\n}\n\ncase class DateFormat(pattern: String) {\n  def format(d: Date): String = {\n    val c = Calendar.getInstance\n    c.setTimeInMillis(d.toLong)\n    new SimpleDateFormat(pattern).format(c.getTime)\n  }\n\n  def format(dt: DateTime): String = {\n    val c = Calendar.getInstance\n    c.setTimeInMillis(dt.toLong)\n    new SimpleDateFormat(pattern).format(c.getTime)\n  }\n}\n\ncase class TimeFormat(pattern: String) {\n  def format(dt: DateTime): String = {\n    val c = Calendar.getInstance\n    c.setTimeInMillis(dt.toLong)\n    new SimpleDateFormat(pattern).format(c.getTime)\n  }\n}\n\nobject Date {\n  def unapply(n: Long) = {\n    val c = Calendar.getInstance\n    c.setTimeInMillis(n)\n    Some(Date(c.get(Calendar.YEAR), c.get(Calendar.MONTH) + 1, c.get(Calendar.DATE)))\n  }\n}\n\nobject DateTime {\n  def unapply(n: Long) = {\n    val Date(date) = n\n    val c = Calendar.getInstance\n    c.setTimeInMillis(n)\n\n    Some(DateTime(date, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), c.get(Calendar.SECOND)))\n  }\n}\n\nobject Time {\n  def apply(hours: Int): Time = Time(hours, 0, 0)\n  def apply(hours: Int, minutes: Int): Time = Time(hours, minutes, 0)\n}\n\nobject `package` {\n\n  def monthString(n: Int) =\n    List(\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\")(n - 1)\n\n  val Jan = Month(1)\n  val Feb = Month(2)\n  val Mar = Month(3)\n  val Apr = Month(4)\n  val May = Month(5)\n  val Jun = Month(6)\n  val Jul = Month(7)\n  val Aug = Month(8)\n  val Sep = Month(9)\n  val Oct = Month(10)\n  val Nov = Month(11)\n  val Dec = Month(12)\n\n  implicit class TimeEnrichedString(s: StringContext) {\n    private val Matcher1 = \"([0-9][0-9]):([0-9][0-9])\".r\n    private val Matcher2 = \"([0-9][0-9]):([0-9][0-9]):([0-9][0-9])\".r\n    def t(args: Int*): Time = s.parts.head match {\n      case Matcher1(h, m) => Time(h.toInt, m.toInt)\n      case Matcher2(h, m, s) => Time(h.toInt, m.toInt, s.toInt)\n    }\n  }\n\n  implicit val dateOrder = new Ordering[Date] {\n    def compare(d1: Date, d2: Date) = if (d1 < d2) -1 else if (d2 == d1) 0 else 1\n  }\n\n  implicit val dateTimeOrder = new Ordering[DateTime] {\n    def compare(d1: DateTime, d2: DateTime) = if (d1 < d2) -1 else if (d2 == d1) 0 else 1\n  }\n\n  def now() = DateTime.unapply(System.currentTimeMillis).get\n\n  implicit class IntoMonth(d: Int) {\n    def -(m: Month) = new IntoDay(m)\n\n    class IntoDay(m: Month) {\n      def -(y: Int) = Date(y, m.no, d)\n    }\n  }\n}\ncase class Time(hours: Int, minutes: Int, seconds: Int)\n\ncase class Date(year: Int, month: Int, day: Int) { date =>\n\n  override def toString() =\n    day + \"-\" + monthString(month) + \"-\" + year\n\n  def +(n: Int) = Date.unapply(n + toLong).get\n  def -(n: Int) = Date.unapply(toLong - n).get\n\n  override def equals(that: Any): Boolean = that match {\n    case that: Date => toLong == that.toLong\n    case that: DateTime => toLong == that.toLong\n    case _ => false\n  }\n\n  def toLong = {\n    val c = Calendar.getInstance\n    c.set(Calendar.YEAR, year)\n    c.set(Calendar.MONTH, month - 1)\n    c.set(Calendar.DATE, day)\n    c.getTimeInMillis\n  }\n\n  def at(time: Time) = DateTime(date, time.hours, time.minutes, time.seconds)\n\n  def at(hours: Int) = new {\n    def h(minutes: Int) = new DateTime(date, hours, minutes, 0) {\n      def m(seconds: Int) = DateTime(date, hours, minutes, seconds)\n    }\n  }\n\n  def >(that: Date): Boolean = toLong > that.toLong\n  def <(that: Date): Boolean = toLong < that.toLong\n  def >=(that: Date): Boolean = toLong >= that.toLong\n  def <=(that: Date): Boolean = toLong <= that.toLong\n\n  def format(implicit dateFormat: DateFormat) = dateFormat.format(this)\n}\n\ncase class DateTime(date: Date, hour: Int, minute: Int, second: Int) {\n\n  def pad(n: Int) = if (n < 10) \"0\" + n else n\n\n  def +(n: Int) = DateTime.unapply(n + toLong).get\n  def -(n: Int) = DateTime.unapply(toLong - n).get\n  def -(d: DateTime): Long = toLong - d.toLong\n\n  override def toString() =\n    date.toString + \" \" + pad(hour) + \":\" + pad(minute) + \":\" + pad(second)\n\n  override def equals(that: Any): Boolean = that match {\n    case that: Date => toLong == that.toLong\n    case that: DateTime => toLong == that.toLong\n    case _ => false\n  }\n\n  def >(that: DateTime): Boolean = toLong > that.toLong\n  def <(that: DateTime): Boolean = toLong < that.toLong\n  def >=(that: DateTime): Boolean = toLong >= that.toLong\n  def <=(that: DateTime): Boolean = toLong <= that.toLong\n\n  def toLong = {\n    val c = Calendar.getInstance\n    c.setTimeInMillis(0L)\n    c.set(Calendar.YEAR, date.year)\n    c.set(Calendar.MONTH, date.month - 1)\n    c.set(Calendar.DATE, date.day)\n    c.set(Calendar.HOUR, hour)\n    c.set(Calendar.MINUTE, minute)\n    c.set(Calendar.SECOND, second)\n    c.getTimeInMillis\n  }\n\n  def format(implicit dateFormat: DateFormat, timeFormat: TimeFormat) =\n    dateFormat.format(this) + \" \" + timeFormat.format(this)\n}\n\ncase class Month(no: Int)\n"
  },
  {
    "path": "unixsocket/jvm/src/main/scala/rapture/unixsocket/UnixSocketHttpClient.scala",
    "content": "package rapture.unixsocket\n\nimport java.io.File\nimport java.net.{Socket, InetSocketAddress}\nimport java.util.concurrent.TimeUnit\n\nimport org.apache.http.{HttpRequest, HttpHost}\nimport org.apache.http.config.SocketConfig\nimport org.apache.http.conn.{ManagedHttpClientConnection, HttpClientConnectionOperator, SchemePortResolver}\nimport org.apache.http.impl.conn.{PoolingHttpClientConnectionManager, ManagedHttpClientConnectionFactory, DefaultHttpResponseParserFactory, DefaultRoutePlanner}\nimport org.apache.http.impl.client.HttpClients\nimport org.apache.http.impl.io.DefaultHttpRequestWriterFactory\nimport org.apache.http.protocol.HttpContext\n\nimport org.newsclub.net.unix.{AFUNIXSocketAddress, AFUNIXSocket}\n\nobject UnixSocketHttpClient {\n\n  /**\n    * Executes an HttpRequest\n    * @param host The custom HttpHost (the hostname is actually the socket file)\n    * @param request The HttpRequest (eg. GET /)\n    * @return The CloseableHttpResponse\n    */\n  def execute(host: HttpHost, request: HttpRequest) =\n    client.execute(host, request)\n\n  /**\n    * Create the customized http client\n    */\n  private val client = HttpClients\n    .custom\n    .setConnectionManager(connectionManager)\n    .setConnectionManagerShared(true)\n    .setRoutePlanner(routePlanner)\n    .build\n\n  /**\n    * The customized connection manager\n    */\n  private def connectionManager = new PoolingHttpClientConnectionManager(connectionOperator, connectionFactory, -1, TimeUnit.MILLISECONDS)\n\n  /**\n    * A route planner with our custom scheme port resolver\n    */\n  private def routePlanner = new DefaultRoutePlanner(schemePortResolver)\n\n  /**\n    * Our connection operator\n    * It will create unix socket connections for us\n    */\n  private def connectionOperator = new HttpClientConnectionOperator {\n\n    /**\n      * Creates the socket for our request, which is a unix socket.\n      */\n    def connect(conn: ManagedHttpClientConnection, host: HttpHost, localAddress: InetSocketAddress,\n                connectTimeout: Int, socketConfig: SocketConfig, context: HttpContext): Unit = {\n      val sock: Socket = AFUNIXSocket.newInstance\n      sock.setTcpNoDelay(socketConfig.isTcpNoDelay)\n      if (socketConfig.getRcvBufSize > 0) {\n        sock.setReceiveBufferSize(socketConfig.getRcvBufSize)\n      }\n      if (socketConfig.getSndBufSize > 0) {\n        sock.setSendBufferSize(socketConfig.getSndBufSize)\n      }\n      val linger: Int = socketConfig.getSoLinger\n      if (linger >= 0) {\n        sock.setSoLinger(true, linger)\n      }\n      sock.connect(new AFUNIXSocketAddress(new File(host.getHostName)), connectTimeout)\n      conn.bind(sock)\n    }\n\n    /**\n      * Can upgrade an http connection. This is only used for proxies - so we don't need it\n      */\n    def upgrade(conn: ManagedHttpClientConnection, host: HttpHost, context: HttpContext) =\n      throw new NotImplementedError(\"upgrade is not supported - a unix-socket cannot be accessed through a proxy\")\n\n  }\n\n  /**\n    * A default managed connection factory\n    */\n  private def connectionFactory = new ManagedHttpClientConnectionFactory(\n    new DefaultHttpRequestWriterFactory(),\n    new DefaultHttpResponseParserFactory()\n  )\n\n  /**\n    * Resolves the port for the \"unix\" scheme\n    * We don't actually need a port, but an NPE will be thrown if we don't replace it.\n    */\n  private def schemePortResolver = new SchemePortResolver { def resolve(host: HttpHost) = 0 }\n\n}\n\n"
  },
  {
    "path": "unixsocket/jvm/src/main/scala/rapture/unixsocket/UnixSocketHttpUrl.scala",
    "content": "package rapture.unixsocket\n\nimport rapture.core.ParseException\n\ncase class UnixSocketHttpUrl(socketFileName: String, queryString: String, queryParams: Option[String])\n\nobject UnixSocketHttpUrl {\n\n  private val UnixSocketRegex = \"\"\"unix:\\/\\/(\\/[^:]+):(\\/?[^\\?]*)(\\?[^\\?]*)?\"\"\".r\n\n  @throws[ParseException]\n  def parse(unixSocketUrl: String): UnixSocketHttpUrl = {\n    unixSocketUrl match {\n      case UnixSocketRegex(unixSocket, queryUrl, queryParams) => UnixSocketHttpUrl(unixSocket, queryUrl, Option(queryParams))\n      case _ => throw new ParseException(unixSocketUrl, \"unix socket url\")\n    }\n  }\n\n}\n\n"
  },
  {
    "path": "unixsocket/jvm/src/main/scala/rapture/unixsocket/package.scala",
    "content": "package rapture\n\nimport rapture.core.`package`._\nimport rapture.core.Mode\nimport rapture.io.OutputStreamBuilder\nimport rapture.io.`package`._\nimport rapture.net._\nimport rapture.uri.UriContext\n\nimport java.io._\n\nimport org.apache.http.HttpHost\nimport org.apache.http.client.config.RequestConfig\nimport org.apache.http.client.methods._\nimport org.apache.http.entity.AbstractHttpEntity\n\npackage object unixsocket {\n\n\n  implicit class EnrichedUnixUriContext(uc: UriContext.type) {\n    // `unix+http` as method name did not play well with the implicit conversion it seems :(\n    def unix(constants: List[String])(variables: List[String]) = {\n      var unixSocketUrl = \"unix:\" + constants.zip(variables :+ \"\").map { case (a, b) => a+b }.mkString\n      UnixSocketHttpUrl.parse(unixSocketUrl)\n    }\n  }\n\n\n  implicit def basicHttpSupport: HttpSupport[UnixSocketHttpUrl] = new HttpSupport[UnixSocketHttpUrl] {\n\n    def doHttp[C: PostType, T](unixSocketHttpUrl: UnixSocketHttpUrl, content: C,\n                               headers: Map[String, String] = Map(),method: String = \"POST\")\n                              (implicit mode: Mode[`NetUrl#httpPost`], httpTimeout: HttpTimeout,\n                               httpRedirectConfig: HttpRedirectConfig, httpCertificateConfig: HttpCertificateConfig,\n                               httpBasicAuthentication: HttpBasicAuthentication):\n                              mode.Wrap[HttpResponse, HttpExceptions with httpTimeout.Throws] =\n      mode wrap {\n\n        val host = HttpHost.create(s\"unix://${unixSocketHttpUrl.socketFileName}\")\n\n        val url = unixSocketHttpUrl.queryString + unixSocketHttpUrl.queryParams.getOrElse(\"\")\n\n        class InvertedHttpEntity extends AbstractHttpEntity {\n\n          override def isRepeatable: Boolean = false\n\n          override def getContentLength: Long = -1\n\n          override def isStreaming: Boolean = false\n\n          override def getContent: InputStream = throw new UnsupportedOperationException\n\n          override def writeTo(outputStream: OutputStream): Unit = {\n            ensuring(OutputStreamBuilder.output(outputStream)) { out =>\n              ?[PostType[C]].sender(content) > out\n            }\n          }\n\n        }\n\n        val request = method.toUpperCase match {\n          case \"GET\"    => new HttpGet(url)\n          case \"POST\"   => {\n            val post = new HttpPost(url)\n            if(content != None)\n              post.setEntity(new InvertedHttpEntity)\n            post\n          }\n          case \"PUT\"    => {\n            val put = new HttpPut(url)\n            if(content != None)\n              put.setEntity(new InvertedHttpEntity)\n            put\n          }\n          case \"DELETE\" => new HttpDelete(url)\n        }\n\n        val config = RequestConfig\n          .custom()\n          .setConnectTimeout(httpTimeout.duration)\n          .build\n\n        request.setConfig(config)\n\n        def base64encode(content: String) =\n          NetUrl.base64.encode(content.getBytes(\"UTF-8\")).mkString\n\n        httpBasicAuthentication.credentials foreach {\n          case (username, password) =>\n            request.setHeader(\"Authorization\", \"Basic \" + base64encode(s\"$username:$password\"))\n        }\n\n        ?[PostType[C]]\n          .contentType\n          .foreach { ct => request.setHeader(\"Content-Type\", ct.name) }\n\n        for((k, v) <- headers) request.setHeader(k, v)\n\n        val response = UnixSocketHttpClient.execute(host, request)\n\n        val statusLine = response.getStatusLine\n\n        val statusCode = statusLine.getStatusCode\n\n        val responseHeaders = response.getAllHeaders.map(header => (header.getName, List(header.getValue))).toMap\n\n        new HttpResponse(responseHeaders, statusCode, response.getEntity.getContent)\n      }\n  }\n\n}\n"
  },
  {
    "path": "uri/shared/src/main/scala/rapture/uri/classpath.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.uri\n\nimport rapture.core._\n\nobject ClasspathUrl {\n\n  implicit def cpSlashString: Dereferenceable[ClasspathUrl, String, ClasspathUrl] =\n    new Dereferenceable[ClasspathUrl, String, ClasspathUrl] {\n      def dereference(p1: ClasspathUrl, p2: String) = ClasspathUrl(p1.elements :+ p2)\n    }\n\n  implicit def cpSlashRelativePath[RP <: RelativePath]: Dereferenceable[ClasspathUrl, RP, ClasspathUrl] =\n    new Dereferenceable[ClasspathUrl, RP, ClasspathUrl] {\n      def dereference(p1: ClasspathUrl, p2: RP) = ClasspathUrl(p1.elements.dropRight(p2.ascent) ++ p2.elements)\n    }\n\n  implicit def uriCapable: UriCapable[ClasspathUrl] = new UriCapable[ClasspathUrl] {\n    def uri(cp: ClasspathUrl) = Uri(\"classpath\", cp.elements.mkString(\"/\"))\n  }\n}\n\ncase class ClasspathUrl(elements: Vector[String]) {\n  override def toString: String = s\"classpath:${elements.mkString(\"/\")}\"\n}\n"
  },
  {
    "path": "uri/shared/src/main/scala/rapture/uri/macros.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.uri\n\nimport rapture.base._\nimport rapture.core._\n\nobject Paramable {\n  implicit val stringParamable = new Paramable[String] { def paramize(s: String): String = s }\n  implicit val intParamable = new Paramable[Int] { def paramize(s: Int): String = s.toString }\n  implicit val doubleParamable = new Paramable[Double] { def paramize(s: Double): String = s.toString }\n}\n\ntrait Paramable[T] {\n  def paramize(t: T): String\n}\n\nobject UriMacros {\n\n  def uriMacro(c: WhiteboxContext)(content: c.Expr[String]*): c.Expr[Any] = {\n    import c.universe._\n    import compatibility._\n\n    c.prefix.tree match {\n      case Apply(_, List(Apply(_, rawParts))) =>\n        rawParts.head match {\n          case Literal(Constant(part: String)) =>\n            val scheme = part.split(\":\", 2) match {\n              case Array(s, _) => s\n              case _ => c.abort(c.enclosingPosition, \"could not find a valid scheme for this URI.\")\n            }\n\n            val constants: List[String] = rawParts.map {\n              case Literal(Constant(s: String)) => s\n            }\n            \n            val constantsAfterScheme = constants match {\n              case h :: t => h.substring(scheme.length + 1) :: t\n              case Nil => Nil\n            }\n\n            val variables = content.map(_.tree).to[List]\n            c.Expr(q\"\"\"_root_.rapture.uri.UriContext.${termName(c, scheme)}(_root_.scala.List(\n                ..$constantsAfterScheme))(_root_.scala.List(..$variables))\"\"\")\n        }\n    }\n  }\n}\n"
  },
  {
    "path": "uri/shared/src/main/scala/rapture/uri/nav.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.uri\nimport rapture.core._\n\ntrait `Navigable#children` extends MethodConstraint\ntrait `Navigable#descendants` extends MethodConstraint\ntrait `Navigable#isDirectory` extends MethodConstraint\ntrait `Navigable#walkFilter` extends MethodConstraint\n\ntrait Navigable[UrlType] {\n\n  def children(url: UrlType)(implicit mode: Mode[`Navigable#children`]): mode.Wrap[Seq[UrlType], Exception]\n\n  /** Returns false if the filesystem object represented by this FsUrl is a file, and true if\n    * it is a directory. */\n  def isDirectory(url: UrlType)(implicit mode: Mode[`Navigable#isDirectory`]): mode.Wrap[Boolean, Exception]\n\n  /** If this represents a directory, returns an iterator over all its descendants,\n    * otherwise returns the empty iterator. */\n  def descendants(url: UrlType)(\n      implicit mode: Mode[`Navigable#descendants`]): mode.Wrap[Iterator[UrlType], Exception] =\n    mode wrap {\n      children(url)(modes.throwExceptions()).iterator.flatMap { c =>\n        if (isDirectory(c)(modes.throwExceptions()))\n          Iterator(c) ++ descendants(c)(modes.throwExceptions())\n        else Iterator(c)\n      }\n    }\n}\n\nclass NavigableExtras[UrlType: Navigable](url: UrlType) {\n\n  /** Return a sequence of children of this URL */\n  def children(implicit mode: Mode[`Navigable#children`]) =\n    mode flatWrap ?[Navigable[UrlType]].children(url)\n\n  /** Return true if this URL node is a directory (i.e. it can contain other URLs). */\n  def isDirectory(implicit mode: Mode[`Navigable#isDirectory`]): mode.Wrap[Boolean, Exception] =\n    mode flatWrap ?[Navigable[UrlType]].isDirectory(url)\n\n  /** Return an iterator of all descendants of this URL. */\n  def descendants(implicit mode: Mode[`Navigable#descendants`]): mode.Wrap[Iterator[UrlType], Exception] =\n    mode flatWrap ?[Navigable[UrlType]].descendants(url)\n\n  def walkFilter(cond: UrlType => Boolean)(\n      implicit mode: Mode[`Navigable#walkFilter`]): mode.Wrap[Seq[UrlType], Exception] = mode wrap {\n    children(modes.throwExceptions()) filter cond flatMap { f =>\n      new NavigableExtras(f).walkFilter(cond)(modes.throwExceptions())\n    }\n  }\n}\n"
  },
  {
    "path": "uri/shared/src/main/scala/rapture/uri/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.uri\n\nimport rapture.core._\n\nimport language.experimental.macros\nimport scala.language.implicitConversions\n\nobject UriContext\n\nobject `package` {\n\n  implicit class EnrichedStringContext(sc: StringContext) {\n    def uri(content: String*): Any = macro UriMacros.uriMacro\n  }\n\n  implicit class EnrichedUriContext(uc: UriContext.type) {\n    def classpath(constants: List[String])(variables: List[String]) =\n      new ClasspathUrl(constants.zip(variables :+ \"\").map { case (a, b) => a + b }.mkString.split(\"/\").to[Vector])\n  }\n\n  val $ : String = \"\"\n\n  val !! : String = \"..\"\n\n  object ^ extends RootedPath(Vector())\n\n  implicit def dereferenceable[Res](res: Res): Dereferenceable.Capability[Res] = alloc(res)\n  implicit def uriCapable[Res: UriCapable](res: Res): UriCapable.Capability[Res] = alloc(res)\n  implicit def linkCapable[Res: Linkable](res: Res): Linkable.Capability[Res] = alloc(res)\n  implicit def parentable[Res](res: Res): Parentable.Capability[Res] = alloc(res)\n  implicit def navigableExtras[Res: Navigable](url: Res): NavigableExtras[Res] =\n    new NavigableExtras(url)\n\n}\n"
  },
  {
    "path": "uri/shared/src/main/scala/rapture/uri/paths.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.uri\n\nimport scala.annotation.implicitNotFound\n\nobject RelativePath {\n  implicit val relativePathLinkable: Linkable[RelativePath] = new Linkable[RelativePath] {\n    def link(res: RelativePath): PathLink = PathLink(res.toString)\n  }\n\n  val Self: RelativePath = RelativePath(0, Vector())\n}\n\ncase class RelativePath(ascent: Int, elements: Vector[String]) {\n  override def toString = if (ascent == 0 && elements.isEmpty) \".\" else \"../\" * ascent + elements.mkString(\"/\")\n\n  override def equals(that: Any) = that match {\n    case RelativePath(a, es) => a == ascent && es == elements\n    case _ => false\n  }\n\n  override def hashCode = ascent ^ elements.hashCode\n}\n\nobject RootedPath {\n  def parse(s: String): Option[RootedPath] = {\n    if (s.head == '/') Some(RootedPath(s.tail.split(\"/\").to[Vector]))\n    else None\n  }\n\n  implicit val linkable: Linkable[RootedPath] = new Linkable[RootedPath] {\n    def link(res: RootedPath): PathLink = PathLink(res.toString)\n  }\n}\n\nobject / {\n  def unapply(p: RootedPath): Option[(RootedPath, String)] =\n    if (p.elements.isEmpty) None\n    else Some((RootedPath(p.elements.init), p.elements.last))\n}\n\ncase class RootedPath(elements: Vector[String]) {\n  override def toString = elements.mkString(\"/\", \"/\", \"\")\n\n  override def equals(that: Any) = that match {\n    case RootedPath(es) => es == elements\n    case _ => false\n  }\n\n  override def hashCode = elements.hashCode\n}\n\nobject Dereferenceable {\n  implicit val stringSlashString: Dereferenceable[String, String, RelativePath] =\n    new Dereferenceable[String, String, RelativePath] {\n      def dereference(p1: String, p2: String): RelativePath = RelativePath(0, Vector(p1, p2))\n    }\n\n  implicit def relativePathSlashString[RP <: RelativePath]: Dereferenceable[RP, String, RelativePath] =\n    new Dereferenceable[RP, String, RelativePath] {\n      def dereference(p1: RP, p2: String): RelativePath = RelativePath(p1.ascent, p1.elements :+ p2)\n    }\n\n  implicit def rootSlashString[RRP <: RootedPath]: Dereferenceable[RRP, String, RootedPath] =\n    new Dereferenceable[RRP, String, RootedPath] {\n      def dereference(p1: RRP, p2: String): RootedPath = RootedPath(p1.elements :+ p2)\n    }\n\n  implicit def rootSlashRelative[RRP <: RootedPath, RP <: RelativePath]: Dereferenceable[RRP, RP, RootedPath] =\n    new Dereferenceable[RRP, RP, RootedPath] {\n      def dereference(p1: RRP, p2: RP): RootedPath = RootedPath(p2.elements ++ p1.elements.drop(p2.ascent))\n    }\n\n  class Capability[Path](val path: Path) {\n    def /[Elem, Return](elem: Elem)(implicit deref: Dereferenceable[Path, Elem, Return]): Return =\n      deref.dereference(path, elem)\n  }\n}\n\n@implicitNotFound(\"it is not possible to dereference a value of type ${P1} by a value of type ${P2}.\")\ntrait Dereferenceable[-P1, -P2, +Return] {\n  def dereference(p1: P1, p2: P2): Return\n}\n\nobject Parentable {\n  implicit def relativePathParent[RP <: RelativePath]: Parentable[RP, RelativePath] =\n    new Parentable[RP, RelativePath] {\n      def parent(p: RP): RelativePath =\n        RelativePath(if (p.elements.isEmpty) p.ascent + 1 else p.ascent, p.elements.dropRight(1))\n    }\n\n  implicit def rootRelativePathParent[RRP <: RootedPath]: Parentable[RRP, RootedPath] =\n    new Parentable[RRP, RootedPath] {\n      def parent(p1: RRP): RootedPath = RootedPath(p1.elements.dropRight(1))\n    }\n\n  class Capability[Path](val path: Path) {\n    def parent[Return](implicit parentable: Parentable[Path, Return]): Return =\n      parentable.parent(path)\n  }\n}\n\n@implicitNotFound(\"type ${P} does not have a parent\")\ntrait Parentable[-P, +Return] {\n  def parent(p1: P): Return\n}\n"
  },
  {
    "path": "uri/shared/src/main/scala/rapture/uri/uri.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.uri\n\nobject UriCapable {\n  class Capability[Res: UriCapable](res: Res) {\n    def uri: Uri = implicitly[UriCapable[Res]].uri(res)\n  }\n}\n\ncase class Uri(scheme: String, schemeSpecificPart: String) {\n  override def toString: String = s\"$scheme:$schemeSpecificPart\"\n}\n\ntrait UriCapable[-Res] {\n  def uri(res: Res): Uri\n}\n\nobject Linkable {\n  class Capability[Res: Linkable](res: Res) {\n    def link: PathLink = implicitly[Linkable[Res]].link(res)\n  }\n\n  implicit def linkableUri[Res: UriCapable]: Linkable[Res] = new Linkable[Res] {\n    def link(res: Res): PathLink = PathLink(implicitly[UriCapable[Res]].uri(res).toString)\n  }\n}\n\nobject PathLink {\n  implicit def linkLinkable: Linkable[PathLink] = new Linkable[PathLink] {\n    def link(lnk: PathLink): PathLink = lnk\n  }\n}\n\ncase class PathLink(link: String) {\n  override def toString: String = link\n}\n\ntrait Linkable[-Res] {\n  def link(res: Res): PathLink\n}\n"
  },
  {
    "path": "version.sbt",
    "content": "version in ThisBuild := \"2.0.0-M9\"\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nimport rapture.core._\nimport rapture.data._\n\nimport scala.util._\nimport scala.collection.immutable._\n\ntrait XmlAst extends DataAst {\n\n  def isScalar(any: Any) = isString(any)\n\n  def getScala(any: Any) = Try(getString(any)) getOrElse { throw new Exception }\n\n  def getString(string: Any): String\n\n  def fromString(string: String): Any\n\n  def isComment(any: Any): Boolean\n\n  def isPi(any: Any): Boolean\n\n  def getPiText(any: Any): String\n\n  def getComment(any: Any): String\n\n  def getAttributes(obj: Any): Map[String, String]\n\n  /** Tests if the element represents a `String` */\n  def isString(any: Any): Boolean\n\n  /** Returns the DataType instance for the particular type. */\n  def getType(any: Any): DataTypes.DataType =\n    if (isString(any)) DataTypes.String\n    else if (isObject(any)) DataTypes.Object\n    else if (isArray(any)) DataTypes.Array\n    else throw MissingValueException()\n\n  def convert(v: Any, ast: DataAst): Any = {\n    val oldAst = ast.asInstanceOf[XmlAst]\n    if (oldAst.isString(v)) fromString(oldAst.getString(v))\n    else if (oldAst.isArray(v)) fromArray(oldAst.getArray(v).map(convert(_, oldAst)))\n    else if (oldAst.isObject(v)) fromObject(oldAst.getObject(v).mapValues(convert(_, oldAst)))\n    else nullValue\n  }\n\n  val nullValue = \"\"\n\n  protected def typeTest(pf: PartialFunction[Any, Unit])(v: Any) = pf.isDefinedAt(v)\n}\n\ntrait XmlBufferAst extends XmlAst with MutableDataAst\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/context.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nimport rapture.base._\nimport rapture.core._\nimport rapture.data._\n\nimport language.experimental.macros\n\nprivate[xml] object XmlDataMacros extends DataContextMacros[Xml, XmlAst] {\n\n  def dataCompanion(c: BlackboxContext): c.Expr[DataCompanion[Xml, XmlAst]] = c.universe.reify(Xml)\n\n  def parseSource(s: List[String], stringsUsed: List[Boolean]) =\n    try {\n      XmlValidator.validate(s)\n      None\n    } catch {\n      case XmlValidator.ValidationException(strNo, pos, expected, found) =>\n        val f = if (found == '\\u0000') \"end of input\" else s\"'$found'\"\n        Some((strNo, pos, s\"failed to parse Xml literal: expected $expected, but found $f\"))\n      case XmlValidator.DuplicateKeyException(strNo, pos, key) =>\n        Some((strNo, pos, s\"\"\"duplicate key found in Xml literal: \"$key\"\"\"\"))\n    }\n\n  override def contextMacro(c: BlackboxContext)(exprs: c.Expr[ForcedConversion[Xml]]*)(\n      parser: c.Expr[Parser[String, XmlAst]]): c.Expr[Xml] =\n    super.contextMacro(c)(exprs: _*)(parser)\n\n}\n\nprivate[xml] object XmlBufferDataMacros extends DataContextMacros[XmlBuffer, XmlBufferAst] {\n\n  def dataCompanion(c: BlackboxContext): c.Expr[DataCompanion[XmlBuffer, XmlBufferAst]] =\n    c.universe.reify(XmlBuffer)\n\n  def parseSource(s: List[String], stringsUsed: List[Boolean]) =\n    try {\n      XmlValidator.validate(s)\n      None\n    } catch {\n      case XmlValidator.ValidationException(strNo, pos, expected, found) =>\n        val f = if (found == '\\u0000') \"end of input\" else s\"'$found'\"\n        Some((strNo, pos, s\"Failed to parse XmlBuffer literal: Expected $expected, but found $f.\"))\n    }\n\n  override def contextMacro(c: BlackboxContext)(exprs: c.Expr[ForcedConversion[XmlBuffer]]*)(\n      parser: c.Expr[Parser[String, XmlBufferAst]]): c.Expr[XmlBuffer] =\n    super.contextMacro(c)(exprs: _*)(parser)\n}\n\n/** Provides support for XML literals, in the form xml\" { } \" or xml\"\"\" { } \"\"\".\n  * Interpolation is used to substitute variable names into the XML, and to extract values\n  * from a XML string. */\nprivate[xml] class XmlStrings(sc: StringContext) {\n  class XmlContext() extends DataContext(Xml, sc) {\n    def apply(exprs: ForcedConversion[Xml]*)(implicit parser: Parser[String, XmlAst]): Xml = macro XmlDataMacros.contextMacro\n  }\n  val xml = new XmlContext()\n}\n\nprivate[xml] class XmlBufferStrings(sc: StringContext) {\n  class XmlBufferContext() extends DataContext(XmlBuffer, sc) {\n    def apply(exprs: ForcedConversion[XmlBuffer]*)(implicit parser: Parser[String, XmlBufferAst]): XmlBuffer = macro XmlBufferDataMacros.contextMacro\n  }\n  val xmlBuffer = new XmlBufferContext()\n}\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nimport rapture.core._\nimport rapture.data._\n\nimport scala.util._\n\nimport language.higherKinds\n\nprivate[xml] case class XmlCastExtractor[T](ast: XmlAst, dataType: DataTypes.DataType)\n\nprivate[xml] trait Extractors extends Extractors_1 {\n\n  implicit def optionExtractor[T](\n      implicit ext: Extractor[T, Xml]): Extractor[Option[T], Xml] { type Throws = Nothing } =\n    GeneralExtractors.optionExtractor[Xml, T]\n\n  implicit def tryExtractor[T](implicit ext: Extractor[T, Xml]): Extractor[Try[T], Xml] { type Throws = Nothing } =\n    GeneralExtractors.tryExtractor[Xml, T]\n\n  implicit def genSeqExtractor[T, Coll[_]](\n      implicit cbf: scala.collection.generic.CanBuildFrom[Nothing, T, Coll[T]],\n      ext: Extractor[T, Xml]): Extractor[Coll[T], Xml] { type Throws = ext.Throws } = {\n\n    GeneralExtractors.genSeqExtractor[T, Coll, Xml]\n  }\n\n  implicit def xmlExtractor(implicit ast: XmlAst): Extractor[Xml, Xml] { type Throws = DataGetException } =\n    new Extractor[Xml, Xml] {\n      type Throws = DataGetException\n      def extract(any: Xml, dataAst: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[Xml, DataGetException] =\n        mode.wrap(mode.catching[DataGetException, Xml](any.$wrap(any.$normalize)))\n    }\n\n}\n\nprivate[xml] trait Extractors_1 {\n\n  implicit def stringableExtractors[T](implicit ext: StringParser[T]): Extractor[T, Xml] {\n    type Throws = DataGetException with ext.Throws\n  } = new Extractor[T, Xml] {\n\n    type Throws = DataGetException with ext.Throws\n\n    def extract(any: Xml,\n                ast: DataAst,\n                mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, DataGetException with ext.Throws] = mode.wrap {\n      val value: String = mode.catching[DataGetException, String](any.$ast.getString(any.$normalize))\n      mode.unwrap(ext.parse(value, mode))\n    }\n  }\n\n  implicit def xmlBufferExtractor[T](implicit xmlAst: XmlAst,\n                                     ext: Extractor[T, Xml]): Extractor[T, XmlBuffer] { type Throws = ext.Throws } =\n    new Extractor[T, XmlBuffer] {\n      type Throws = ext.Throws\n      def extract(any: XmlBuffer, ast: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, ext.Throws] =\n        ext.extract(Xml.construct(MutableCell(any.$root.value), Vector()), ast, mode)\n    }\n\n  implicit def xmlBufferToXmlExtractor(implicit ast: XmlBufferAst): Extractor[XmlBuffer, Xml] =\n    new Extractor[XmlBuffer, Xml] {\n      type Throws = DataGetException\n      def extract(any: Xml, dataAst: DataAst, mode: Mode[_ <: MethodConstraint]): mode.Wrap[XmlBuffer, Throws] =\n        mode.wrap(XmlBuffer.construct(MutableCell(XmlDataType.xmlSerializer.serialize(any)), Vector()))\n    }\n\n}\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/formatters.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nimport rapture.core._\nimport rapture.data._\n\nobject formatters {\n  object compact {\n    def apply[Ast <: XmlAst]()(implicit ast: Ast): Formatter[Ast] { type Out = String } = xmlFormatterImplicit[Ast]\n\n    implicit def xmlFormatterImplicit[Ast <: XmlAst](implicit ast: Ast): Formatter[Ast] { type Out = String } =\n      new Formatter[Ast] {\n        type Out = String\n        // FIXME: This is a lazy implementation\n        def format(xml: Any): String = xml.toString\n      }\n  }\n}\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/macros.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nimport rapture.base._\nimport rapture.data._\n\nprivate[xml] object XmlMacros {\n  def xmlExtractorMacro[T: c.WeakTypeTag, Th](c: WhiteboxContext): c.Expr[Extractor[T, Xml]] =\n    Macros.extractorMacro[T, Xml, Th](c)\n\n  //def xmlBufferExtractorMacro[T: c.WeakTypeTag](c: Context) =\n  //  Macros.extractorMacro2[T, XmlBuffer](c)\n\n  def xmlSerializerMacro[T: c.WeakTypeTag](c: WhiteboxContext)(ast: c.Expr[XmlAst]): c.Expr[Serializer[T, Xml]] =\n    Macros.serializerMacro[T, Xml](c)(ast)\n\n  def xmlBufferSerializerMacro[T: c.WeakTypeTag](c: WhiteboxContext)(\n      ast: c.Expr[XmlBufferAst]): c.Expr[Serializer[T, XmlBuffer]] =\n    Macros.serializerMacro[T, XmlBuffer](c)(ast)\n}\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nimport rapture.core._\nimport rapture.data._\n\nobject `package` {\n\n  val patternMatching = rapture.data.patternMatching\n\n  type Extractor[T, -D] = rapture.data.Extractor[T, D]\n  type Serializer[T, -D] = rapture.data.Serializer[T, D]\n  type DataGetException = rapture.data.DataGetException\n  type TypeMismatchException = rapture.data.TypeMismatchException\n  type MissingValueException = rapture.data.MissingValueException\n\n  val TypeMismatchException = rapture.data.TypeMismatchException\n  val MissingValueException = rapture.data.MissingValueException\n\n  implicit def xmlStringContext(sc: StringContext)(implicit parser: Parser[String, XmlAst]) =\n    new XmlStrings(sc)\n\n  implicit def xmlBufferStringContext(sc: StringContext)(implicit parser: Parser[String, XmlBufferAst]) =\n    new XmlBufferStrings(sc)\n}\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nimport rapture.core._\nimport rapture.data._\n\nimport language.higherKinds\n\nprivate[xml] case class DirectXmlSerializer[T](ast: XmlAst)\n\nprivate[xml] case class BasicXmlSerializer[T](serialization: T => Any) extends Serializer[T, Xml] {\n  def serialize(t: T): Any = serialization(t)\n}\n\nprivate[xml] trait Serializers extends Serializers_1{\n\n  implicit def xmlBufferSerializer[T](implicit ser: Serializer[T, Xml]): Serializer[T, XmlBuffer] =\n    new Serializer[T, XmlBuffer] { def serialize(t: T): Any = ser.serialize(t) }\n\n  implicit def intSerializer(implicit ast: XmlAst): Serializer[Int, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def booleanSerializer(implicit ast: XmlAst): Serializer[Boolean, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def stringSerializer(implicit ast: XmlAst): Serializer[String, Xml] =\n    BasicXmlSerializer(ast.fromString)\n\n  implicit def floatSerializer(implicit ast: XmlAst): Serializer[Float, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def doubleSerializer(implicit ast: XmlAst): Serializer[Double, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def bigDecimalSerializer(implicit ast: XmlAst): Serializer[BigDecimal, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def bigIntSerializer(implicit ast: XmlAst): Serializer[BigInt, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def longSerializer(implicit ast: XmlAst): Serializer[Long, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def shortSerializer(implicit ast: XmlAst): Serializer[Short, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def byteSerializer(implicit ast: XmlAst): Serializer[Byte, Xml] =\n    BasicXmlSerializer(ast fromString _.toString)\n\n  implicit def nilSerializer(implicit ast: XmlAst): Serializer[Nil.type, Xml] =\n    BasicXmlSerializer(v => ast fromArray Nil)\n\n  implicit def traversableSerializer[Type, Coll[T] <: Traversable[T]](\n      implicit ast: XmlAst,\n      ser: Serializer[Type, Xml]): Serializer[Coll[Type], Xml] =\n    BasicXmlSerializer(ast fromArray _.map(ser.serialize).to[List])\n\n  implicit def optionSerializer[Type](implicit ast: XmlAst,\n                                      ser: Serializer[Type, Xml]): Serializer[Option[Type], Xml] =\n    BasicXmlSerializer(_ map ser.serialize getOrElse ast.nullValue)\n\n  implicit def mapSerializer[Type, Ast <: XmlAst](implicit ast: Ast,\n                                                  ser: Serializer[Type, Xml]): Serializer[Map[String, Type], Xml] =\n    new Serializer[Map[String, Type], Xml] {\n      def serialize(m: Map[String, Type]) = ast.fromObject(m.mapValues(ser.serialize))\n    }\n\n  implicit def directXmlSerializer[T: DirectXmlSerializer](implicit ast: XmlAst): Serializer[T, Xml] =\n    BasicXmlSerializer(\n        obj => xmlSerializer.serialize(Xml.construct(MutableCell(obj), Vector())(?[DirectXmlSerializer[T]].ast)))\n\n  implicit def xmlSerializer[XmlType <: XmlDataType[XmlType, _ <: XmlAst]](\n      implicit ast: XmlAst): Serializer[XmlType, Xml] =\n    BasicXmlSerializer[XmlType]({ j =>\n      if (j.$ast == ast) j.$normalize else ast.convert(j.$normalize, j.$ast)\n    })\n}\n\ntrait Serializers_1 {\n  implicit def generalStringSerializer[S](implicit ast: XmlAst, ss: StringSerializer[S]): Serializer[S, Xml] =\n    BasicXmlSerializer(s => ast fromString ss.serialize(s))\n}\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/validator.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nprivate[xml] object XmlValidator {\n\n  case class ValidationException(strNo: Int, pos: Int, expected: String, found: Char) extends Exception\n\n  case class DuplicateKeyException(strNo: Int, pos: Int, key: String) extends Exception\n\n  def validate(parts: List[String]) = {\n    var i = 0\n    var n = 0\n    var stack: List[String] = Nil\n    def s = parts(n)\n    def cur = if (i >= s.length) '\\u0000' else s(i)\n    def ahead(j: Int) = if (i + j >= s.length) '\\u0000' else s(i + j)\n\n    def fail(expected: String) = throw ValidationException(n, i, expected, cur)\n    def failPosition(expected: String) = throw ValidationException(n, i, expected, cur)\n    def duplicateKey(start: Int, key: String) = throw DuplicateKeyException(n, start, key)\n\n    def takeWhitespace(): Unit = while (cur.isWhitespace) next()\n\n    def consume(cs: Char*): Unit = cs foreach { c =>\n      if (cur == c) next() else fail(s\"'$c'\")\n    }\n\n    def next() = i += 1\n\n    def takeTag(): Unit = {\n      consume('<')\n      cur match {\n        case '/' => takeEndTag()\n        case '?' => takePi()\n        case '!' => takeSpecial()\n        case _ => takeStartTag(i)\n      }\n      if (stack.nonEmpty) takeText()\n    }\n\n    def takePi(): Unit = {\n      consume('?')\n      takeName()\n      takeWhitespace()\n      while (i < s.length && cur != '?') next()\n      consume('?', '>')\n    }\n\n    def takeComment(): Unit = {\n      consume(\"--\": _*)\n      while (i < s.length && !(cur == '-' && ahead(1) == '-')) next()\n      consume(\"-->\": _*)\n    }\n\n    def takeSpecial(): Unit = {\n      consume('!')\n      cur match {\n        case '-' => takeComment()\n        case '[' =>\n          consume('[')\n          cur match {\n            case 'C' =>\n              consume(\"CDATA[\": _*)\n            case 'P' =>\n              consume(\"PCDATA[\": _*)\n            case _ =>\n              fail(\"CDATA or PCDATA section\")\n          }\n          while (i < s.length && !(cur == ']' && ahead(1) == ']')) next()\n          consume(\"]]>\": _*)\n        case _ => fail(\"'-' or '['\")\n      }\n    }\n\n    def takeEndTag(): Unit = {\n      consume('/')\n      consume(stack.head: _*)\n      stack = stack.tail\n      consume('>')\n    }\n\n    def takeName(): String = {\n      val start = i\n      if (!cur.isLetter) fail(\"letter\") else next()\n      while (cur.isLetterOrDigit && i < s.length) next()\n      s.substring(start, i)\n    }\n\n    def takeAttribute(): Unit = {\n      takeName()\n      takeWhitespace()\n      consume('=')\n      takeWhitespace()\n      takeAttributeValue()\n    }\n\n    def takeStartTag(start: Int): Unit = {\n      val tagName = takeName()\n      stack ::= tagName\n      takeWhitespace()\n      takeTagContents(tagName)\n    }\n\n    def takeTagContents(tagName: String): Unit = cur match {\n      case '>' =>\n        consume('>')\n      case '/' =>\n        stack = stack.tail\n        consume('/', '>')\n      case _ =>\n        takeAttribute()\n        takeWhitespace()\n        takeTagContents(tagName)\n    }\n\n    def takeText(): Unit = cur match {\n      case '<' =>\n        takeTag()\n      case '&' =>\n        takeEntity()\n        takeText()\n      case '\\u0000' =>\n        fail(s\"\"\"closing tag \"${stack.head}\"\"\"\")\n      case _ =>\n        next()\n        takeText()\n    }\n\n    def takeEntity(): Unit = {\n      consume('&')\n      takeName()\n      consume(';')\n    }\n\n    def takeAttributeValue(): Unit = cur match {\n      case quot @ ('\\'' | '\"') =>\n        consume(quot)\n        var finished = false\n        while (!finished) cur match {\n          case `quot` =>\n            consume(quot)\n            finished = true\n          case '&' =>\n            takeEntity()\n          case _ =>\n            next()\n        }\n      case _ => fail(\"single or double quote\")\n    }\n\n    takeTag()\n    takeWhitespace()\n\n    if (i != s.length) fail(\"end of data\")\n  }\n}\n"
  },
  {
    "path": "xml/shared/src/main/scala/rapture/xml/xml.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml\n\nimport rapture.core._\nimport rapture.data._\n\nimport language.experimental.macros\nimport scala.language.implicitConversions\n\nprivate[xml] trait Xml_2 {\n  implicit def xmlExtractorMacro[T <: Product, Th]: Extractor[T, Xml] = macro XmlMacros\n    .xmlExtractorMacro[T, Th]\n\n  implicit def xmlSerializerMacro[T <: Product](implicit ast: XmlAst): Serializer[T, Xml] = macro XmlMacros\n    .xmlSerializerMacro[T]\n}\n\nprivate[xml] trait Xml_1 extends Xml_2 {\n  implicit def dynamicWorkaround(j: Xml): DynamicWorkaround = new DynamicWorkaround(j)\n}\n\nprivate[xml] class DynamicWorkaround(xml: Xml) {\n  def self: Xml = xml.selectDynamic(\"self\")(null)\n}\n\ntrait `Xml.parse` extends MethodConstraint\n\nprivate[xml] trait XmlDataCompanion[Type <: XmlDataType[Type, AstType], AstType <: XmlAst]\n    extends DataCompanion[Type, AstType] {\n\n  type ParseMethodConstraint = `Xml.parse`\n\n}\n\nprivate[xml] object XmlDataType extends Extractors with Serializers\n\nprivate[xml] trait XmlDataType[+T <: XmlDataType[T, AstType], AstType <: XmlAst] extends DataType[T, AstType]\n\nobject XmlBuffer extends XmlDataCompanion[XmlBuffer, XmlBufferAst] {\n\n  def construct(any: MutableCell, path: Vector[Either[Int, String]])(implicit ast: XmlBufferAst): XmlBuffer =\n    new XmlBuffer(any, path)\n}\n\n/** Companion object to the `Xml` type, providing factory and extractor methods, and a XML\n  * pretty printer. */\nobject Xml extends XmlDataCompanion[Xml, XmlAst] with Xml_1 {\n  \n  def apply[T](t: T)(implicit ast: XmlAst, ser: Serializer[T, Xml]): Xml =\n    construct(MutableCell(if(t == null) ast.nullValue else ser.serialize(t)), Vector())\n\n  object DynamicApplied {\n    implicit def auto[L](k: L)(implicit dynApp: DynamicApply[L]): DynamicApplied[L, dynApp.Result] =\n      new DynamicApplied[L, dynApp.Result](dynApp, k) {\n        def apply(v: Xml): dynApp.Result = dynApp(v, k)\n      }\n  }\n\n  abstract class DynamicApplied[L, R](val dynApp: DynamicApply[L] { type Result = R }, key: L) {\n    def apply(v: Xml): R\n  }\n\n  abstract class DynamicApply[L] {\n    type Result\n    def apply(v: Xml, k: L): Result\n  }\n\n  implicit val applyInt: DynamicApply[Int] { type Result = Xml } = new DynamicApply[Int] {\n    type Result = Xml\n    def apply(v: Xml, k: Int): Xml = v.$deref(Left(k) +: v.$path)\n  }\n\n  implicit val applySymbol: DynamicApply[Symbol] { type Result = XmlAttribute } = new DynamicApply[Symbol] {\n    type Result = XmlAttribute\n    def apply(v: Xml, k: Symbol): XmlAttribute = v.$attribute(k)\n  }\n\n  def construct(any: MutableCell, path: Vector[Either[Int, String]])(implicit ast: XmlAst): Xml = new Xml(any, path)\n\n  def ast(xml: Xml): XmlAst = xml.$ast\n\n  def extractor[T](implicit ext: Extractor[T, Xml]): Extractor[T, Xml] { type Throws = ext.Throws } = ext\n  def serializer[T](implicit ser: Serializer[T, Xml]) = ser\n\n  implicit def xmlCastExtractor[T: XmlCastExtractor](implicit ast: XmlAst): Extractor[T, XmlDataType[_, _ <: XmlAst]] =\n    new Extractor[T, XmlDataType[_, _ <: XmlAst]] {\n      type Throws = DataGetException\n      def extract(value: XmlDataType[_, _ <: XmlAst],\n                  ast2: DataAst,\n                  mode: Mode[_ <: MethodConstraint]): mode.Wrap[T, DataGetException] =\n        mode.wrap(ast2 match {\n          case ast2: XmlAst =>\n            val norm = mode.catching[DataGetException, Any](value.$normalize)\n            try {\n              if (ast == ast2) norm.asInstanceOf[T]\n              else\n                XmlDataType.xmlSerializer.serialize(Xml.construct(MutableCell(norm), Vector())(ast2)).asInstanceOf[T]\n            } catch {\n              case e: ClassCastException =>\n                mode.exception[T, DataGetException](\n                    TypeMismatchException(ast.getType(norm), implicitly[XmlCastExtractor[T]].dataType))\n            }\n          case _ => ???\n        })\n    }\n\n}\n\ncase class XmlAttribute(key: String, value: String) {\n  def as[T: StringParser]: T = implicitly[StringParser[T]].parse(value, modes.throwExceptions())\n  def is[T: StringParser]: Boolean =\n    try {\n      as[T]\n      true\n    } catch { case e: Exception => false }\n\n  override def toString = s\"\"\"$key=\"$value\"\"\"\"\n}\n\n/** Represents some parsed XML. */\nclass Xml(val $root: MutableCell, val $path: Vector[Either[Int, String]] = Vector())(implicit val $ast: XmlAst)\n    extends XmlDataType[Xml, XmlAst]\n    with DynamicData[Xml, XmlAst] {\n\n  def apply(attribute: Symbol): XmlAttribute = $attribute(attribute)\n  def $attribute(attribute: Symbol): XmlAttribute =\n    XmlAttribute(attribute.name, $ast.getAttributes($normalize)(attribute.name))\n  def applyDynamic[L, R](field: String)(dynApp: Xml.DynamicApplied[L, R] = 0): R =\n    dynApp($deref(Right(field) +: $path))\n\n  def $wrap(any: Any, path: Vector[Either[Int, String]]): Xml =\n    new Xml(MutableCell(any), path)\n\n  def $deref(path: Vector[Either[Int, String]]): Xml = new Xml($root, path)\n\n  def $extract(sp: Vector[Either[Int, String]]): Xml =\n    if (sp.isEmpty) this\n    else\n      sp match {\n        case Left(i) +: tail => apply(i).$extract(tail)\n        case Right(e) +: tail => selectDynamic(e)(null).$extract(tail)\n      }\n\n  override def toBareString =\n    try Xml.format(this)(formatters.compact()($ast))\n    catch {\n      case e: Exception => \"undefined\"\n    }\n\n  override def toString: String = s\"\"\"xml\"\"${'\"'}$toBareString\"\"${'\"'}\"\"\"\n}\n\nclass XmlBuffer(val $root: MutableCell, val $path: Vector[Either[Int, String]] = Vector())(\n    implicit val $ast: XmlBufferAst)\n    extends XmlDataType[XmlBuffer, XmlBufferAst]\n    with MutableDataType[XmlBuffer, XmlBufferAst]\n    with DynamicData[XmlBuffer, XmlBufferAst] {\n\n  def $wrap(any: Any, path: Vector[Either[Int, String]]): XmlBuffer =\n    new XmlBuffer(MutableCell(any), path)\n\n  def $deref(path: Vector[Either[Int, String]]): XmlBuffer = new XmlBuffer($root, path)\n\n  def $extract(sp: Vector[Either[Int, String]]): XmlBuffer =\n    if (sp.isEmpty) this\n    else\n      sp match {\n        case Left(i) +: tail => apply(i).$extract(tail)\n        case Right(e) +: tail => selectDynamic(e)(null).$extract(tail)\n      }\n\n  override def toBareString =\n    try Xml.format(this)(formatters.compact()($ast))\n    catch {\n      case e: Exception => \"undefined\"\n    }\n\n  override def toString: String = s\"\"\"xml\"\"${'\"'}$toBareString\"\"${'\"'}\"\"\"\n}\n"
  },
  {
    "path": "xml-stdlib/shared/src/main/scala/rapture/xml-stdlib/ast.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml.xmlBackends.stdlib\n\nimport rapture.core._\nimport rapture.xml._\nimport rapture.data.DataTypes\nimport rapture.data.TypeMismatchException\nimport rapture.data.MissingValueException\n\nimport scala.collection.immutable.ListMap\nimport scala.xml._\n\nprivate[stdlib] object StdlibAst extends XmlBufferAst {\n\n  override def dereferenceObject(obj: Any, element: String): Any = obj match {\n    case n: Node if n.child.exists(_.label == element) => n \\ element\n    case ns: NodeSeq if ns.exists(_.child.exists(_.label == element)) => ns \\ element\n    case _ => throw MissingValueException()\n  }\n\n  override def getChildren(obj: Any): Seq[Any] = obj match {\n    case n: Node => n.child.to[List]\n    case n: NodeSeq => n.flatMap(_.child).to[List]\n    case _ => throw new Exception\n  }\n\n  def getArray(array: Any): List[Any] = array match {\n    case ns: NodeSeq => ns.to[List]\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def getString(string: Any): String = string match {\n    case ns: NodeSeq => ns.text\n    case _ => throw TypeMismatchException(getType(string), DataTypes.String)\n  }\n\n  def getObject(obj: Any): ListMap[String, Any] = obj match {\n    case n: Node =>\n      ListMap(n.child.map { e =>\n        e.label -> e.child\n      }: _*)\n    case n: NodeSeq =>\n      ListMap(n.flatMap(_.child.map { e =>\n          e.label -> e.child\n        }): _*)\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def getLabel(obj: Any): String = obj match {\n    case n: Node => n.label\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def getAttributes(obj: Any): Map[String, String] = obj match {\n    case n: Node => n.attributes.asAttrMap\n    case v =>\n      println(s\"Found $v of type ${v.getClass}\")\n      throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def setObjectValue(obj: Any, name: String, value: Any): Any =\n    fromObject(getObject(obj).updated(name, value))\n\n  def removeObjectValue(obj: Any, name: String): Any = obj match {\n    case obj: ListMap[_, _] => obj.asInstanceOf[ListMap[String, Any]] - name\n    case _ => throw TypeMismatchException(getType(obj), DataTypes.Object)\n  }\n\n  def addArrayValue(array: Any, value: Any): Any = array match {\n    case array: NodeSeq => array :+ value\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def setArrayValue(array: Any, index: Int, value: Any): Any = array match {\n    case array: NodeSeq =>\n      new NodeSeq {\n        def theSeq = array.patch(index, List(value.asInstanceOf[Node]), 1).to[List]\n      }\n    case _ => throw TypeMismatchException(getType(array), DataTypes.Array)\n  }\n\n  def isPi(any: Any): Boolean = any match {\n    case ProcInstr(_, _) => true\n    case _ => false\n  }\n\n  def getPiText(any: Any): String = any match {\n    case ProcInstr(_, text) => text\n    case _ => throw TypeMismatchException(getType(any), DataTypes.Object)\n  }\n\n  def isComment(any: Any): Boolean = any match {\n    case Comment(_) => true\n    case _ => false\n  }\n\n  def getComment(any: Any): String = any match {\n    case Comment(text) => text\n    case _ => throw TypeMismatchException(getType(any), DataTypes.Object)\n  }\n\n  def getPiTarget(any: Any): String = any match {\n    case ProcInstr(target, _) => target\n    case _ => throw TypeMismatchException(getType(any), DataTypes.Object)\n  }\n\n  def isArray(array: Any): Boolean = array match {\n    case n: Node => false\n    case ns: NodeSeq => true\n    case _ => false\n  }\n\n  def isString(string: Any): Boolean = string match {\n    case Text(_) => true\n    case _ => false\n  }\n\n  def isObject(obj: Any): Boolean = obj match {\n    case _: Node => true\n    case _: NodeSeq => true\n    case _ => false\n  }\n\n  def isNull(obj: Any): Boolean = false\n\n  def fromArray(array: Seq[Any]): Any = array.collect { case e: NodeSeq => e }.foldLeft(NodeSeq.Empty)(_ ++ _)\n\n  def fromObject(obj: Map[String, Any]): Any =\n    obj\n      .to[List]\n      .collect {\n        case (k, v: NodeSeq) =>\n          Elem(null, k, Null, TopScope, true, v: _*): NodeSeq\n      }\n      .foldLeft(NodeSeq.Empty)(_ ++ _)\n\n  def fromString(string: String): Any = Text(string)\n\n  override val nullValue = \"\"\n\n  override def toString = \"<XmlStdlib>\"\n\n}\n"
  },
  {
    "path": "xml-stdlib/shared/src/main/scala/rapture/xml-stdlib/extractors.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml.xmlBackends.stdlib\n\nprivate[stdlib] trait Extractors {}\n"
  },
  {
    "path": "xml-stdlib/shared/src/main/scala/rapture/xml-stdlib/package.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml.xmlBackends.stdlib\n\nimport rapture.xml._\n\nobject `package` extends Extractors with Serializers {\n  implicit val implicitXmlAst: XmlBufferAst = StdlibAst\n  implicit val implicitXmlStringParser: StdlibStringParser.type = StdlibStringParser\n}\n"
  },
  {
    "path": "xml-stdlib/shared/src/main/scala/rapture/xml-stdlib/parse.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml.xmlBackends.stdlib\n\nimport rapture.core._\nimport rapture.data._\nimport rapture.xml._\n\nimport scala.xml._\n\nprivate[stdlib] object StdlibStringParser extends Parser[String, XmlBufferAst] {\n\n  override def toString = \"<StdlibStringParser>\"\n\n  val ast = StdlibAst\n  def parse(s: String): Option[Any] =\n    try Some(XML.loadString(s))\n    catch { case e: Exception => None }\n}\n"
  },
  {
    "path": "xml-stdlib/shared/src/main/scala/rapture/xml-stdlib/serializers.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml.xmlBackends.stdlib\n\nprivate[stdlib] trait Serializers {}\n"
  },
  {
    "path": "xml-test/shared/src/test/scala/rapture/xml-test/java8TimeTests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n\n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml.test\n\nimport java.time._\n\nimport rapture.core.ParseException\nimport rapture.xml._\nimport rapture.data.Parser\nimport rapture.test._\nimport rapture.xml.xmlBackends.stdlib\nimport rapture.core.java8.time._\n\nclass XmlJava8TimeApiTestRun extends Programme {\n  include(StdlibTests)\n  object StdlibTests extends XmlJava8TimeApiTests(stdlib.implicitXmlAst, stdlib.implicitXmlStringParser)\n}\n\n\nabstract class XmlJava8TimeApiTests(ast: XmlAst, parser: Parser[String, XmlAst]) extends TestSuite {\n\n  implicit def implicitAst: XmlAst = ast\n\n  implicit def implicitParser: Parser[String, XmlAst] = parser\n\n  case class TestLocalDate(time: LocalDate)\n  case class TestLocalDateTime(time: LocalDateTime)\n  case class TestLocalTime(time: LocalTime)\n  case class TestZonedDateTime(time: ZonedDateTime)\n  case class TestOffsetDateTime(time: OffsetDateTime)\n  case class TestOffsetTime(time: OffsetTime)\n\n\n  val `[Java 8 Time Extractor] Extract LocalDate` = test {\n    xml\"\"\"<time>2017-01-23</time>\"\"\".as[LocalDate]\n  } returns LocalDate.of(2017, 1, 23)\n\n  val `[Java 8 Time Extractor] Extract LocalDateTime` = test {\n    xml\"\"\"<time>2017-01-23T18:28:51.045</time>\"\"\".as[LocalDateTime]\n  } returns LocalDateTime.of(2017, 1, 23, 18, 28, 51, 45000000)\n\n  val `[Java 8 Time Extractor] Extract LocalTime` = test {\n    xml\"\"\"<time>18:38:14.997</time>\"\"\".as[LocalTime]\n  } returns LocalTime.of(18, 38, 14, 997000000)\n\n\n  val `[Java 8 Time Extractor] Extract ZonedDateTime` = test {\n    xml\"\"\"<time>2017-01-23T18:41:02.086+02:00[Europe/Kiev]</time>\"\"\".as[ZonedDateTime]\n  } returns ZonedDateTime.of(2017, 1, 23, 18, 41, 2, 86000000, ZoneId.of(\"Europe/Kiev\"))\n\n\n  val `[Java 8 Time Extractor] Extract OffsetDateTime` = test {\n    xml\"\"\"<time>2017-01-23T18:44:18.221+02:00</time>\"\"\".as[OffsetDateTime]\n  } returns OffsetDateTime.of(2017, 1, 23, 18, 44, 18, 221000000, ZoneOffset.ofHours(2))\n\n\n  val `[Java 8 Time Extractor] Extract OffsetTime` = test {\n    xml\"\"\"<time>19:03:25.325+02:00</time>\"\"\".as[OffsetTime]\n  } returns OffsetTime.of(19, 3, 25, 325000000, ZoneOffset.ofHours(2))\n\n\n  val `[Java 8 Time Extractor] Extract Failure` = test {\n    xml\"\"\"<time>19:03:25.325+02:0</time>\"\"\".as[OffsetTime]\n  } throws classOf[ParseException]\n\n\n  val `[Java 8 Time Serializator] Serialize LocalDate` = test {\n    Xml(TestLocalDate(LocalDate.of(2017, 1, 23))).toBareString\n  } returns xml\"\"\"<time>2017-01-23</time>\"\"\".toBareString\n\n  val `[Java 8 Time Serializator] Serialize LocalDateTime` = test {\n    Xml(TestLocalDateTime( LocalDateTime.of(2017, 1, 23, 18, 28, 51, 45000000))).toBareString\n  } returns xml\"\"\"<time>2017-01-23T18:28:51.045</time>\"\"\".toBareString\n\n\n  val `[Java 8 Time Serializator] Serialize LocalTime` = test {\n    Xml(TestLocalTime(LocalTime.of(18, 38, 14, 997000000))).toBareString\n  } returns xml\"\"\"<time>18:38:14.997</time>\"\"\".toBareString\n\n\n  val `[Java 8 Time Serializator] Serialize ZonedDateTime` = test {\n    Xml(TestZonedDateTime(ZonedDateTime.of(2017, 1, 23, 18, 41, 2, 86000000, ZoneId.of(\"Europe/Kiev\")))).toBareString\n  } returns xml\"\"\"<time>2017-01-23T18:41:02.086+02:00[Europe/Kiev]</time>\"\"\".toBareString\n\n\n  val `[Java 8 Time Serializator] Serialize OffsetDateTime` = test {\n    Xml(TestOffsetDateTime(OffsetDateTime.of(2017, 1, 23, 18, 44, 18, 221000000, ZoneOffset.ofHours(2)))).toBareString\n  } returns xml\"\"\"<time>2017-01-23T18:44:18.221+02:00</time>\"\"\".toBareString\n\n\n  val `[Java 8 Time Serializator] Serialize OffsetTime` = test {\n    Xml(TestOffsetTime(OffsetTime.of(19, 3, 25, 325000000, ZoneOffset.ofHours(2)))).toBareString\n  } returns xml\"\"\"<time>19:03:25.325+02:00</time>\"\"\".toBareString\n\n}"
  },
  {
    "path": "xml-test/shared/src/test/scala/rapture/xml-test/tests.scala",
    "content": "/*\n  Rapture, version 2.0.0. Copyright 2010-2016 Jon Pretty, Propensive Ltd.\n\n  The primary distribution site is\n  \n    http://rapture.io/\n\n  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in\n  compliance with the License. You may obtain a copy of the License at\n  \n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software distributed under the License is\n  distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and limitations under the License.\n */\n\npackage rapture.xml.test\n\nimport rapture.core._\nimport rapture.xml._\nimport rapture.data.Parser\nimport rapture.test._\nimport rapture.data.dictionaries.dynamic._\n\n\nclass TestRun extends Programme {\n  include(StdlibTests)\n}\n\nprivate[test] case class Foo(alpha: String, beta: Int)\nprivate[test] case class Bar(foo: Foo, gamma: Double)\n\nprivate[test] case class Baz(alpha: String, beta: Option[Int])\nprivate[test] case class Baz2(alpha: String, beta: util.Try[Int])\n\nprivate[test] case class HasDefault(alpha: String = \"yes\", beta: Int)\nprivate[test] case class HasDefault2(alpha: String, beta: Int = 1)\n\nprivate[test] case class A(a: B)\nprivate[test] case class B(b: C)\nprivate[test] case class C(c: D)\nprivate[test] case class D(d: E)\nprivate[test] case class E(e: F)\nprivate[test] case class F(f: Int)\n\nimport xmlBackends._\nobject StdlibTests extends XmlTests(stdlib.implicitXmlAst, stdlib.implicitXmlStringParser)\n\nobject StdlibPatternMatchTests extends XmlPatternMatchingTests(stdlib.implicitXmlAst, stdlib.implicitXmlStringParser)\n\nobject Data {\n  def source1(implicit ast: XmlAst, parser: Parser[String, XmlAst]) = xml\"\"\"<source>\n    <string>Hello</string>\n    <int>42</int>\n    <double>3.14159</double>\n    <boolean>true</boolean>\n    <list>\n      <item>1</item>\n      <item>2</item>\n      <item>3</item>\n    </list>\n    <foo>\n      <alpha>test</alpha>\n      <beta>1</beta>\n    </foo>\n    <bar>\n      <foo>\n        <alpha>test2</alpha>\n        <beta>2</beta>\n      </foo>\n      <gamma>2.7</gamma>\n    </bar>\n    <baz>\n      <alpha>test</alpha>\n    </baz>\n    <baz2>\n      <alpha>test</alpha>\n      <beta>7</beta>\n    </baz2>\n    <self>0</self>\n  </source>\"\"\"\n}\n\nabstract class XmlTests(ast: XmlAst, parser: Parser[String, XmlAst]) extends TestSuite {\n\n  implicit def implicitAst: XmlAst = ast\n  implicit def implicitParser: Parser[String, XmlAst] = parser\n\n  val source1 = Data.source1\n\n  val `Extract Int` = test {\n    source1.int.as[Int]\n  } returns 42\n\n  val `Extract Option[Int]` = test {\n    source1.int.as[Option[Int]]\n  } returns Some(42)\n\n  val `Extract Option[Int], wrong type` = test {\n    source1.string.as[Option[Int]]\n  } returns None\n\n  val `Extract Double` = test {\n    source1.double.as[Double]\n  } returns 3.14159\n\n  val `Extract Boolean` = test {\n    source1.boolean.as[Boolean]\n  } returns true\n\n  val `Extract String` = test {\n    source1.string.as[String]\n  } returns \"Hello\"\n\n  val `Extract List[Int]` = test {\n    source1.list.item.as[List[Int]]\n  } returns List(1, 2, 3)\n\n  val `Extract Vector[Int]` = test {\n    source1.list.item.as[Vector[Int]]\n  } returns Vector(1, 2, 3)\n\n  val `Extract case class` = test {\n    source1.foo.as[Foo]\n  } returns Foo(\"test\", 1)\n\n  val `Extract case class with missing optional value` = test {\n    source1.baz.as[Baz]\n  } returns Baz(\"test\", None)\n\n  val `Extract case class with missing tried value` = test {\n    source1.baz.as[Baz2]\n  } returns Baz2(\"test\", util.Failure(MissingValueException(\"beta\")))\n\n  val `Extract case class with present optional value` = test {\n    source1.baz2.as[Baz]\n  } returns Baz(\"test\", Some(7))\n\n  val `Extract case class with present tried value` = test {\n    source1.baz2.as[Baz2]\n  } returns Baz2(\"test\", util.Success(7))\n\n  val `Extract nested case class` = test {\n    source1.bar.as[Bar]\n  } returns Bar(Foo(\"test2\", 2), 2.7)\n\n  val `Extract deeply-nested case class` = test {\n    xml\"\"\"<obj><a><b><c><d><e><f>1</f></e></d></c></b></a></obj>\"\"\".as[A]\n  } returns A(B(C(D(E(F(1))))))\n\n  val `Extract List element` = test {\n    source1.list.item(1).as[Int]\n  } returns 2\n\n  val `Extract object element` = test {\n    source1.bar.foo.alpha.as[String]\n  } returns \"test2\"\n\n  val `Extract missing value with case class default` = test {\n    xml\"\"\"<obj><beta>0</beta></obj>\"\"\".as[HasDefault]\n  } returns HasDefault(\"yes\", 0)\n\n  val `Extract missing value with case class default 2` = test {\n    xml\"\"\"<obj><alpha>no</alpha></obj>\"\"\".as[HasDefault2]\n  } returns HasDefault2(\"no\", 1)\n\n  val `Extract case class ignoring default value` = test {\n    xml\"\"\"<obj><beta>0</beta><alpha>no</alpha></obj>\"\"\".as[HasDefault2]\n  } returns HasDefault2(\"no\", 0)\n\n  val `Check type failure` = test {\n    source1.string.as[Int]\n  } throws InvalidNumber(\"Hello\", \"integer\")\n\n  val `Check missing value failure` = test {\n    source1.nothing.as[Int]\n  } throws MissingValueException(\"nothing\")\n\n  val `Serialize string` = test {\n    Xml(\"Hello World!\").toString\n  } returns \"xml\\\"\\\"\\\"Hello World!\\\"\\\"\\\"\"\n\n  val `Serialize int` = test {\n    Xml(1648).toString\n  } returns \"xml\\\"\\\"\\\"1648\\\"\\\"\\\"\"\n\n  /*val `Serialize array` = test {\n    Json(List(1, 2, 3)).toString\n  } returns \"123\"\n\n  val `Serialize object` = test {\n    import formatters.humanReadable._\n    Xml.format(xml\"<baz>quux</baz><foo>bar</foo>\")\n  } returns \"<baz>quux</baz><foo>bar</foo>\"\n\n  val `Empty object serialization` = test {\n    import formatters.humanReadable._\n    Json.format(json\"{}\")\n  } returns \"{}\"\n\n  val `Empty node serialization` = test {\n    import formatters.humanReadable._\n    Xml.format(xml\"<empty></empty>\")\n  } returns \"<empty/>\"\n\n  val `Extracting Option should not throw exception` = test {\n    val x = xml\"\"\"{\"foo\":\"bar\"}\"\"\"\n    j.as[Option[String]]\n  } returns None*/\n\n}\n\nabstract class XmlPatternMatchingTests(ast: XmlAst, parser: Parser[String, XmlAst]) extends TestSuite {\n  \n  implicit def implicitAst: XmlAst = ast\n  implicit def implicitParser: Parser[String, XmlAst] = parser\n\n  val source1 = Data.source1\n  \n  val `Pattern matching` = test {\n    Xml(\"\") match {\n      case xml\"\"\"\"\"\" => \"Match\"\n      case _ => \"Does not match\"\n    }\n  } returns \"Match\"\n\n  val `Match string` = test {\n    source1 match {\n      case xml\"\"\"<string>$h<string>\"\"\" => h.as[String]\n    }\n  } returns \"Hello\"\n\n  val `Match int` = test {\n    source1 match {\n      case xml\"\"\"<int>$h<int>\"\"\" => h.as[Int]\n    }\n  } returns 42\n\n  val `Match double` = test {\n    source1 match {\n      case xml\"\"\"<double>$h<double>\"\"\" => h.as[Double]\n    }\n  } returns 3.14159\n\n  val `Match boolean` = test {\n    source1 match {\n      case xml\"\"\"<boolean>$h<boolean>\"\"\" => h.as[Boolean]\n    }\n  } returns true\n}\n"
  }
]