Skip to content

Commit

Permalink
fix conflict, bump version
Browse files Browse the repository at this point in the history
Merge commit '1fdeb53a439443db5ce5990947deb13e903e1d12'

#Conflicts:
#	DESCRIPTION
#	NEWS.md
#	R/boxr_read.R
  • Loading branch information
ijlyttle committed Feb 3, 2024
2 parents 12d4a48 + 1fdeb53 commit 726a935
Show file tree
Hide file tree
Showing 20 changed files with 152 additions and 159 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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_KEY: ${{ secrets.BOXR_KEY }}
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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: boxr
Type: Package
Title: Interface for the 'Box.com API'
Version: 0.3.6.9006
Version: 0.3.6.9012
Authors@R: c(
person("Brendan", "Rocks", email = "foss@brendanrocks.com",
role = c("aut")),
Expand Down Expand Up @@ -40,7 +40,6 @@ Imports:
fs,
glue,
httr (>= 1.1.0),
httpuv,
magrittr,
mime,
purrr,
Expand All @@ -52,7 +51,8 @@ Imports:
tibble,
lifecycle,
jsonlite,
jose
jose,
withr
Suggests:
clipr (>= 0.3.0),
conflicted,
Expand Down
16 changes: 15 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# boxr 0.3.6 (development)

## Fixes

* fix bug in `box_save()`, setting default environment for evaluating dots (#255)

## Internal

* update minimum version of rio package to reflect newer treatment of JSON files. (#261)

* 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)

* 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)

* update maintainer's email address. (#248)
Expand All @@ -15,7 +29,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

Expand Down
17 changes: 2 additions & 15 deletions R/boxr__internal_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ create_test_dir <- function() {
return()
}


# A function to modify that directory structure
modify_test_dir <- function() {
# Delete a directory
Expand All @@ -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)
}


Expand Down Expand Up @@ -355,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
Expand Down
25 changes: 11 additions & 14 deletions R/boxr_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,29 @@ 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(
req$headers["content-disposition"][[1]],
'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`
Expand All @@ -88,20 +88,17 @@ 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, ...)
}

# 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"
)
Expand Down
24 changes: 9 additions & 15 deletions R/boxr_save_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,10 @@
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))

save(..., file = 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)
}
Expand All @@ -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)
Expand All @@ -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())
}
2 changes: 1 addition & 1 deletion R/boxr_source.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
}
5 changes: 1 addition & 4 deletions R/boxr_upload_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 3 additions & 1 deletion R/boxr_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ url <- function(x = "") {

<!-- badges: start -->
[![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)
<!-- badges: end -->
Expand Down
Loading

0 comments on commit 726a935

Please sign in to comment.