From 79423363265fabc18ba971f1e969fff11dfeb247 Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Sat, 3 Feb 2024 09:54:52 -0700 Subject: [PATCH 1/6] test: activate save-load tests (#256) * fix bug in box_save(), activate tests * add to NEWS, bump version --- DESCRIPTION | 2 +- NEWS.md | 4 ++ R/boxr_save_load.R | 2 +- tests/testthat/test_04_load_save.R | 71 ++++++++++++------------------ 4 files changed, 33 insertions(+), 46 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 20ffa9fd..58d00340 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: boxr Type: Package Title: Interface for the 'Box.com API' -Version: 0.3.6.9005 +Version: 0.3.6.9006 Authors@R: c( person("Brendan", "Rocks", email = "foss@brendanrocks.com", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index 99fda554..c03cd48b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,11 @@ # boxr 0.3.6 (development) +## fix bug in `box_save()`, setting default environment for evaluating dots (#255) + ## Internal +* activate tests for `box_save()`, `box_load()` (#255) + * update documentation to reflect updates to rio package. (#242, @chainsawriot) * update maintainer's email address. (#248) diff --git a/R/boxr_save_load.R b/R/boxr_save_load.R index 6884f3ec..051caa13 100644 --- a/R/boxr_save_load.R +++ b/R/boxr_save_load.R @@ -39,7 +39,7 @@ box_save <- function(..., dir_id = box_getwd(), file_name = ".RData", # - see https://github.com/r-lib/usethis/issues/1217 on.exit(fs::file_delete(temp_file)) - save(..., file = temp_file) + save(..., envir = parent.frame(), file = temp_file) box_ul(dir_id, temp_file, description = description) } diff --git a/tests/testthat/test_04_load_save.R b/tests/testthat/test_04_load_save.R index d90dd10f..729adcea 100644 --- a/tests/testthat/test_04_load_save.R +++ b/tests/testthat/test_04_load_save.R @@ -1,44 +1,27 @@ -# Load/Save --------------------------------------------------------------- -# For some reason (probably related to environements), these run fine in the -# console/terminal, but testthat can't find the files when running them with -# devtools::test() -# -# Leaving not-run, for now -if (FALSE) { - context("Load/Save") - - test_that("Saving R Object Remotely", { - skip_on_cran() - skip_if_no_token() - - # Here's an R object - test_list <- list(data.frame(), 1:10, letters) - test_vars$test_list <- test_list - rda_name <- "test.RData" - - # The upload should throw an error if it doesn't work - b <- box_save(test_list, envir = globalenv(), dir_id = 0, file_name = rda_name) - - # Put the id in an environment variable for subsequent tests - test_vars$object_return <- b - - # Did the file end up with the right name? - expect_equal(rda_name, b$entries[[1]]$name) - }) - - test_that("Loading remote R object", { - skip_on_cran() - skip_if_no_token() - - rm("object") - - # Can you load the remote file which stores the R object? - b <- box_load(test_vars$object_return$entries[[1]]$id) - - # Did it return the right object name? - expect_equal("object", b) - # Is the R object the same after it's journey? - expect_equal(object, test_vars$object) - }) - -} +context("Load/Save") + +test_that("object can be saved, retrieved, and deleted", { + skip_on_cran() + skip_if_no_token() + + # Here's an R object + test_ref <- list(data.frame(), 1:10, letters) + + test_list <- test_ref + rda_name <- "test.RData" + + b_save <- box_save(test_list, dir_id = 0, file_name = rda_name) + expect_equal(rda_name, b_save$name) + + rm("test_list") + + # will load data into `test_list` + b_load <- box_load(b_save$id) + expect_identical(b_load, "test_list") + expect_equal(test_ref, test_list) + + # clean up + box_delete_file(b_save$id) + +}) + From 689d16fd0051d87ee6732bebfb95336b33a0c380 Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Sat, 3 Feb 2024 11:42:22 -0700 Subject: [PATCH 2/6] refactor: use withr to manage tempfiles (#258) * bump version, add to NEWS * use withr::local_tempfile() in place of tempfile() * use function to clear box directory * refactor in favor of withr::local_tempfile() * use withr::local_tempdir() * update with withr "local" functions * fix bug introduced into box_save() * similar refactor for named files --- DESCRIPTION | 5 +++-- NEWS.md | 6 +++++- R/boxr__internal_misc.R | 6 ++---- R/boxr_read.R | 25 +++++++++++-------------- R/boxr_save_load.R | 22 ++++++++-------------- R/boxr_source.R | 2 +- R/boxr_upload_download.R | 5 +---- R/boxr_write.R | 4 +++- tests/testthat/test_02_clear_out.R | 2 +- tests/testthat/test_05_read_write.R | 8 ++++---- tests/testthat/test_99_tidy_up.R | 3 +-- 11 files changed, 40 insertions(+), 48 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 58d00340..a5d131c8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: boxr Type: Package Title: Interface for the 'Box.com API' -Version: 0.3.6.9006 +Version: 0.3.6.9007 Authors@R: c( person("Brendan", "Rocks", email = "foss@brendanrocks.com", role = c("aut")), @@ -52,7 +52,8 @@ Imports: tibble, lifecycle, jsonlite, - jose + jose, + withr Suggests: clipr (>= 0.3.0), conflicted, diff --git a/NEWS.md b/NEWS.md index c03cd48b..8aa1082f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,13 @@ # boxr 0.3.6 (development) -## fix bug in `box_save()`, setting default environment for evaluating dots (#255) +## Fixes + +* fix bug in `box_save()`, setting default environment for evaluating dots (#255) ## Internal +* refactor to use withr functions to handle temp files. (#183) + * activate tests for `box_save()`, `box_load()` (#255) * update documentation to reflect updates to rio package. (#242, @chainsawriot) diff --git a/R/boxr__internal_misc.R b/R/boxr__internal_misc.R index c06e1e6c..3f81e37a 100644 --- a/R/boxr__internal_misc.R +++ b/R/boxr__internal_misc.R @@ -294,7 +294,6 @@ create_test_dir <- function() { return() } - # A function to modify that directory structure modify_test_dir <- function() { # Delete a directory @@ -314,9 +313,8 @@ modify_test_dir <- function() { # A function to clear out a box.com directory clear_box_dir <- function(dir_id) { - dir.create("delete_me", showWarnings = FALSE) - box_push(dir_id, "delete_me", delete = TRUE) - unlink("delete_me", recursive = TRUE, force = TRUE) + tmp_dir <- withr::local_tempdir() + box_push(dir_id, tmp_dir, delete = TRUE) } diff --git a/R/boxr_read.R b/R/boxr_read.R index feff538c..fd0fdf31 100644 --- a/R/boxr_read.R +++ b/R/boxr_read.R @@ -54,13 +54,13 @@ box_read <- function(file_id, type = NULL, version_id = NULL, ...) { checkAuth() - temp_file <- tempfile() + temp_file <- withr::local_tempfile() # Make the request req <- boxGet(file_id, local_file = temp_file, version_id = version_id, version_no = version_no, download = TRUE) - # Extract the filename + # Extract the filename and extension filename <- gsub( 'filename=\"|\"', '', stringr::str_extract( @@ -68,15 +68,15 @@ box_read <- function(file_id, type = NULL, version_id = NULL, 'filename=\"(.*?)\"' ) ) + file_ext <- glue::glue(".{fs::path_ext(filename)}") - # Give the file it's original name back, so that you can preserve the file - # extension - new_name <- paste0(tempdir(), "/", filename) - file.rename(temp_file, new_name) + # Give the file its original file-extension back + temp_file_new <- withr::local_tempfile(fileext = file_ext) + file.rename(temp_file, temp_file_new) # If the file doesn't have an obvious file extension, try and do the right # thing by considering the mime-type from the request - if (!grepl("\\.[[:alnum:]]+$", new_name)) { + if (!grepl("\\.[[:alnum:]]+$", temp_file_new)) { message("Cannot read file extension from name.\n", "Inferring from mime-type...\n") mime <- req$headers$`content-type` @@ -88,13 +88,13 @@ box_read <- function(file_id, type = NULL, version_id = NULL, # Supply the file format to read_fun, if it seems to accept them (the # default, rio::import, does) if ("format" %in% names(formals(read_fun))) { - cont <- read_fun(new_name, format = ext, ...) + cont <- read_fun(temp_file_new, format = ext, ...) } else { # Otherwise, just try and read it with a user-supplied function - cont <- read_fun(new_name, ...) + cont <- read_fun(temp_file_new, ...) } } else { - cont <- read_fun(new_name, ...) + cont <- read_fun(temp_file_new, ...) } # this code comment is old (i think) and maybe worth revisiting was rio goes to CRAN (NCD 2019-11-01) @@ -106,11 +106,8 @@ box_read <- function(file_id, type = NULL, version_id = NULL, cont <- unclass(cont) } - # Delete the tempfile - unlink(temp_file, force = TRUE) - message( - "Remote file '", new_name, "' read into memory as an object of class ", + "Remote file '", filename, "' read into memory as an object of class ", paste(class(cont), collapse = ", "), "\n" ) diff --git a/R/boxr_save_load.R b/R/boxr_save_load.R index 051caa13..114004eb 100644 --- a/R/boxr_save_load.R +++ b/R/boxr_save_load.R @@ -31,14 +31,9 @@ box_save <- function(..., dir_id = box_getwd(), file_name = ".RData", description = NULL) { - # TODO: fs - temp_file <- normalizePath(file.path(tempdir(), file_name), mustWork = FALSE) - - # clean up after ourselves - # TODO: withr 2.3.0 may have a cleaner way to do this: local_tempfile() - # - see https://github.com/r-lib/usethis/issues/1217 - on.exit(fs::file_delete(temp_file)) - + # using local_tempdir() to preserve the filename + temp_file <- fs::path(withr::local_tempdir(), file_name) + save(..., envir = parent.frame(), file = temp_file) box_ul(dir_id, temp_file, description = description) @@ -63,10 +58,9 @@ box_save_image <- function(dir_id = box_getwd(), file_name = ".RData", } } - # TODO: fs - temp_file <- normalizePath(file.path(tempdir(), file_name), mustWork = FALSE) - on.exit(fs::file_delete(temp_file)) - + # using local_tempdir() to preserve the filename + temp_file <- fs::path(withr::local_tempdir(), file_name) + save.image(file = temp_file) box_ul(dir_id, temp_file, description = description) @@ -76,9 +70,9 @@ box_save_image <- function(dir_id = box_getwd(), file_name = ".RData", #' @export #' box_load <- function(file_id) { - temp_dir <- tempdir() + # using local_tempdir() to preserve the filename + temp_dir <- withr::local_tempdir() temp_file <- box_dl(file_id, overwrite = TRUE, local_dir = temp_dir) - on.exit(fs::file_delete(temp_file)) load(temp_file, envir = globalenv()) } diff --git a/R/boxr_source.R b/R/boxr_source.R index 428f7342..1ac044c1 100644 --- a/R/boxr_source.R +++ b/R/boxr_source.R @@ -19,7 +19,7 @@ #' @export #' box_source <- function(file_id, local = globalenv(), ...) { - temp_dir <- tempdir() + temp_dir <- withr::local_tempdir() temp_file <- box_dl(file_id, overwrite = TRUE, local_dir = temp_dir) source(temp_file, local = local, ...) } diff --git a/R/boxr_upload_download.R b/R/boxr_upload_download.R index f9a7de7a..07a64a37 100644 --- a/R/boxr_upload_download.R +++ b/R/boxr_upload_download.R @@ -83,7 +83,7 @@ box_dl <- function(file_id, local_dir = getwd(), overwrite = FALSE, stop("File already exists locally, and overwrite = FALSE") # Get a temp file - temp_file <- tempfile() + temp_file <- withr::local_tempfile() # Download to a tempfile with boxGet req <- boxGet(file_id = file_id, version_id = version_id, @@ -127,9 +127,6 @@ box_dl <- function(file_id, local_dir = getwd(), overwrite = FALSE, stop("Problem writing file to ", new_file, ".\n Check that directory is writable.") - # Remove the tempfile to free up space - file.remove(temp_file) - return(new_file) } diff --git a/R/boxr_write.R b/R/boxr_write.R index 5b6006a6..b4d446f7 100644 --- a/R/boxr_write.R +++ b/R/boxr_write.R @@ -68,7 +68,9 @@ box_write <- function(object, file_name, dir_id = box_getwd(), description = NUL } } - temp_file <- paste0(tempdir(), "/", file_name) + # using local_tempdir() to preserve the filename + temp_file <- fs::path(withr::local_tempdir(), file_name) + write_fun(object, temp_file, ...) box_ul(dir_id = dir_id, file = temp_file, description = description) } diff --git a/tests/testthat/test_02_clear_out.R b/tests/testthat/test_02_clear_out.R index 7b389ff7..42e7c0a1 100644 --- a/tests/testthat/test_02_clear_out.R +++ b/tests/testthat/test_02_clear_out.R @@ -20,7 +20,7 @@ test_that("Clear out the remote directory", { options(boxr.verbose = FALSE) # Tell boxr to sync the remote home directory with an empty local one # (i.e. delete everything) - b <- box_push(0, fs::path_temp("test_dir/dir_12/dir_121/dir_1211"), delete = TRUE) + boxr:::clear_box_dir(0) expect_length(box_ls(0), 0) diff --git a/tests/testthat/test_05_read_write.R b/tests/testthat/test_05_read_write.R index 92d8068c..44be226f 100644 --- a/tests/testthat/test_05_read_write.R +++ b/tests/testthat/test_05_read_write.R @@ -8,7 +8,7 @@ test_that("You can source a remote R script", { skip_if_no_token() # Write a little R script - tf <- paste(tempfile(), ".R") + tf <- withr::local_tempfile(fileext = ".R") writeLines("test_vector <- 1:10\n", tf) # Upload it, so that you can 'source it' back down @@ -26,7 +26,7 @@ test_that("You can write/read a remote .csv file", { skip_if_no_token() # Write a little .csv file - tf <- paste0(tempfile(), ".csv") + tf <- withr::local_tempfile(fileext = ".csv") # Note: It looks like although httr says it uses read.csv for the .csv files, # it doesn't obey the usual R behaviour of treating strings as factors by # default. So to get two objects that match, you'll need to make sure they're @@ -58,7 +58,7 @@ test_that("You can write/read a remote .tsv file", { skip_if_no_token() # Write a little .tsv file - tf <- paste0(tempfile(), ".tsv") + tf <- withr::local_tempfile(fileext = ".tsv") df <- data.frame(a = letters[1:5], b = 1:5, c = rnorm(5), stringsAsFactors = FALSE) @@ -88,7 +88,7 @@ test_that("You can write/read a remote .json file", { skip_if_no_token() # Write a little .json file - tf <- paste0(tempfile(), ".json") + tf <- withr::local_tempfile(fileext = ".json") df <- data.frame(a = letters[1:5], b = 1:5, c = rnorm(5), stringsAsFactors = FALSE) l <- list(a = 1:10, b = matrix(1, 3, 3), c = df) diff --git a/tests/testthat/test_99_tidy_up.R b/tests/testthat/test_99_tidy_up.R index 620ebdb3..7b0d6d7f 100644 --- a/tests/testthat/test_99_tidy_up.R +++ b/tests/testthat/test_99_tidy_up.R @@ -5,8 +5,7 @@ test_that("Box directory is emptied", { boxr:::skip_on_travis() skip_if_no_token() - # push empty local dir to top level on Box - b <- box_push(0, fs::path_temp("test_dir/dir_12/dir_121/dir_1211"), delete = TRUE) + boxr:::clear_box_dir(0) expect_equal(nrow(as.data.frame(box_ls(0))), 0) }) From 80c5ad2b9506eb2e1b6914406dea74aa3783b97b Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Sat, 3 Feb 2024 12:04:01 -0700 Subject: [PATCH 3/6] update actions (#267) --- .github/workflows/R-CMD-check.yaml | 9 +++++---- .github/workflows/pkgdown.yaml | 4 ++-- .github/workflows/test-coverage.yaml | 4 ++-- DESCRIPTION | 2 +- NEWS.md | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 2817a1e4..89e5b24e 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -25,13 +25,14 @@ jobs: - {os: ubuntu-latest, r: 'oldrel-1'} env: - BOXR_PASSWORD: ${{ secrets.BOXR_PASSWORD }} - BOXR_USE_TOKEN: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release' }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes - + # these are the only local adaptations needed + BOXR_PASSWORD: ${{ secrets.BOXR_PASSWORD }} + BOXR_USE_TOKEN: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release' }} + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index ed7650c7..a7276e85 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -22,7 +22,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 @@ -41,7 +41,7 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: JamesIves/github-pages-deploy-action@v4.5.0 with: clean: false branch: gh-pages diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 27d45283..960234cd 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -15,7 +15,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: @@ -44,7 +44,7 @@ jobs: - name: Upload test results if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage-test-failures path: ${{ runner.temp }}/package diff --git a/DESCRIPTION b/DESCRIPTION index a5d131c8..54d99d8e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: boxr Type: Package Title: Interface for the 'Box.com API' -Version: 0.3.6.9007 +Version: 0.3.6.9008 Authors@R: c( person("Brendan", "Rocks", email = "foss@brendanrocks.com", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index 8aa1082f..28981761 100644 --- a/NEWS.md +++ b/NEWS.md @@ -21,7 +21,7 @@ A patch is applied offering to move tokens from "old" locations. (#219 w/@danielruss) -* adds and updates GitHub Actions for testing and coverage. (#206, #247) +* adds and updates GitHub Actions for testing and coverage. (#206, #247, #256) # boxr 0.3.6 From 19e6cf74fcc9ec2198b32c35a2463eff524c7c1c Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Sat, 3 Feb 2024 12:33:26 -0700 Subject: [PATCH 4/6] switch from master to main (#268) --- DESCRIPTION | 2 +- NEWS.md | 2 ++ README.Rmd | 2 +- README.md | 75 ++++++++++++++++++++++++++--------------------------- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 54d99d8e..791f5cfd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: boxr Type: Package Title: Interface for the 'Box.com API' -Version: 0.3.6.9008 +Version: 0.3.6.9009 Authors@R: c( person("Brendan", "Rocks", email = "foss@brendanrocks.com", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index 28981761..dd308126 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ ## Internal +* default branch switched from `master` to `main`. (#252) + * refactor to use withr functions to handle temp files. (#183) * activate tests for `box_save()`, `box_load()` (#255) diff --git a/README.Rmd b/README.Rmd index a3a14cf8..c558618f 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,7 +19,7 @@ url <- function(x = "") { [![cran version](https://www.r-pkg.org/badges/version/boxr)](https://CRAN.R-project.org/package=boxr) -[![codecov](https://codecov.io/gh/r-box/boxr/branch/master/graph/badge.svg?token=eeGrWfmg4P)](https://codecov.io/gh/r-box/boxr) +[![codecov](https://codecov.io/gh/r-box/boxr/branch/main/graph/badge.svg?token=eeGrWfmg4P)](https://codecov.io/gh/r-box/boxr) ![monthly_downloads](https://cranlogs.r-pkg.org/badges/boxr) [![R-CMD-check](https://github.com/r-box/boxr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-box/boxr/actions/workflows/R-CMD-check.yaml) diff --git a/README.md b/README.md index e1ea592a..43b73b52 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ [![cran version](https://www.r-pkg.org/badges/version/boxr)](https://CRAN.R-project.org/package=boxr) -[![R-CMD-check](https://github.com/r-box/boxr/workflows/R-CMD-check/badge.svg)](https://github.com/r-box/boxr/actions) -[![codecov](https://codecov.io/gh/r-box/boxr/branch/master/graph/badge.svg?token=eeGrWfmg4P)](https://codecov.io/gh/r-box/boxr) +[![codecov](https://codecov.io/gh/r-box/boxr/branch/main/graph/badge.svg?token=eeGrWfmg4P)](https://codecov.io/gh/r-box/boxr) ![monthly_downloads](https://cranlogs.r-pkg.org/badges/boxr) +[![R-CMD-check](https://github.com/r-box/boxr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-box/boxr/actions/workflows/R-CMD-check.yaml) A lightweight, *opinionated*, high-level R interface to the box.com API, @@ -23,9 +23,9 @@ easier for you to integrate your Box account into your R workflow. ### Bug fixes -- Harmonizes the default location for tokens; `~` resolves to the home - directory for all platforms. A patch is applied offering to move - tokens from “old” locations. This bug appeared on Windows only. +- Harmonizes the default location for tokens; `~` resolves to the home + directory for all platforms. A patch is applied offering to move + tokens from “old” locations. This bug appeared on Windows only. All changes are detailed in the [NEWS](https://r-box.github.io/boxr/news/). @@ -52,8 +52,8 @@ The package-documentation website is created and maintained using [pkgdown](https://pkgdown.r-lib.org). The documentation website consists of: -- a [CRAN-version site](https://r-box.github.io/boxr/). -- a [development-version site](https://r-box.github.io/boxr/dev/). +- a [CRAN-version site](https://r-box.github.io/boxr/). +- a [development-version site](https://r-box.github.io/boxr/dev/). ## Usage @@ -88,44 +88,43 @@ Box-app](https://r-box.github.io/boxr/articles/boxr-app-interactive.html) ### Basic operations -- [Accessing Box - files](https://r-box.github.io/boxr/articles/boxr.html#files): - `box_ul()`, `box_dl()`, `box_version_history()`. -- [Accessing Box - directories](https://r-box.github.io/boxr/articles/boxr.html#directories): - `box_setwd()`, `box_getwd()`, `box_dir_create()`, `box_ls()`, - `box_search()`. -- [Directory-wide - operations](https://r-box.github.io/boxr/articles/boxr.html#directory-wide-operations): - `box_push()`, `box_fetch()`. +- [Accessing Box + files](https://r-box.github.io/boxr/articles/boxr.html#files): + `box_ul()`, `box_dl()`, `box_version_history()`. +- [Accessing Box + directories](https://r-box.github.io/boxr/articles/boxr.html#directories): + `box_setwd()`, `box_getwd()`, `box_dir_create()`, `box_ls()`, + `box_search()`. +- [Directory-wide + operations](https://r-box.github.io/boxr/articles/boxr.html#directory-wide-operations): + `box_push()`, `box_fetch()`. ### Advanced operations -- [Interactng with Box - files](https://r-box.github.io/boxr/articles/boxr.html#box-file-interaction): - `box_collab_create()`, `box_comment_create()`, - `box_add_description()`. -- [Using Box - trash](https://r-box.github.io/boxr/articles/boxr.html#using-box-trash): - `box_delete_file()`, `box_delete_folder()`, `box_restore_file()`, - `box_restore_folder()`. -- [Interacting with your R - session](https://r-box.github.io/boxr/articles/boxr.html#interacting-with-your-r-session): - `box_read()`, `box_write()`, `box_read_rds()`, `box_save_rds()`, - `box_save()`, `box_load()`, `box_browse()`. +- [Interactng with Box + files](https://r-box.github.io/boxr/articles/boxr.html#box-file-interaction): + `box_collab_create()`, `box_comment_create()`, + `box_add_description()`. +- [Using Box + trash](https://r-box.github.io/boxr/articles/boxr.html#using-box-trash): + `box_delete_file()`, `box_delete_folder()`, `box_restore_file()`, + `box_restore_folder()`. +- [Interacting with your R + session](https://r-box.github.io/boxr/articles/boxr.html#interacting-with-your-r-session): + `box_read()`, `box_write()`, `box_read_rds()`, `box_save_rds()`, + `box_save()`, `box_load()`, `box_browse()`. ## Alternatives Other ways to interact with a Box account include: -- The [Box desktop apps](https://www.box.com/resources/downloads). -- The *other* boxr, [written in - Ruby](https://github.com/cburnette/boxr). Its motivations are rather - different, and it covers 100% of the box.com API (e.g account - administration, etc.). -- Box themselves provide a [wide range of - SDKs](https://github.com/box), including [one for - Python](https://github.com/box/box-python-sdk). +- The [Box desktop apps](https://www.box.com/resources/downloads). +- The *other* boxr, [written in + Ruby](https://github.com/cburnette/boxr). Its motivations are rather + different, and it covers 100% of the box.com API (e.g account + administration, etc.). +- Box themselves provide a [wide range of SDKs](https://github.com/box), + including [one for Python](https://github.com/box/box-python-sdk). ## Contributing @@ -139,7 +138,7 @@ Conduct](https://r-box.github.io/boxr/CONDUCT.html). The MIT License (MIT) -Copyright (c) 2015-2022 boxr contributors +Copyright (c) 2015-2024 boxr contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From d75d99a1b761e6f46e6552336de98389b6b25ae3 Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Sat, 3 Feb 2024 13:06:50 -0700 Subject: [PATCH 5/6] refactor: update gargle functions (#265) * bump version, add to NEWS * replace with exported functions from gargle * use base warning() for now * use BOXR_KEY * update workflow --- .github/workflows/R-CMD-check.yaml | 2 +- DESCRIPTION | 2 +- NEWS.md | 2 ++ inst/secret/boxr-testing.json | Bin 2183 -> 2912 bytes tests/testthat/setup_auth.R | 23 ++++++++++++++++++++--- tests/testthat/test_01_oauth.R | 11 +++++++---- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 89e5b24e..424c7d06 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -28,7 +28,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes # these are the only local adaptations needed - BOXR_PASSWORD: ${{ secrets.BOXR_PASSWORD }} + BOXR_KEY: ${{ secrets.BOXR_KEY }} BOXR_USE_TOKEN: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release' }} steps: diff --git a/DESCRIPTION b/DESCRIPTION index 791f5cfd..9890d5c1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: boxr Type: Package Title: Interface for the 'Box.com API' -Version: 0.3.6.9009 +Version: 0.3.6.9010 Authors@R: c( person("Brendan", "Rocks", email = "foss@brendanrocks.com", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index dd308126..80caf651 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ ## Internal +* update superseded function-calls from gargle, used in testing. (#251) + * default branch switched from `master` to `main`. (#252) * refactor to use withr functions to handle temp files. (#183) diff --git a/inst/secret/boxr-testing.json b/inst/secret/boxr-testing.json index b3e88e83614242a240c243daafc21961f5d3486f..fcf17f82ae902e20e230b0bbd3162909cbf9831f 100644 GIT binary patch literal 2912 zcmWNTwXWp=3`F;bB88z$ZkU;xD9p_H`hBh4SRRkhKn0NkUc-#!fpNTX{v1M1Qup24 zgPATQ&{u*p1Rp>$o6uVSIi*FL6l_+pj7iT>UyFIvv~x^IFF{=Jb@DecH74eu9SkAG z4ovQR){f>EK9O}7cZmaBtH;aM74x&|1m&`GZrh-c7T;fswYqv_vUgydeJ4QXK?(Y z_M7;)Cap%Of>Rtx(qh{tU>4*w zj%SeZs_zUeqQ>laRJz8=eJ>eL+FX-7Xi8Y5?l6O)UAW1gcPaKPWGOhl$xFcC6 zbV%qM+stdIN#kKoUZ9K%&r>aKTg=P^u?D)ZYqx6qY{&UGZhi-#^+Onp31IL9`v#If zIm))l|2^QxS;OS41c~NuzM7T+gNG>uaPtf0r@7O6od69!fhuf-Mu3WQ6gd!FY_wOr zIHu7;OdeA9z2=2nZ9N7OM*9)M|Trs5;N4VZl=D61z+~MMxCP>rvvZ&svj5xjBXKKQ$Gz{*cED&2~ga<6|@JgyJbPzwOtB;|q_ZOar z&hv>(UUF=o!j5u+lO;scCo>#ukNY*p?^v{*xn2+Ps)?Cr69)|m;MGZeJa@G}*r5IV zHGV1rGs|(U;3eSF6IWH=#iBksBXI_S>0#P#udGzIva!QO`e((6_P=btBL|GyX}egg z^($-lpVj3=z=K4`YI#?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Q$6;FErb$Rz;n8I{1j&~{-9G%CPIsjO40mDEPN4`7W$izbDv%$D_D%#PK> zU&PiC)dNqyhi;jRI7;fk*S=ZG zFgL}$@*|jS2i1G(km2{mmw8Jaqh*(HQX)S4S~B_54EvA-USkNx(FH#(DcT}Qwx^*> J4` 50) +# text <- gargle::secret_decrypt_json(path_secret, env_secret) +# expect_true(inherits("x", "character")) +# expect_true(nchar(text) > 50) # }) From 1fdeb53a439443db5ce5990947deb13e903e1d12 Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Sat, 3 Feb 2024 13:17:23 -0700 Subject: [PATCH 6/6] remove unsued function (#260) --- DESCRIPTION | 3 +-- NEWS.md | 2 ++ R/boxr__internal_misc.R | 11 ----------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9890d5c1..9180056c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: boxr Type: Package Title: Interface for the 'Box.com API' -Version: 0.3.6.9010 +Version: 0.3.6.9011 Authors@R: c( person("Brendan", "Rocks", email = "foss@brendanrocks.com", role = c("aut")), @@ -40,7 +40,6 @@ Imports: fs, glue, httr (>= 1.1.0), - httpuv, magrittr, mime, purrr, diff --git a/NEWS.md b/NEWS.md index 80caf651..433cd5b3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ ## Internal +* remove unused internal function, removing dependency on httpuv package. (#259) + * update superseded function-calls from gargle, used in testing. (#251) * default branch switched from `master` to `main`. (#252) diff --git a/R/boxr__internal_misc.R b/R/boxr__internal_misc.R index 3f81e37a..19d563e4 100644 --- a/R/boxr__internal_misc.R +++ b/R/boxr__internal_misc.R @@ -353,17 +353,6 @@ modify_remote_dir <- function() }) - -#' @keywords internal -forRCMDCheck <- function(cran = "http://cran.r-project.org/") { - if (FALSE) { - httpuv::encodeURI(cran) - mime::guess_type(cran) - rio::import(cran) - } -} - - # API --------------------------------------------------------------------- #' Common Box API client-errors