Skip to content

Commit

Permalink
add to more exported functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ijlyttle committed Jan 7, 2024
1 parent 7c37398 commit 79002c3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/boxr__internal_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ as_box_id <- function(x, arg = rlang::caller_arg(x),

# a box_id is a string that contains only digits

# do we need this?
# some defaults are NULL; we just pass these through
if (is.null(x)) {
return(NULL)

Check warning on line 30 in R/boxr__internal_misc.R

View check run for this annotation

Codecov / codecov/patch

R/boxr__internal_misc.R#L30

Added line #L30 was not covered by tests
}
Expand Down
4 changes: 4 additions & 0 deletions R/boxr_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ boxDirCreate <- function(dir_name, parent_dir_id = box_getwd()) {
#' @export
#'
box_browse <- function(dir_id = NULL, file_id = NULL) {

dir_id <- as_box_id(dir_id)
file_id <- as_box_id(file_id)

Check warning on line 311 in R/boxr_misc.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_misc.R#L310-L311

Added lines #L310 - L311 were not covered by tests

item <- collab_item_helper(dir_id, file_id)
utils::browseURL(glue::glue("https://app.box.com/{item$type}/{item$id}"))
}
6 changes: 6 additions & 0 deletions R/boxr_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ box_read <- function(file_id, type = NULL, version_id = NULL,
version_no = NULL, read_fun = rio::import,
...) {
checkAuth()
file_id <- as_box_id(file_id)

Check warning on line 56 in R/boxr_read.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_read.R#L56

Added line #L56 was not covered by tests

temp_file <- tempfile()

Expand Down Expand Up @@ -122,33 +123,38 @@ box_read <- function(file_id, type = NULL, version_id = NULL,
#' @rdname box_read
#' @export
box_read_csv <- function(file_id, ...) {
file_id <- as_box_id(file_id)

Check warning on line 126 in R/boxr_read.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_read.R#L126

Added line #L126 was not covered by tests
box_read(file_id, format = "csv", ...)
}


#' @rdname box_read
#' @export
box_read_tsv <- function(file_id, ...) {
file_id <- as_box_id(file_id)

Check warning on line 134 in R/boxr_read.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_read.R#L134

Added line #L134 was not covered by tests
box_read(file_id, format = "tsv", ...)
}


#' @rdname box_read
#' @export
box_read_json <- function(file_id, ...) {
file_id <- as_box_id(file_id)

Check warning on line 142 in R/boxr_read.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_read.R#L142

Added line #L142 was not covered by tests
box_read(file_id, read_fun = jsonlite::fromJSON, ...)
}


#' @rdname box_read
#' @export
box_read_excel <- function(file_id, ...) {
file_id <- as_box_id(file_id)

Check warning on line 150 in R/boxr_read.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_read.R#L150

Added line #L150 was not covered by tests
box_read(file_id, format = "excel", ...)
}

#' @rdname box_read
#' @export
box_read_rds <- function(file_id, ...) {
file_id <- as_box_id(file_id)

Check warning on line 157 in R/boxr_read.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_read.R#L157

Added line #L157 was not covered by tests
box_read(file_id, read_fun = readRDS, ...)
}

7 changes: 6 additions & 1 deletion R/boxr_save_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ box_save <- function(..., dir_id = box_getwd(), file_name = ".RData",
box_save_image <- function(dir_id = box_getwd(), file_name = ".RData",
description = NULL, filename) {

dir_id <- as_box_id(dir_id)

Check warning on line 53 in R/boxr_save_load.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_save_load.R#L53

Added line #L53 was not covered by tests

# TODO: in future version, remove argument
if (!missing(filename)) {

Expand All @@ -75,7 +77,10 @@ box_save_image <- function(dir_id = box_getwd(), file_name = ".RData",
#' @rdname box_save
#' @export
#'
box_load <- function(file_id) {
box_load <- function(file_id) {

file_id <- as_box_id(file_id)

Check warning on line 82 in R/boxr_save_load.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_save_load.R#L82

Added line #L82 was not covered by tests

temp_dir <- tempdir()
temp_file <- box_dl(file_id, overwrite = TRUE, local_dir = temp_dir)
on.exit(fs::file_delete(temp_file))
Expand Down
4 changes: 4 additions & 0 deletions R/boxr_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
box_write <- function(object, file_name, dir_id = box_getwd(), description = NULL,
write_fun = rio::export, x, filename, ...) {

dir_id <- as_box_id(dir_id)

Check warning on line 46 in R/boxr_write.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_write.R#L46

Added line #L46 was not covered by tests

# TODO: in future version, remove argument
if (!missing(filename)) {

Expand Down Expand Up @@ -78,6 +80,8 @@ box_write <- function(object, file_name, dir_id = box_getwd(), description = NUL
box_save_rds <- function(object, dir_id = box_getwd(), file_name = ".RDS",
description = NULL) {

dir_id <- as_box_id(dir_id)

Check warning on line 83 in R/boxr_write.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_write.R#L83

Added line #L83 was not covered by tests

temp_file <- fs::path_temp(file_name)
on.exit(fs::file_delete(temp_file))

Expand Down

0 comments on commit 79002c3

Please sign in to comment.