Skip to content

Commit

Permalink
Updates for scala 2.9.0 and the new dispatch library
Browse files Browse the repository at this point in the history
  • Loading branch information
Debasish Ghosh committed May 15, 2011
1 parent 1b69f74 commit 6d17990
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 74 deletions.
Binary file removed embedded-repo/sjson/json/sjson/0.7/sjson-0.7.jar
Binary file not shown.
Binary file removed embedded-repo/sjson/json/sjson/0.8/sjson-0.8.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions project/build.properties
Expand Up @@ -2,8 +2,9 @@
#Sun Jan 24 13:59:22 EST 2010
project.organization=scouch.db
project.name=scouchdb
sbt.version=0.7.4
sbt.version=0.7.6.RC0
scala.version=2.8.1
project.version=0.6
def.scala.version=2.7.7
build.scala.versions=2.8.0
build.scala.versions=2.9.0
project.initialize=false
22 changes: 7 additions & 15 deletions project/build/SCouchDbProject.scala
Expand Up @@ -4,28 +4,20 @@ class SCouchDbProject(info: ProjectInfo) extends DefaultProject(info)
{
val scalaToolsSnapshots = "Scala-Tools Maven2 Snapshots Repository" at "http://scala-tools.org/repo-snapshots"
val scalaToolsReleases = "Scala-Tools Maven2 Releases Repository" at "http://scala-tools.org/repo-releases"
val embeddedRepo = MavenRepository("Embedded Repo", (info.projectPath / "embedded-repo").asURL.toString)
val dispatch_json = "net.databinder" % "dispatch-json_2.8.0" % "0.7.4" % "compile"
val dispatch_http_json = "net.databinder" % "dispatch-http-json_2.8.0" % "0.7.4" % "compile"
val dispatch_http = "net.databinder" % "dispatch-http_2.8.0" % "0.7.4" % "compile"
// val embeddedRepo = MavenRepository("Embedded Repo", (info.projectPath / "embedded-repo").asURL.toString)
val dispatch_json = "net.databinder" % "dispatch-json_2.9.0" % "0.8.1" % "compile"
val dispatch_http_json = "net.databinder" % "dispatch-http-json_2.9.0" % "0.8.1" % "compile"
val dispatch_http = "net.databinder" % "dispatch-http_2.9.0" % "0.8.1" % "compile"
val commons_logging = "commons-logging" % "commons-logging" % "1.1.1" % "compile"
val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.0.1" % "compile"
val sjson = "sjson.json" % "sjson" % "0.8" % "compile"
val sjson = "net.debasishg" % "sjson_2.9.0" % "0.11" % "compile"

val scalatest =
buildScalaVersion match {
case "2.7.7" =>
"org.scalatest" % "scalatest" % "1.0"
case "2.8.0.Beta1" =>
"org.scalatest" % "scalatest" % "1.0.1-for-scala-2.8.0.Beta1-with-test-interfaces-0.3-SNAPSHOT"
case "2.8.0.RC2" =>
"org.scalatest" % "scalatest" % "1.2-for-scala-2.8.0.RC2-SNAPSHOT" % "test"
case "2.8.0.RC3" =>
"org.scalatest" % "scalatest" % "1.2-for-scala-2.8.0.RC2-SNAPSHOT" % "test"
case "2.8.0.RC7" =>
"org.scalatest" % "scalatest" % "1.2-for-scala-2.8.0.RC7-SNAPSHOT" % "test"
case "2.8.0" =>
"org.scalatest" % "scalatest" % "1.2" % "test"
case "2.9.0" =>
"org.scalatest" % "scalatest_2.9.0" % "1.4.1" % "test"
}

val junit = "junit" % "junit" % "4.8.1"
Expand Down
21 changes: 11 additions & 10 deletions src/main/scala/scouch/db/Database.scala
Expand Up @@ -6,7 +6,7 @@ import dispatch._
import dispatch.json._
import dispatch.json.Js._
import JsHttp._
import RichRequest._
// import RichRequest._
import DbUtils._
import sjson.json._

Expand Down Expand Up @@ -50,11 +50,11 @@ case class Db(couch: Couch, name: String) extends Request(couch / name) with Js

/** create a doc from an object with auto id generation */
def doc(obj: JsValue) = {
this <:< Map("Content-Type" -> "application/json") << obj ># %('id ! str, 'rev ! str)
this <:< Map("Content-Type" -> "application/json") << JsValue.toJson(obj) ># %('id ! str, 'rev ! str)
}

val create = this <<< Nil.mkString >|
val delete = DELETE >|
val delete = this.DELETE >|


/** create multiple docs with auto-generated ids through a single POST. For
Expand Down Expand Up @@ -103,7 +103,7 @@ case class Db(couch: Couch, name: String) extends Request(couch / name) with Js

/** fetch by id, returns a tuple (id, rev)
@deprecated use <tt>getRef</tt> instead */
@deprecated("use getRef instead") def ref_by_id(id: String) =
@deprecated("use getRef instead", "0.6") def ref_by_id(id: String) =
this / encode(id, Request.factoryCharset) ># %(Symbol("_id") ? str, Symbol("_rev") ? str)

/** fetch by id, returns a tuple (id, rev) */
Expand All @@ -118,7 +118,7 @@ case class Db(couch: Couch, name: String) extends Request(couch / name) with Js
/** get an entity of type <tt>T</tt> based on its id. Returns a
<tt>Tuple3</tt> of <tt>(id, ref, T)</tt>
@deprecated use <tt>get(id)</tt> instead */
@deprecated("use get(id) instead") def by_id[T](id: String)(implicit m: Manifest[T]) =
@deprecated("use get(id) instead", "0.6") def by_id[T](id: String)(implicit m: Manifest[T]) =
this / encode(id, Request.factoryCharset) ># {
case s@_ =>
val (id, ref) = getIdAndRef(s)
Expand All @@ -143,7 +143,7 @@ case class Db(couch: Couch, name: String) extends Request(couch / name) with Js
/** get an entity of type <tt>T</tt> based on its id and rev. Returns a
<tt>Tuple3</tt> of <tt>(id, ref, T)</tt>
@deprecated use <tt>get(id, rev)</tt> instead */
@deprecated("use get(id, rev) instead") def by_id[T](id: String, rev: String)(implicit m: Manifest[T]) =
@deprecated("use get(id, rev) instead", "0.6") def by_id[T](id: String, rev: String)(implicit m: Manifest[T]) =
this / encode(id, Request.factoryCharset) <<? Map("rev" -> rev) ># {
case s@_ =>
val (id, ref) = getIdAndRef(s)
Expand Down Expand Up @@ -265,11 +265,12 @@ case class Doc(val db: Db, val id: String) extends Request(db / encode(id, Reque

/** add attachment to a document. None as the <tt>rev</tt> will create a new document
as well */
import org.apache.http.entity.ByteArrayEntity
def attach(attachmentId: String, contentType: String, data: Array[Byte], rev: Option[String]) = rev match {
case Some(r) =>
this / (encode(attachmentId, Request.factoryCharset) + Http.?(Map("rev" -> r))) put (data, contentType) >|
this / encode(attachmentId, Request.factoryCharset) <<? Map("rev" -> r) copy(method = "PUT", body = Some(new ByteArrayEntity(data))) >|
case None =>
this / encode(attachmentId, Request.factoryCharset) put (data, contentType) >|
this / encode(attachmentId, Request.factoryCharset) copy(method = "PUT", body = Some(new ByteArrayEntity(data))) >|
}

/** fetch the attachment having id as <tt>attachmentId</tt> */
Expand All @@ -280,7 +281,7 @@ case class Doc(val db: Db, val id: String) extends Request(db / encode(id, Reque
/** delete the attachment specified by the id <tt>attachmentId</tt> for the revision
<tt>rev</tt> of the current document */
def deleteAttachment(attachmentId: String, rev: String) = {
(this / encode(attachmentId, Request.factoryCharset) DELETE) <<? Map("rev" -> rev) >|
(this / encode(attachmentId, Request.factoryCharset)) <<? Map("rev" -> rev) copy(method = "DELETE") >|
}

/** update the document of specified revision, with the specified object */
Expand All @@ -295,6 +296,6 @@ case class Doc(val db: Db, val id: String) extends Request(db / encode(id, Reque
case Updated.rev(rev) => (Id._rev << rev)(js)
}
private object Updated { val rev = 'rev ? str }
def delete(rev: String) = DELETE <<? Map("rev" -> rev) >|
def delete(rev: String) = this.DELETE <<? Map("rev" -> rev) >|
}

45 changes: 0 additions & 45 deletions src/main/scala/scouch/db/RichRequest.scala

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/scala/scouch/db/ViewServer.scala
Expand Up @@ -32,7 +32,7 @@ class ViewServer(val ps: PrintWriter) {

/** The passed in <tt>PrintWriter</tt> is also used to log any message
that the Scala interpreter spits out */
val interpreter = new scala.tools.nsc.Interpreter(s, ps)
val interpreter = new scala.tools.nsc.interpreter.IMain(s, ps)

/** Evaluates the code snippet passed in. The snippet has to return a value */
private def eval(code : String) : Any = {
Expand All @@ -43,7 +43,7 @@ class ViewServer(val ps: PrintWriter) {
// Execute the code and catch the result
val ir = interpreter.interpret("$res__.value = " + code);

import scala.tools.nsc.InterpreterResults._
import scala.tools.nsc.interpreter.Results._

// Return value or throw an exception based on result
ir match {
Expand Down

0 comments on commit 6d17990

Please sign in to comment.