Skip to content

Commit

Permalink
- modified cdb$toJSON to be able to push \r into database
Browse files Browse the repository at this point in the history
- del some old versions
	geändert:   R4CouchDB/DESCRIPTION
	geändert:   R4CouchDB/NAMESPACE
	geändert:   R4CouchDB/R/cdbAddDoc.R
	geändert:   R4CouchDB/R/cdbIni.R
	gelöscht:    R4CouchDB_0.08.tar.gz
	gelöscht:    R4CouchDB_0.09.tar.gz
	neue Datei:   R4CouchDB_0.1.2.tar.gz
	gelöscht:    R4CouchDB_0.1.tar.gz
  • Loading branch information
wactbprot committed Jan 30, 2013
1 parent db02118 commit a52311d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
6 changes: 3 additions & 3 deletions R4CouchDB/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: R4CouchDB
Type: Package
Title: A R convenience layer for CouchDB
Version: 0.1.1
Date: 2012/10/13
Version: 0.1.2
Date: 2013/01/29
Author: wactbprot
Maintainer: <thsteinbock@web.de>
Description: The R4CouchDB package provides a collection of functions for
Expand All @@ -17,6 +17,7 @@ Depends:
RCurl(>= 1.6),
RJSONIO (>= 0.95)
Collate:
'cdbIni.R'
'cdbAddAttachment.R'
'cdbAddDoc.R'
'cdbDeleteDoc.R'
Expand All @@ -26,7 +27,6 @@ Collate:
'cdbGetUuid.R'
'cdbGetUuidS.R'
'cdbGetView.R'
'cdbIni.R'
'cdbListDB.R'
'cdbMakeDB.R'
'cdbRemoveDB.R'
Expand Down
2 changes: 2 additions & 0 deletions R4CouchDB/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export(cdbIni)
export(cdbAddDoc)
export(cdbAddAttachment)
export(cdbDeleteDoc)
export(cdbGetConfig)
export(cdbGetDoc)
Expand Down
3 changes: 1 addition & 2 deletions R4CouchDB/R/cdbAddDoc.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ cdbAddDoc <- function( cdb){
sep="")

res <- getURL(adrString,
customrequest = "PUT",
curl=cdb$curl,
customrequest = 'PUT',
postfields = cdb$toJSON(cdb$dataList),
httpheader=c('Content-Type: application/json'),
.opts =cdb$opts(cdb))
Expand Down
20 changes: 15 additions & 5 deletions R4CouchDB/R/cdbIni.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
#' The list: \code{ cdb <- list(serverName = "localhost", ... )} is returned if
#' the packages \code{library(RCurl)} and \code{library(RJSONIO)} are
#' successfully loaded.
#'
#'
#' http://www.omegahat.org/RJSONIO/
#' thanx to Duncan Temple Lang
#'
#' @author wactbprot
#' @export
#' @usage cdbIni(serverName="localhost",port="5984",dbname="")
#' @param serverName server name
#' @param port port
#' @param dbname name of database
#' @return
#'
#' \item{cdb}{see details for the default settings of this function }
#' @author wactbprot
#' @keywords misc
#'

cdbIni <- function(serverName="localhost",port="5984",dbname=""){
## http://www.omegahat.org/RJSONIO/
## thanx to Duncan Temple Lang
rc <- library(RCurl,
logical.return = TRUE,
quietly =TRUE)
Expand Down Expand Up @@ -75,7 +78,14 @@ cdbIni <- function(serverName="localhost",port="5984",dbname=""){
}

cdb$toJSON <- function(lst){
return(toJSON(lst))
## one can {"a":"\r"} have in the
## database but one can not send it back
## in this way. A \r is here replaced by \\r
## resulting in \r in the database
jsn <- toJSON(lst, collapse = "")
jsn <- gsub("\\r","\\\\r",jsn)
jsn <- gsub("\\n","\\\\n",jsn)
return(jsn)
}

cdb$checkRes <- function(cdb,res){
Expand Down
Binary file removed R4CouchDB_0.08.tar.gz
Binary file not shown.
Binary file removed R4CouchDB_0.09.tar.gz
Binary file not shown.
Binary file added R4CouchDB_0.1.2.tar.gz
Binary file not shown.
Binary file removed R4CouchDB_0.1.tar.gz
Binary file not shown.

0 comments on commit a52311d

Please sign in to comment.