Permalink
Browse files

Merge branch 'master' of gitproxy:wactbprot/R4CouchDB

Conflicts:
	README.md

	modified:   R4CouchDB/DESCRIPTION
	new file:   R4CouchDB/LICENSE
	modified:   R4CouchDB/NAMESPACE
	modified:   R4CouchDB/R/cdbAddAttachment.R
	modified:   R4CouchDB/R/cdbAddDoc.R
	modified:   R4CouchDB/R/cdbDeleteDoc.R
	modified:   R4CouchDB/R/cdbGetConfig.R
	modified:   R4CouchDB/R/cdbGetDoc.R
	modified:   R4CouchDB/R/cdbGetUuid.R
	modified:   R4CouchDB/R/cdbGetUuidS.R
	modified:   R4CouchDB/R/cdbGetView.R
	modified:   R4CouchDB/R/cdbIni.R
	modified:   R4CouchDB/R/cdbListDB.R
	modified:   R4CouchDB/R/cdbMakeDB.R
	modified:   R4CouchDB/R/cdbRemoveDB.R
	modified:   R4CouchDB/R/cdbUpdateDoc.R
	modified:   R4CouchDB/man/cdbAddAttachment.Rd
	modified:   R4CouchDB/man/cdbAddDoc.Rd
	modified:   R4CouchDB/man/cdbGetConfig.Rd
	modified:   R4CouchDB/man/cdbGetDoc.Rd
	modified:   R4CouchDB/man/cdbGetUuid.Rd
	modified:   R4CouchDB/man/cdbGetUuidS.Rd
	modified:   R4CouchDB/man/cdbIni.Rd
	modified:   R4CouchDB/man/cdbListDB.Rd
	modified:   R4CouchDB/man/cdbMakeDB.Rd
	modified:   R4CouchDB/man/cdbRemoveDB.Rd
	modified:   R4CouchDB/man/cdbUpdateDoc.Rd
	deleted:    R4CouchDB_0.2.4.tar.gz
	deleted:    R4CouchDB_0.2.5.tar.gz
	new file:   R4CouchDB_0.3.3.tar.gz
	new file:   R4CouchDB_0.4.tar.gz
	modified:   README.md
	new file:   example/3dplot.pdf
	modified:   example/test-session.R
  • Loading branch information...
2 parents 3ee20d3 + 139b809 commit 7dd1cf6678a5dd181dc86b9880b1a21263212bc7 @wactbprot committed Jan 17, 2014
View
@@ -1,22 +1,22 @@
Package: R4CouchDB
Type: Package
Title: A R convenience layer for CouchDB
-Version: 0.3.2
-Date: 2013/10/30
-Author: wactbprot
-Maintainer: <thsteinbock@web.de>
+Version: 0.4
+Date: 2013/12/31
+Author: Thomas Bock
+Maintainer: wactbprot <thsteinbock@web.de>
Description: The R4CouchDB package provides a collection of functions for
basic database and document management operations such as add and
delete. Every cdbFunction() gets and returns a list() containing the
- connection setup. Such a list (in the documentation mostly called cdb)
+ connection setup. Such a list (in the documentation mostly called cdb)
can be generated by cdb <- cdbIni(). Then cdb also contains some function
- resp. functionality e.g cdb$baseUrl().
-License: BSD
+ resp. functionality e.g cdb$baseUrl().
+License: MIT + file LICENSE
LazyLoad: yes
Depends:
R (>= 2.7.0),
bitops,
- RCurl(>= 1.95),
+ RCurl (>= 1.95),
RJSONIO (>= 1.0)
Collate:
'cdbIni.R'
View
@@ -0,0 +1,2 @@
+YEAR:2014
+COPYRIGHT HOLDER: Thomas Bock
View
@@ -1,14 +1,9 @@
-export(cdbAddDoc)
-export(cdbAddAttachment)
-export(cdbDeleteDoc)
-export(cdbGetConfig)
-export(cdbGetDoc)
-export(cdbGetList)
-export(cdbGetUuid)
-export(cdbGetUuidS)
-export(cdbGetView)
-export(cdbIni)
-export(cdbListDB)
-export(cdbMakeDB)
-export(cdbRemoveDB)
-export(cdbUpdateDoc)
+# Export all names
+exportPattern(".")
+
+# Import all packages listed as Imports or Depends
+import(
+ bitops,
+ RCurl,
+ RJSONIO
+)
@@ -14,6 +14,32 @@
#' @return \item{cdb}{The result is stored in \code{cdb$res} }
#' @author wactbprot
#' @export
+#' @examples
+#' \dontrun{
+#' ccc <- cdbIni(DBName="r4couch_db")
+#' ccc$dataList <- list(normalDistRand = rnorm(20))
+#' ccc <- cdbAddDoc(ccc)
+#'# make a 3d plot (stolen from ?persp)
+#' x <- seq(-10, 10, length= 30)
+#' y <- x
+#' f <- function(x,y) {r <- sqrt(x^2+y^2); 10 * sin(r)/r }
+#' z <- outer(x, y, f)
+#'
+#' z[is.na(z)] <- 1
+#' op <- par(bg = "black")
+#' ccc$fileName <- "3dplot.pdf"
+#'
+#' pdf(ccc$fileName)
+#' persp(x, y, z,
+#' theta = 30,
+#' phi = 30,
+#' expand = 0.5,
+#' col = "lightblue")
+#' dev.off()
+#' # add the plot as attachment to the database
+#' # it workes over ccc$fileName
+#' ccc <- cdbAddAttachment(ccc)
+#'}
#' @keywords misc
#'
View
@@ -1,24 +1,34 @@
#' Generates a new document
-#'
+#'
#' This function adds a new document to an already existing database
-#'
+#'
#' This function is called addDoc (which means add a new document). Therefore
#' the \code{cdb$id} is requested using \code{cdbGetUuid()} for every document
#' to add if no \code{cdb$id} is provided. If a \code{cdb$id} is provided the
#' function fails when a document with the given id already exists. In this
#' case one should use \code{cdbUpdateDoc()}. Since version v0.6 the function
#' writes the \code{_rev} and \code{_id} key to the top level of
#' \code{cdb$dataList}.
-#'
+#'
#' @usage cdbAddDoc(cdb)
#' @param cdb The list \code{cdb} only has to contain a \code{cdb$dataList}
#' which is not an empty \code{list()}.
#' @return \item{cdb}{The couchdb response is stored in \code{cdb$res} }
#' @author wactbprot
#' @export
+#'@examples
+#'\dontrun{
+#' ccc <- cdbIni()
+#' # I assume a database at localhost:5984 already exists
+#' ccc$DBName <- "r4couchdb_db"
+#' ccc$dataList <- list(normalDistRand = rnorm(20))
+#' ccc <- cdbAddDoc(ccc)
+#'
+#'}
+#'
#' @seealso \code{cdbGetDoc()}
#' @keywords misc
-#'
+#'
cdbAddDoc <- function( cdb){
@@ -29,21 +39,21 @@ cdbAddDoc <- function( cdb){
if(cdb$id == ""){
cdb <- cdbGetUuid(cdb)
}
-
+
adrString <- paste(cdb$baseUrl(cdb),
cdb$DBName,"/",
cdb$id,
sep="")
pf <-cdb$toJSON(cdb$dataList)
-
+
res <- getURL(adrString,
customrequest = 'PUT',
postfields = pf,
httpheader=c('Content-Type: application/json;charset=utf-8'),
.opts =cdb$opts(cdb))
-
+
res <- cdb$fromJSON( res )
-
+
if(length(res$ok) > 0){
cdb$dataList$'_id' <- res$id
cdb$dataList$'_rev' <- res$rev
@@ -53,7 +63,7 @@ cdbAddDoc <- function( cdb){
cdb$error <- paste(cdb$error, res$error)
}
}
-
+
if(!(cdb$error == "")){
stop( cdb$error )
}
@@ -16,7 +16,6 @@
#' @export
#' @seealso \code{cdbAddDoc()}
#' @references
-#'
#' \url{ http://couchdb.apache.org/ } \url{ http://www.omegahat.org/ }
#' @keywords misc
#'
@@ -11,6 +11,10 @@
#' converting the answer into a list using \code{fromJSON()}. }
#' @author wactbprot
#' @export
+#' @examples
+#'\dontrun{
+#' cdbGetConfig(cdbIni())$res
+#'}
#' @seealso \code{cdbMakeDB}
#' @references
#'
View
@@ -9,7 +9,6 @@
#'
#' in cdb$errors
#' @return
-#'
#' \item{cdb }{The result of the request is stored in \code{cdb$res} after
#' converting the answer into a list using \code{fromJSON()}. If a list entry
#' needed in \code{cdb} is not provided \code{cdb$error} gives some
@@ -18,9 +17,16 @@
#' }
#' @author wactbprot
#' @export
+#' @examples
+#' \dontrun{
+#' ccc <- cdbIni()
+#' ccc$newDBName <- "r4couchdb_db"
+#' ccc$dataList <- list(normalDistRand = rnorm(20))
+#' ccc <- cdbAddDoc(ccc)
+#' cdbGetDoc(ccc)$res
+#' }
#' @seealso \code{cdbAddDoc()}
#' @references
-#'
#' \url{ http://couchdb.apache.org/ } \url{ http://www.omegahat.org/ }
#' @keywords misc
#'
View
@@ -1,26 +1,30 @@
#' Function for request one id
-#'
+#'
#' Function returns a 128bit uuid requested from CouchDB
-#'
+#'
#' Simple CouchDB API end point to http://serverName:port/_uuids.
-#'
+#'
#' @param cdb Only the connection settings \code{cdb$port} and
#' \code{cdb$serverName} is needed.
#' @return
-#'
+#'
#' \item{cdb }{The result of the request is stored in \code{cdb$id} after
#' converting the answer into a list using \code{fromJSON()}.}
#' @author wactbprot
#' @export
+#' @examples
+#' \dontrun{
+#' cdbGetUuid(cdbIni())$res
+#'}
+#'
#' @seealso \code{cdbMakeDB}
#' @references
-#'
#' \url{ http://www.omegahat.org/RCurl/ } \url{
#' http://www.omegahat.org/RJSONIO/ } \url{ http://couchdb.apache.org/ }
#' @keywords misc
cdbGetUuid <- function(cdb){
-
+
fname <- deparse(match.call()[[1]])
cdb <- cdb$checkCdb(cdb,fname)
@@ -41,5 +45,5 @@ cdbGetUuid <- function(cdb){
}else{
stop(cdb$error)
- }
+ }
}
@@ -15,6 +15,15 @@
#' converting the answer into a list using \code{fromJSON()}. }
#' @author wactbprot
#' @export
+#' @examples
+#'\dontrun{
+#' ccc <- cdbIni()
+#' ccc$queryParam <- "count=10"
+#' cdbGetUuidS(ccc)$res
+#' # better clear params in order to avoid
+#' # unwanted side effects
+#' ccc$queryParam <- ""
+#'}
#' @seealso \code{cdbMakeDB}
#' @references
#'
View
@@ -21,7 +21,6 @@
#' @author wactbprot
#' @export
#' @references
-#'
#' \url{ http://www.omegahat.org/RCurl/ } \url{
#' http://www.omegahat.org/RJSONIO/ } \url{ http://couchdb.apache.org/ } \url{
#' http://www.omegahat.org/RJavaScript/ }
Oops, something went wrong.

0 comments on commit 7dd1cf6

Please sign in to comment.