From a78ccad57a121ca0fc5923579219b6b4f07603a8 Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Tue, 20 Jan 2015 16:08:07 -0500 Subject: [PATCH 1/3] Fix response filepath when contains directory --- R/plotly.R | 4 ++-- tests/testthat/test-plotly-filename.R | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/testthat/test-plotly-filename.R diff --git a/R/plotly.R b/R/plotly.R index 6cc132cab3..c667e56846 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -105,8 +105,8 @@ For more help, see https://plot.ly/R or contact .") } resp <- fromJSON(respst, simplify = FALSE) - if (!is.null(resp$filename)) - pub$filename <- resp$filename + if (!is.null(kwargs$filename)) + resp$filename <- kwargs$filename if (!is.null(resp$error)) cat(resp$err) if (!is.null(resp$warning)) diff --git a/tests/testthat/test-plotly-filename.R b/tests/testthat/test-plotly-filename.R new file mode 100644 index 0000000000..986ea00ad5 --- /dev/null +++ b/tests/testthat/test-plotly-filename.R @@ -0,0 +1,21 @@ +context("Filename") + +test_that("Filepath with directories is returned as passed", { + x <- c(-1.50548425849621, 0.023267831354017, -1.38460390550496, + -0.805552814226363, 1.59651736643461, 0.936302685370894, + 0.512729504994891, -0.24492573745161, -0.465348603632604, + 0.173523456651353, 0.389491211182137, -0.275308705542518, + -0.132866228059449, -0.336255877656944, 0.916535489109209, + -0.936870130264329, 0.363137478307925, -1.26433467241078, + -0.388804188531171, 0.785842426281935) + data = list(x=x, + type="histogramx") + l <- list(autosize=FALSE, width=600, height=400, showlegend=FALSE) + + py <- plotly("get_test_user_2", "0f9es4r6tm") + response <- py$plotly(data, kwargs=list(layout=l, filename="directory/hist", + fileopt="overwrite")) + + expect_identical(response$filename, "directory/hist") + +}) From e436d0a9edef93ae4638de14e855208c88cd8aa5 Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Tue, 20 Jan 2015 16:22:41 -0500 Subject: [PATCH 2/3] Improve style a little bit --- tests/testthat/test-plotly-filename.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-plotly-filename.R b/tests/testthat/test-plotly-filename.R index 986ea00ad5..51c92b14ec 100644 --- a/tests/testthat/test-plotly-filename.R +++ b/tests/testthat/test-plotly-filename.R @@ -1,6 +1,6 @@ context("Filename") -test_that("Filepath with directories is returned as passed", { +test_that("filepath with directories is returned as passed", { x <- c(-1.50548425849621, 0.023267831354017, -1.38460390550496, -0.805552814226363, 1.59651736643461, 0.936302685370894, 0.512729504994891, -0.24492573745161, -0.465348603632604, @@ -8,8 +8,7 @@ test_that("Filepath with directories is returned as passed", { -0.132866228059449, -0.336255877656944, 0.916535489109209, -0.936870130264329, 0.363137478307925, -1.26433467241078, -0.388804188531171, 0.785842426281935) - data = list(x=x, - type="histogramx") + data = list(x=x, type="histogramx") l <- list(autosize=FALSE, width=600, height=400, showlegend=FALSE) py <- plotly("get_test_user_2", "0f9es4r6tm") From dfa24ee20095699d3198b888dbafcad67ef3c786 Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Thu, 22 Jan 2015 12:13:57 -0500 Subject: [PATCH 3/3] Increment version number to 0.5.18 --- DESCRIPTION | 2 +- NEWS | 4 ++++ R/plotly-package.r | 2 +- R/plotly.R | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8b712c64ab..10b44ced77 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: plotly Type: Package Title: Interactive, publication-quality graphs online. -Version: 0.5.17 +Version: 0.5.18 Authors@R: c(person("Chris", "Parmer", role = c("aut", "cre"), email = "chris@plot.ly"), person("Scott", "Chamberlain", role = "aut", diff --git a/NEWS b/NEWS index 90ae1f4812..3e9a48217a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +0.5.18 -- 22 January 2015. + +Return proper filepath when filename contains directories. + 0.5.17 -- 30 December 2014. Support date-time binning in histograms. diff --git a/R/plotly-package.r b/R/plotly-package.r index 136a643a35..1a00944894 100644 --- a/R/plotly-package.r +++ b/R/plotly-package.r @@ -7,7 +7,7 @@ #' \itemize{ #' \item Package: plotly #' \item Type: Package -#' \item Version: 0.5.17 +#' \item Version: 0.5.18 #' \item Date: 2014-03-07 #' \item License: MIT #' } diff --git a/R/plotly.R b/R/plotly.R index c667e56846..db8978d135 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -82,7 +82,7 @@ For more help, see https://plot.ly/R or contact .") # public attributes/methods that the user has access to pub <- list(username=username, key=key, filename="from api", fileopt=NULL, - version="0.5.17") + version="0.5.18") priv <- list() pub$makecall <- function(args, kwargs, origin) {