Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
816597b
Fixing the client warnings/errors, upgrading libraries, fixing tests …
Oct 20, 2018
e252837
Fixing the maybe stuff in requests, upgrading more libraries
Oct 21, 2018
0e31a24
Swithching from scalaz concurrency to fs2 task, fixing all dependent …
Oct 21, 2018
95b6836
fixing tests and test framework
Oct 21, 2018
152715f
Fixed most of the tests, these never could have passed in the first p…
Oct 21, 2018
fc80a3f
only 16 tests now broken, mostly query stuff
Oct 22, 2018
2b70490
dbInfo serialization/deserialization now works properly, 14 tests fai…
Oct 22, 2018
1841b5c
All tests outside query language now pass, WINZ
Oct 22, 2018
cb25343
All tests outside query language now pass, WINZ
Oct 22, 2018
cb55631
All tests outside query language now pass, WINZ
Oct 22, 2018
1e6e397
Deleting temp views and temp view tests as couchdb2 no longer support…
Oct 22, 2018
e245168
Deleting temp views and temp view tests as couchdb2 no longer support…
Oct 22, 2018
b5edd82
final sbt changes for release
Oct 22, 2018
cf7ef5d
adding stuff to publish to oss sonatype
Oct 22, 2018
50f3233
sonatype sbt changes for one click maven central release. WINZZZZZ
Oct 22, 2018
73b739d
Update README.md
GuyIncognito1986 Oct 22, 2018
bc6b32d
Update README.md
GuyIncognito1986 Oct 22, 2018
6240516
Update README.md
GuyIncognito1986 Oct 22, 2018
b0a8172
Update README.md
GuyIncognito1986 Oct 22, 2018
3248b0a
Update README.md
GuyIncognito1986 Oct 22, 2018
02f8845
removing static libs and more temp view redundant code, updating readme
Oct 23, 2018
e4074be
Updating readme
Oct 23, 2018
5137ec3
upgrading upickle to latest
Nov 1, 2018
82be691
reverting upickle update because of breaking changes in the serializer
Nov 1, 2018
8d57dd6
CHanging travis scala version
Nov 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: scala
scala:
- 2.11.8
- 2.12.7
jdk:
- oraclejdk8
services:
Expand Down
89 changes: 34 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# CouchDB-Scala

[![Build Status](https://travis-ci.org/beloglazov/couchdb-scala.svg?branch=master)](https://travis-ci.org/beloglazov/couchdb-scala)
[![Join the chat at https://gitter.im/beloglazov/couchdb-scala](https://badges.gitter.im/beloglazov/couchdb-scala.svg)](https://gitter.im/beloglazov/couchdb-scala?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.ibm/couchdb-scala_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.ibm/couchdb-scala_2.11)
[![Stories in Ready](https://badge.waffle.io/beloglazov/couchdb-scala.png?label=ready&title=Ready)](https://waffle.io/beloglazov/couchdb-scala)


This is a purely functional Scala client for
[CouchDB](http://couchdb.apache.org/). The design goals are compositionality,
expressiveness, type-safety, and ease of use.
Expand All @@ -22,7 +16,7 @@ It's based on these awesome libraries:
Add the following dependency to your SBT config:

```Scala
libraryDependencies += "com.ibm" %% "couchdb-scala" % "0.7.2"
libraryDependencies += "io.github.guyincognito1986" %% "couchdb-scala" % "1.0.3.1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

```


Expand Down Expand Up @@ -546,7 +540,12 @@ Here is a basic example of an application that stores a set of case class
instances in a database, retrieves them back, and prints out afterwards:

```Scala
import com.ibm.couchdb._
import org.slf4j.LoggerFactory
import fs2.Task

object Basic extends App {
private val logger = LoggerFactory.getLogger(Basic.getClass)

// Define a simple case class to represent our data model
case class Person(name: String, age: Int)
Expand All @@ -566,25 +565,33 @@ object Basic extends App {
// Get an instance of the DB API by name and type mapping
val db = couch.db(dbName, typeMapping)

val actions = for {
// Delete the database or ignore the error if it doesn't exist
_ <- couch.dbs.delete(dbName).ignoreError
// Create a new database
_ <- couch.dbs.create(dbName)
// Insert documents into the database
_ <- db.docs.createMany(Seq(alice, bob, carl))
// Retrieve all documents from the database and unserialize to Person
docs <- db.docs.getMany.includeDocs[Person].build.query
} yield docs.getDocsData

// Execute the actions and process the result
actions.attemptRun match {
// In case of an error (left side of Either), print it
case -\/(e) => println(e)
// In case of a success (right side of Either), print each object
case \/-(a) => a.map(println(_))
typeMapping.get(classOf[Person]).foreach { mType =>
val actions: Task[Seq[Person]] = for {
// Delete the database or ignore the error if it doesn't exist
_ <- couch.dbs.delete(dbName)
// Create a new database
_ <- couch.dbs.create(dbName)
// Insert documents into the database
_ <- db.docs.createMany(Seq(alice, bob, carl))
// Retrieve all documents from the database and unserialize to Person
docs <- db.docs.getMany.includeDocs[Person].byTypeUsingTemporaryView(mType).build.query
} yield docs.getDocsData
couch.dbs.delete(dbName)
couch.dbs.create(dbName)
db.docs.createMany(Seq(alice, bob, carl))
db.docs.getMany.includeDocs[Person].byTypeUsingTemporaryView(mType).build.query
// Execute the actions and process the result
actions.unsafeRunAsync(x =>
try{
x.map(ps => ps.foreach(p => logger.info(p.toString)))
()
}
catch{
case e: Throwable => logger.error(e.toString)
}
)
couch.client.client.shutdownNow()
}

}
```

Expand All @@ -595,40 +602,12 @@ sbt "run-main com.ibm.couchdb.examples.Basic"
```


## Mailing list

Please feel free to join our mailing list, we welcome all questions and
suggestions: https://groups.google.com/forum/#!forum/couchdb-scala


## Contributing

We welcome contributions, but request you follow these guidelines. Please raise
any bug reports on the project's [issue
tracker](https://github.com/beloglazov/couchdb-scala/issues).

In order for us to accept pull-requests, the contributor must first complete a
Contributor License Agreement (CLA). This clarifies the intellectual property
license granted with any contribution. It is for your protection as a
Contributor as well as the protection of IBM and its customers; it does not
change your rights to use your own Contributions for any other purpose.

You can download the CLAs here:

- [individual](cla/cla-individual.pdf)
- [corporate](cla/cla-corporate.pdf)

If you are an IBMer, please contact us directly as the contribution process is
slightly different.


## Contributors

- Anton Semenov https://github.com/GuyIncognito1986
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheeky.

- [Anton Beloglazov](http://beloglazov.info/) ([@beloglazov](https://github.com/beloglazov))
- Ermyas Abebe ([@ermyas](https://github.com/ermyas))


## Copyright and license

© Copyright 2015 IBM Corporation, Google Inc. Distributed under the [Apache 2.0
license](LICENSE).
Apache 2.0 license
120 changes: 29 additions & 91 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,86 +1,36 @@
import xerial.sbt.Sonatype.SonatypeKeys._

sonatypeSettings

profileName := "com.ibm.couchdb-scala"

organization := "com.ibm"

name := "couchdb-scala"

version := "0.8.0-SNAPSHOT"

scalaVersion := "2.11.8"

description := "A purely functional Scala client for CouchDB"

homepage := Some(url("https://github.com/beloglazov/couchdb-scala"))

version := "1.0.3.2"
scalaVersion := "2.12.7"
description := "A purely functional Scala client for CouchDB based on work by ibm guys (Anton Beloglazov and Ermyas Abebe)"
publishMavenStyle := true
licenses := Seq("The Apache Software License, Version 2.0"
-> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
publishTo := sonatypePublishTo.value
sonatypeProfileName := "io.github.guyincognito1986"
test in assembly := {}
organization := "io.github.guyincognito1986"
import xerial.sbt.Sonatype._
sonatypeProjectHosting := Some(GitHubHosting("guyincognito1986", "couchdb-scala", "[email protected]"))

libraryDependencies ++= Seq(
"org.scalaz" %% "scalaz-core" % "7.2.6",
"org.scalaz" %% "scalaz-effect" % "7.2.6",
"org.http4s" %% "http4s-core" % "0.14.6a",
"org.http4s" %% "http4s-client" % "0.14.6a",
"org.http4s" %% "http4s-blaze-client" % "0.14.6a",
"com.lihaoyi" %% "upickle" % "0.4.1",
"com.github.julien-truffaut" %% "monocle-core" % "1.2.2",
"com.github.julien-truffaut" %% "monocle-macro" % "1.2.2",
"org.log4s" %% "log4s" % "1.3.0",
"org.scalaz" %% "scalaz-core" % "7.2.26",
"org.scalaz" %% "scalaz-concurrent" % "7.2.26",
"org.scalaz" %% "scalaz-effect" % "7.2.26",
"org.http4s" %% "http4s-core" % "0.17.6",
"org.http4s" %% "http4s-client" % "0.17.6",
"org.http4s" %% "http4s-blaze-client" % "0.17.6",
"com.lihaoyi" %% "upickle" % "0.4.4",
"com.github.julien-truffaut" %% "monocle-core" % "1.3.2",
"com.github.julien-truffaut" %% "monocle-macro" % "1.3.2",
"org.log4s" %% "log4s" % "1.4.0",
"ch.qos.logback" % "logback-classic" % "1.1.7",
"org.specs2" %% "specs2" % "3.7" % "test",
"org.typelevel" %% "scalaz-specs2" % "0.3.0" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.0" % "test",
"org.scalaz" %% "scalaz-scalacheck-binding" % "7.2.1" % "test"
"org.specs2" %% "specs2-core" % "3.8.9" % "test",
"org.typelevel" %% "scalaz-specs2" % "0.5.2" % "test",
"org.scalacheck" %% "scalacheck" % "1.14.0" % "test",
"org.scalaz" %% "scalaz-scalacheck-binding" % "7.2.26-scalacheck-1.14" % "test"
)

scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture",
"-Ywarn-unused-import"
)

scalacOptions in (Compile, console) ~= (_ filterNot (
List("-Ywarn-unused-import", "-Xfatal-warnings").contains(_)))

wartremover.wartremoverSettings

wartremover.wartremoverErrors in (Compile, compile) ++= Seq(
wartremover.Wart.Any,
wartremover.Wart.Any2StringAdd,
wartremover.Wart.EitherProjectionPartial,
wartremover.Wart.OptionPartial,
wartremover.Wart.Product,
wartremover.Wart.Serializable,
wartremover.Wart.ListOps
)

lazy val compileScalastyle = taskKey[Unit]("compileScalastyle")

compileScalastyle := org.scalastyle.sbt.ScalastylePlugin.scalastyle.in(Compile).toTask("").value

(compile in Compile) <<= (compile in Compile) dependsOn compileScalastyle

lazy val testScalastyle = taskKey[Unit]("testScalastyle")

testScalastyle := org.scalastyle.sbt.ScalastylePlugin.scalastyle.in(Test).toTask("").value

(test in Test) <<= (test in Test) dependsOn testScalastyle

testFrameworks := Seq(TestFrameworks.Specs2, TestFrameworks.ScalaCheck)

parallelExecution in Test := false
Expand All @@ -94,22 +44,10 @@ initialCommands in console in Test := "import scalaz._, Scalaz._, scalacheck.Sca

logBuffered := false

publishMavenStyle := true

publishArtifact in Test := false

pomExtra := {
<scm>
<connection>scm:git:[email protected]:beloglazov/couchdb-scala.git</connection>
<developerConnection>scm:git:[email protected]:beloglazov/couchdb-scala.git</developerConnection>
<url>https://github.com/beloglazov/couchdb-scala</url>
</scm>
<developers>
<developer>
<id>beloglazov</id>
<name>Anton Beloglazov</name>
<email>[email protected]</email>
<url>http://beloglazov.info</url>
</developer>
</developers>
}
assemblyMergeStrategy in assembly := {
case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard
case "reference.conf" => MergeStrategy.concat
case _ => MergeStrategy.last
}
26 changes: 15 additions & 11 deletions examples/src/main/scala/com/ibm/couchdb/examples/Basic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ package com.ibm.couchdb.examples

import com.ibm.couchdb._
import org.slf4j.LoggerFactory

import scalaz._
import scalaz.concurrent.Task
import fs2.Task

object Basic extends App {
private val logger = LoggerFactory.getLogger(Basic.getClass)
Expand All @@ -46,22 +44,28 @@ object Basic extends App {
typeMapping.get(classOf[Person]).foreach { mType =>
val actions: Task[Seq[Person]] = for {
// Delete the database or ignore the error if it doesn't exist
_ <- couch.dbs.delete(dbName).ignoreError
_ <- couch.dbs.delete(dbName)
// Create a new database
_ <- couch.dbs.create(dbName)
// Insert documents into the database
_ <- db.docs.createMany(Seq(alice, bob, carl))
// Retrieve all documents from the database and unserialize to Person
docs <- db.docs.getMany.includeDocs[Person].byTypeUsingTemporaryView(mType).build.query
} yield docs.getDocsData

couch.dbs.delete(dbName)
couch.dbs.create(dbName)
db.docs.createMany(Seq(alice, bob, carl))
db.docs.getMany.includeDocs[Person].byTypeUsingTemporaryView(mType).build.query
// Execute the actions and process the result
actions.unsafePerformSyncAttempt match {
// In case of an error (left side of Either), print it
case -\/(e) => logger.error(e.getMessage, e)
// In case of a success (right side of Either), print each object
case \/-(a) => a.foreach(x => logger.info(x.toString))
}
actions.unsafeRunAsync(x =>
try{
x.map(ps => ps.foreach(p => logger.info(p.toString)))
()
}
catch{
case e: Throwable => logger.error(e.toString)
}
)
couch.client.client.shutdownNow()
}
}
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.2.6
12 changes: 4 additions & 8 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
resolvers += Resolver.sonatypeRepo("releases")

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.0-RC1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "latest.integration")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "latest.integration")

addSbtPlugin("org.brianmckenna" % "sbt-wartremover" % "0.14")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "latest.integration")
2 changes: 1 addition & 1 deletion src/main/scala/com/ibm/couchdb/CouchDb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CouchDb private(
val server = new Server(client)
val dbs = new Databases(client)

private val memo = Memo.mutableHashMapMemo[(String, TypeMapping), CouchDbApi] {
private val memo = Memo.immutableHashMapMemo[(String, TypeMapping), CouchDbApi] {
case (db, types) =>
CouchDbApi(
db,
Expand Down
Loading