From f2de8149bf79308493738a6d7d7e43496c278d81 Mon Sep 17 00:00:00 2001 From: Gunnlaugur Thor Briem Date: Fri, 26 Aug 2011 00:00:00 +0000 Subject: [PATCH] version 0.6.1 --- DESCRIPTION | 6 +++--- MD5 | 13 +++++++------ NAMESPACE | 1 + NEWS | 13 +++++++++++-- R/package.r | 2 +- R/rdatamarket.r | 35 +++++++++++++++++++++++++++++------ README.md | 4 ++++ man/dmCurlOptions.Rd | 29 +++++++++++++++++++++++++++++ 8 files changed, 85 insertions(+), 18 deletions(-) create mode 100644 man/dmCurlOptions.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 8a489cc..3db5b4f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,10 +8,10 @@ Description: Fetches data from DataMarket.com, either as timeseries in zoo form (dmseries) or as long-form data frames (dmlist). Metadata including dimension structure is fetched with dminfo, or just the dimensions with dmdims. -Version: 0.6 +Version: 0.6.1 URL: http://datamarket.com/api/lib/rdatamarket Depends: R (>= 2.10.0), zoo Collate: 'package.r' 'rdatamarket.r' 'util.r' -Packaged: 2011-08-23 18:39:06 UTC; gthb +Packaged: 2011-08-26 12:14:59 UTC; gthb Repository: CRAN -Date/Publication: 2011-08-23 20:03:16 +Date/Publication: 2011-08-26 18:04:35 diff --git a/MD5 b/MD5 index c0a5d41..d288443 100644 --- a/MD5 +++ b/MD5 @@ -1,13 +1,14 @@ -ee4d4fbc931e93a5a74d32e87c31efba *DESCRIPTION -06471e891a85263bd5bb67fea38b821e *NAMESPACE -8dac9696b0ff06d22b0f7322e9b07a0c *NEWS -77edd2757164461deab6ee9e04a432bb *R/package.r -1f052a0f4d64bfaedbbf5d5956a6d61a *R/rdatamarket.r +9d162f681b8a18105538b8a88be645f6 *DESCRIPTION +fdc909b9cb965c08bed244a8341e1227 *NAMESPACE +513b480bf8f84a3b53bd7ef98c8794c1 *NEWS +8423009b4e9fbeb6673fb1d390d532e6 *R/package.r +7ae154c58d711b8f70df63f0acfec424 *R/rdatamarket.r 68dd96bcba0cf6be3c6f7e9390ffde53 *R/util.r -85c54c4b791c4c6470cd189a145dfdb4 *README.md +7a34f8f10337e9b52bbb91ae22be7caa *README.md 65d5b27f729985fcea4a270b54229a12 *demo/00Index 877c93d6c69e5f7cdf1fdf72bc84a340 *demo/rdatamarket-usage.r 6bfdf1f00cc895a718478fdd6fb33334 *inst/tests/test-all.r +03a5156f9f5a5fe2103f736ebfbc3d41 *man/dmCurlOptions.Rd 5dd7524ead630b89f1ddf71eb9e1ef46 *man/dmdims.Rd e0cd42fa1d806daae25e492c2142decb *man/dminfo.Rd 990841d9182cf2c42131915ae4e6d4fe *man/dminit.Rd diff --git a/NAMESPACE b/NAMESPACE index a6a54fe..6790c11 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,4 @@ +export(dmCurlOptions) export(dmdims) export(dminfo) export(dminit) diff --git a/NEWS b/NEWS index 20236c9..e73560d 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,13 @@ -rdatamarket 0.6 ---------------- +rdatamarket 0.6.1 (2011-08-26) +-------------------------------------------------------------------------------- + +* Give full control of Curl options, including (importantly) HTTP proxying + +* Fix bug: format/print of dminfo object was failing when source_source absent + + + +rdatamarket 0.6 (2011-08-23) +-------------------------------------------------------------------------------- First release. diff --git a/R/package.r b/R/package.r index 305bd22..dbd4404 100644 --- a/R/package.r +++ b/R/package.r @@ -56,4 +56,4 @@ NULL .rdatamarketEnv <- new.env() .rdatamarketEnv$curlopts <- curlOptions() -.rdatamarketEnv$curlopts$httpheader <- NULL +.rdatamarketEnv$api.key <- NULL diff --git a/R/rdatamarket.r b/R/rdatamarket.r index e70406d..9963b61 100644 --- a/R/rdatamarket.r +++ b/R/rdatamarket.r @@ -28,10 +28,7 @@ short_url_services <- c( #' dminit(NULL) dminit <- function(api.key) { if (!missing(api.key)) { - .rdatamarketEnv$curlopts$httpheader$`X-DataMarket-API-Key` <- api.key - } - if (length(.rdatamarketEnv$curlopts$httpheader) == 0) { - .rdatamarketEnv$curlopts$httpheader <- NULL # else RCurl acts up + .rdatamarketEnv$api.key <- api.key } } @@ -306,7 +303,7 @@ format.dmdataset <- function(x, ...) { sprintf("Title: \"%s\"\nProvider: \"%s\"%s\nDimensions:\n %s", x$title, x$meta$provider_title, - ifelse(x$meta$source_source != "", + ifelse(!is.null(x$meta$source_source) && x$meta$source_source != "", sprintf(" (citing \"%s\")", x$meta$source_source), ""), paste(lapply(x$dimensions, FUN=format), collapse="\n ") @@ -349,6 +346,32 @@ print.dmerror <- function(x, ...) { invisible(); } +#' Set extra RCurl options for full HTTP control. +#' +#' Use this to control the options with which RCurl connections are created, see +#' \href{http://www.omegahat.org/RCurl/installed/RCurl/html/curlOptions.html}{RCurl::curlOptions}. +#' A common use is setting a proxy to work with your company's firewall setup, +#' see example below. +#' +#' @param ... name-value pairs specifying curl options. See full list of options +#' with `names(getCurlOptionsConstants())`, their types with +#' `getCurlOptionTypes()`, and full documentation in +#' \href{http://curl.haxx.se/docs/manpage.html}{the curl manpage}. +#' @param .opts a named list of options, or a previously created `CURLOptions` +#' object. These are merged with the options specified in `...`. +#' @export +#' @examples +#' \dontrun{dmCurlOptions(proxy='http://outproxy.mycompany.com')} +dmCurlOptions <- function(..., .opts=list()) { + .rdatamarketEnv$curlopts <- curlOptions(.opts=.opts, ...) +} + dmCurlHandle <- function() { - getCurlHandle(.opts=.rdatamarketEnv$curlopts) + getCurlHandle( + .opts=.rdatamarketEnv$curlopts, + httpheader=c( + .rdatamarketEnv$curlopts$httpheader, + 'X-DataMarket-API-Key'=.rdatamarketEnv$api.key + ) + ) } diff --git a/README.md b/README.md index 55e2c09..9a2a9e7 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ browser (or a short URL to it) into `dmlist` or `dmseries`: > plot(dmseries("http://data.is/nyFeP9")) > l <- dmlist("http://data.is/nyFeP9")) +If you need to go through an HTTP proxy, set it up this way: + + > dmCurlOptions(proxy="http://outproxy.mycompany.com") + # Reading metadata Get a dataset object (find the ID in a datamarket URL, or just paste in diff --git a/man/dmCurlOptions.Rd b/man/dmCurlOptions.Rd new file mode 100644 index 0000000..980334f --- /dev/null +++ b/man/dmCurlOptions.Rd @@ -0,0 +1,29 @@ +\name{dmCurlOptions} +\alias{dmCurlOptions} +\title{Set extra RCurl options for full HTTP control.} +\usage{ + dmCurlOptions(..., .opts = list()) +} +\arguments{ + \item{...}{name-value pairs specifying curl options. See + full list of options with + `names(getCurlOptionsConstants())`, their types with + `getCurlOptionTypes()`, and full documentation in + \href{http://curl.haxx.se/docs/manpage.html}{the curl + manpage}.} + + \item{.opts}{a named list of options, or a previously + created `CURLOptions` object. These are merged with the + options specified in `...`.} +} +\description{ + Use this to control the options with which RCurl + connections are created, see + \href{http://www.omegahat.org/RCurl/installed/RCurl/html/curlOptions.html}{RCurl::curlOptions}. + A common use is setting a proxy to work with your + company's firewall setup, see example below. +} +\examples{ +\dontrun{dmCurlOptions(proxy='http://outproxy.mycompany.com')} +} +