Permalink
Browse files

notrun examples, rm trailing whitspaces

	geändert:   R4CouchDB/DESCRIPTION
	geändert:   R4CouchDB/NAMESPACE
	geändert:   R4CouchDB/R/cdbAddAttachment.R
	geändert:   R4CouchDB/R/cdbAddDoc.R
	geändert:   R4CouchDB/R/cdbDeleteDoc.R
	geändert:   R4CouchDB/R/cdbGetConfig.R
	geändert:   R4CouchDB/R/cdbGetDoc.R
	geändert:   R4CouchDB/R/cdbGetUuid.R
	geändert:   R4CouchDB/R/cdbGetUuidS.R
	geändert:   R4CouchDB/R/cdbGetView.R
	geändert:   R4CouchDB/R/cdbIni.R
	geändert:   R4CouchDB/R/cdbListDB.R
	geändert:   R4CouchDB/R/cdbMakeDB.R
	geändert:   R4CouchDB/R/cdbRemoveDB.R
	geändert:   R4CouchDB/R/cdbUpdateDoc.R
	geändert:   R4CouchDB/man/cdbAddAttachment.Rd
	geändert:   R4CouchDB/man/cdbAddDoc.Rd
	geändert:   R4CouchDB/man/cdbGetConfig.Rd
	geändert:   R4CouchDB/man/cdbGetDoc.Rd
	geändert:   R4CouchDB/man/cdbGetUuid.Rd
	geändert:   R4CouchDB/man/cdbGetUuidS.Rd
	geändert:   R4CouchDB/man/cdbIni.Rd
	geändert:   R4CouchDB/man/cdbListDB.Rd
	geändert:   R4CouchDB/man/cdbMakeDB.Rd
	geändert:   R4CouchDB/man/cdbRemoveDB.Rd
	geändert:   R4CouchDB/man/cdbUpdateDoc.Rd
	geändert:   R4CouchDB_0.4.tar.gz
	geändert:   example/test-session.R
  • Loading branch information...
1 parent 35b2762 commit 139b8092045353baa040dea71cd84ccc4bda9a40 @wactbprot committed Jan 1, 2014
View
@@ -4,7 +4,7 @@ Title: A R convenience layer for CouchDB
Version: 0.4
Date: 2013/12/31
Author: Thomas Bock
-Maintainer: <thsteinbock@web.de>
+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
View
@@ -1,14 +1,9 @@
-export(cdbAddAttachment)
-export(cdbAddDoc)
-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/ }
View
@@ -28,6 +28,14 @@
#' @param encSub a character which is used as a replacement for chars who can not be converted by iconv
#' @param attachmentsWithPath effects the result of the function cdbAddAttachment in the way the variable is named
#' @param digits digits kept at toJSON conversion
+#' @export
+#' @examples
+#'\dontrun{
+#' ccc <- cdbIni(digits=13,
+#' DBName="r4couch_db",
+#' attachmentsWithPath=FALSE,
+#' dataList=list(normalDistRand = rnorm(20)))
+#'}
#' @return \item{cdb}{The R4CouchDB (method) chain(ing) list }
#' @keywords misc
#'
View
@@ -14,9 +14,12 @@
#' the json answer into a list using \code{cdb$fromJSON()}.}
#' @author wactbprot
#' @export
+#' @examples
+#' \dontrun{
+#' cdbListDB(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
View
@@ -1,13 +1,13 @@
#' Creates a new database
-#'
+#'
#' The name of the new database is taken from \code{cdb$newDBName}.
-#'
+#'
#' The work is done by \code{getURL()} from Duncans RCurl package.
-#'
+#'
#' After creating the new database the function makes the shortcut
#' \code{cdb$DBName <- cdb$newDBName} so that further operations happen on the
#' new created database. Finaly \code{cdb$newDBName <- ""}.
-#'
+#'
#' @usage cdbMakeDB(cdb)
#' @param cdb The \code{cdb} have to provide \code{cdb$serverName},
#' \code{cdb$port} and \code{cdb$newDBName}
@@ -16,15 +16,25 @@
#' @note The convention for database naming should be implemented.
#' @author wactbprot
#' @export
+#' @examples
+#'\dontrun{
+#' ccc <- cdbIni()
+#' ccc$newDBName <- "r4couchdb_db"
+#' ccc <- cdbMakeDB(ccc)
+#' ccc$res
+#' ccc$removeDBName <- ccc$DBName
+#' cdbRemoveDB(ccc)$res
+#'}
+#'
#' @seealso \code{cdbUpdateDoc}
#' @references \url{ http://couchdb.apache.org/ }
#' @keywords misc
cdbMakeDB <- function(cdb){
-
+
fname <- deparse(match.call()[[1]])
cdb <- cdb$checkCdb(cdb,fname)
-
+
if(cdb$error == ""){
adrString <- paste(cdb$baseUrl(cdb),
cdb$newDBName,
@@ -34,12 +44,12 @@ cdbMakeDB <- function(cdb){
customrequest = "PUT",
curl=cdb$curl,
.opts =cdb$opts(cdb))
-
- cdb$DBName <- cdb$newDBName
+
+ cdb$DBName <- cdb$newDBName
cdb$newDBName <- ""
return(cdb$checkRes(cdb,res))
-
+
}else{
stop(cdb$error)
}
View
@@ -1,32 +1,42 @@
#' Function to remove a database
-#'
+#'
#' Removing a database means sending a http- "DELETE"- request to
#' \code{http://cdb$serverName:cdb$port/ ...}
-#'
+#'
#' In \code{cdb} a entry \code{cdb$delDBName} should be provided for more
#' explicit deleting respectively more secure removing.
-#'
+#'
#' @usage cdbRemoveDB(cdb)
#' @param cdb The \code{cdb} has to provide \code{cdb$serverName},
#' \code{cdb$port} and \code{cdb$DBName}
#' @return \item{cdb}{The CouchDB answer is stored in \code{cdb$res}. Any
#' problems on the R side are reportet in \code{cdb$error} }
#' @author wactbprot
#' @export
+#'@examples
+#'\dontrun{
+#' ccc <- cdbIni()
+#' ccc$newDBName <- "r4couchdb_db"
+#' ccc <- cdbMakeDB(ccc)
+#' ccc$res
+#' ccc$removeDBName <- ccc$DBName
+#' cdbRemoveDB(ccc)$res
+#'}
+#'
#' @seealso \code{cdbMakeDB}
#' @references \url{ http://couchdb.apache.org/ }
#' @keywords misc
cdbRemoveDB <- function(cdb){
-
+
fname <- deparse(match.call()[[1]])
cdb <- cdb$checkCdb(cdb,fname)
-
+
if( cdb$error == ""){
adrString <- paste(cdb$baseUrl(cdb),
cdb$removeDBName,
sep="")
-
+
res <- getURL(adrString,
curl=cdb$curl,
customrequest = "DELETE",
Oops, something went wrong.

0 comments on commit 139b809

Please sign in to comment.