From 8ce9aa77e4e5d448ff590f3a7216b476af99e04f Mon Sep 17 00:00:00 2001 From: jennybc Date: Wed, 1 Jul 2015 11:48:48 +0200 Subject: [PATCH] machinations necessary for success w/ CRAN submission [skip ci] suppress execution of certain vignette chunks on CRAN * to still build the full vignette locally, make sure envvar NOT_CRAN is TRUE * I forgot to do this and submitted a largely unexecuted vignette :( * I figure I'll need to update for other reasons before too long and can re-submit vignette at same time make sure the *unencrypted* token is not sent to CRAN * list the token in tests/testthat in .Rbuildignore * this will cause tests to fail on travis (hence we are skipping ci) --- .Rbuildignore | 1 + cran-comments.md | 4 ++++ vignettes/basic-usage.Rmd | 39 +++++++++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 4f73762..2d302f4 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,3 +11,4 @@ rsconnect ^cran-comments.md$ ^README.html$ tests/testthat/googlesheets_token.rds.enc +tests/testthat/googlesheets_token.rds diff --git a/cran-comments.md b/cran-comments.md index 768f55e..0fbdbde 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -3,12 +3,16 @@ * ubuntu 12.04 on travis-ci, R 3.2.1 * win-builder, devel and release 3.2.1 +This is a resubmission. In the previous submission, Kurt remarked on the fact that CRAN could not re-build the vignette outputs, since the vignette uses the package to make authenticated calls to the Google Sheets API. However, there is no way to securely provide an access token to CRAN. Therefore I have followed his advice to conditionally suppress evaluation of these specific chunks. This has cleared the NOTE about the vignette. + ## R CMD check results There were no ERRORs or WARNINGs. There is one NOTE: +Note #1: + * checking CRAN incoming feasibility ... NOTE Maintainer: 'Jennifer Bryan ' New submission diff --git a/vignettes/basic-usage.Rmd b/vignettes/basic-usage.Rmd index 012fbd6..4c69bd2 100644 --- a/vignettes/basic-usage.Rmd +++ b/vignettes/basic-usage.Rmd @@ -16,18 +16,24 @@ vignette: > knitr::opts_chunk$set( collapse = TRUE, comment = "#>", - fig.path = "README-" + fig.path = "README-", + purl = FALSE ) +if(identical(tolower(Sys.getenv("NOT_CRAN")), "true")) { + NOT_CRAN <- TRUE +} else { + NOT_CRAN <- FALSE +} ``` -```{r auth, include = FALSE} +```{r auth, include = FALSE, eval = NOT_CRAN} ## I grab the token from the testing directory because that's where it is to be ## found on Travis token_path <- file.path("..", "tests", "testthat", "googlesheets_token.rds") suppressMessages(googlesheets::gs_auth(token = token_path, verbose = FALSE)) ``` -```{r pre-clean, include = FALSE} +```{r pre-clean, include = FALSE, eval = NOT_CRAN} ## if a previous compilation of this document leaves anything behind, i.e. if it ## aborts, clean up Google Drive first googlesheets::gs_vecdel(c("foo", "iris"), verbose = FALSE) @@ -43,7 +49,7 @@ suppressMessages(library(dplyr)) The `gs_ls()` function returns the sheets you would see in your Google Sheets home screen: . This should include sheets that you own and may also show sheets owned by others but that you are permitted to access, if you visited the sheet in the browser. Expect a prompt to authenticate yourself in the browser at this point (more below re: authentication). -```{r list-sheets} +```{r list-sheets, eval = NOT_CRAN} (my_sheets <- gs_ls()) # (expect a prompt to authenticate with Google interactively HERE) my_sheets %>% glimpse() @@ -68,7 +74,7 @@ If you plan to consume data from a sheet or edit it, you must first __register__ *We're using the built-in functions `gs_gap_key()` and `gs_gap_url()` to produce the key and browser URL for the Gapminder example sheet, so you can see how this will play out with your own projects.* -```{r register-sheet} +```{r register-sheet, eval = NOT_CRAN} gap <- gs_title("Gapminder") gap @@ -90,6 +96,11 @@ third_party_gap <- GAP_URL %>% gap <- gap %>% gs_gs() ``` +```{r register-sheet-cran-only, include = FALSE, eval = !NOT_CRAN} +gap <- gs_gap_key() %>% gs_key(lookup = FALSE, visibility = "public") +``` + + The registration functions `gs_title()`, `gs_key()`, `gs_url()`, and `gs_gs()` return a registered sheet as a `googlesheet` object, which is the first argument to practically every function in this package. Likewise, almost every function returns a freshly registered `googlesheet` object, ready to be stored or piped into the next command. *We export a utility function, `extract_key_from_url()`, to help you get and store the key from a browser URL. Registering via browser URL is fine, but registering by key is probably a better idea in the long-run.* @@ -215,7 +226,7 @@ gap_1col %>% gs_simplify_cellfeed(notation = "none", col_names = TRUE) You can use `googlesheets` to create new spreadsheets. -```{r new-sheet} +```{r new-sheet, eval = NOT_CRAN} foo <- gs_new("foo") foo ``` @@ -233,7 +244,7 @@ If you have the choice, `gs_add_row()` is faster, but it can only be used when y We'll work within the completely empty sheet created above, `foo`. If your edit populates the sheet with everything it should have, set `trim = TRUE` and we will resize the sheet to match the data. Then the nominal worksheet extent is much more informative (vs. the default of 1000 rows and 26 columns) and any future consumption via the cell feed will be much faster. -```{r edit-cells} +```{r edit-cells, eval = NOT_CRAN} ## foo <- gs_new("foo") ## initialize the worksheets foo <- foo %>% gs_ws_new("edit_cells") @@ -268,7 +279,7 @@ Read the function documentation for `gs_edit_cells()` for how to specify where t Let's clean up by deleting the `foo` spreadsheet we've been playing with. -```{r delete-sheet} +```{r delete-sheet, eval = NOT_CRAN} gs_delete(foo) ``` @@ -278,7 +289,7 @@ If you'd rather specify sheets for deletion by title, look at `gs_grepdel()` and Here's how we can create a new spreadsheet from a suitable local file. First, we'll write then upload a comma-delimited excerpt from the iris data. -```{r new-sheet-from-file} +```{r new-sheet-from-file, eval = NOT_CRAN} iris %>% head(5) %>% write.csv("iris.csv", row.names = FALSE) @@ -290,7 +301,7 @@ file.remove("iris.csv") Now we'll upload a multi-sheet Excel workbook. Slowly. -```{r new-sheet-from-xlsx} +```{r new-sheet-from-xlsx, eval = NOT_CRAN} gap_xlsx <- gs_upload(system.file("mini-gap.xlsx", package = "googlesheets")) gap_xlsx gap_xlsx %>% gs_read(ws = "Asia") @@ -298,7 +309,7 @@ gap_xlsx %>% gs_read(ws = "Asia") And we clean up after ourselves on Google Drive. -```{r delete-moar-sheets} +```{r delete-moar-sheets, eval = NOT_CRAN} gs_vecdel(c("iris", "mini-gap")) ## achieves same as: ## gs_delete(iris_ss) @@ -309,7 +320,7 @@ gs_vecdel(c("iris", "mini-gap")) You can download a Google Sheet as a csv, pdf, or xlsx file. Downloading the spreadsheet as a csv file will export the first worksheet (default) unless another worksheet is specified. -```{r export-sheet-as-csv} +```{r export-sheet-as-csv, eval = NOT_CRAN} gs_title("Gapminder") %>% gs_download(ws = "Africa", to = "gapminder-africa.csv") ## is it there? yes! @@ -318,7 +329,7 @@ read.csv("gapminder-africa.csv") %>% head() Download the entire spreadsheet as an Excel workbook. -```{r export-sheet-as-xlsx} +```{r export-sheet-as-xlsx, eval = NOT_CRAN} gs_title("Gapminder") %>% gs_download(to = "gapminder.xlsx") ``` @@ -327,7 +338,7 @@ Go check it out in Excel, if you wish! And now we clean up the downloaded files. -```{r clean-exported-files} +```{r clean-exported-files, eval = NOT_CRAN} file.remove(c("gapminder.xlsx", "gapminder-africa.csv")) ```