Skip to content

Commit

Permalink
version 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
idmn authored and cran-robot committed May 8, 2024
1 parent de14beb commit 960595c
Show file tree
Hide file tree
Showing 20 changed files with 212 additions and 110 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cloudfs
Title: Streamlined Interface to Interact with Cloud Storage Platforms
Version: 0.1.2
Version: 0.1.3
Authors@R: c(
person("Iaroslav", "Domin", email = "iaroslav@gradientmetrics.com", role = c("aut", "cre")),
person("Stefan", "Musch", email = "stefan@gradientmetrics.com", role = c("aut")),
Expand All @@ -14,7 +14,7 @@ Description: A unified interface for simplifying cloud storage interactions,
(<https://aws.amazon.com/s3/>).
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Imports: aws.s3, googledrive, desc, dplyr, cli, utils, rlang, glue,
httr
Suggests: googlesheets4, haven, jsonlite, knitr, readr, readxl,
Expand All @@ -24,12 +24,12 @@ Config/testthat/edition: 3
URL: https://g6t.github.io/cloudfs/, https://github.com/g6t/cloudfs
BugReports: https://github.com/g6t/cloudfs/issues
NeedsCompilation: no
Packaged: 2023-10-18 01:19:30 UTC; iaroslav@gradientmetrics.com
Packaged: 2024-05-07 16:24:23 UTC; iaroslav@gradientmetrics.com
Author: Iaroslav Domin [aut, cre],
Stefan Musch [aut],
Michal Czyz [aut],
Emmanuel Ugochukwu [aut],
Gradient Metrics [cph, fnd]
Maintainer: Iaroslav Domin <iaroslav@gradientmetrics.com>
Repository: CRAN
Date/Publication: 2023-10-18 15:30:08 UTC
Date/Publication: 2024-05-07 16:40:03 UTC
35 changes: 19 additions & 16 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
ac20d98cf69e94cfc6690a1155526cd7 *DESCRIPTION
2d0e9b34a00ad98eff6970832d0a0f04 *DESCRIPTION
bafe18519f77a78b13345643dbbc5f10 *LICENSE
6349e2a6f0a6c646d914dde908fd126a *NAMESPACE
d20e2352f03be5ff96e716819c33a3a9 *NEWS.md
2c52a4a0101242613ffcbae9e41cb034 *R/cli.R
0e975edeeb97ae5ffd8547df512feec9 *R/cloud_local.R
4c3e9af490ee75430510bbb1e7a7e2a1 *R/common.R
e6cea1493fdb892a8f1b93932dd65baa *NEWS.md
706802861557370d75d1f8f958499738 *R/cli.R
7975b7afb327d3112e10ad2058db52ac *R/cloud_local.R
0eb1d09e7940b904cf910a8629610f6a *R/common.R
fc49d4383cfc10b0ff0d6c39a5dbc082 *R/doc.R
f94be54e3cf2f0ceba427ec871c9b6f2 *R/drive_setup.R
eb58ceddc2810d5b7d0d4639cb9ad256 *R/drive_show.R
3da229479095b73b626759d7f5cf671d *R/drive_transfer.R
0b3232b46cc2df75e18190dec9d3f295 *R/drive_transfer.R
21e2cbe48975ca56fc627f1243bcbeff *R/drive_transfer_bulk.R
04c7e9e1801e150b92649ac77b3c1782 *R/drive_utils.R
a188881c20d8d952ce5a061d40444236 *R/drive_utils.R
308ff61c7cf6607da4c0e76c624969dc *R/package.R
e06c9710baf93f52a9e660afb4b97bfc *R/read_write.R
dca3a90b374b3e20c4c46ba8a2ecfbd4 *R/read_write.R
b54d6120bbcec00f675c061263843ac0 *R/s3_setup.R
97bdc1093d7f4ae6d8af997402d1f32b *R/s3_show.R
6c93f673bd8f1c5e0155f4010060dd50 *R/s3_transfer.R
61726ef67fa8432b00b48328b1bdb902 *R/s3_transfer.R
ced25d41860158030ce6391cf527d2f1 *R/s3_transfer_bulk.R
11bda0eba28b75a8c5c42d0ae5dfad8e *R/str_utils.R
d89d9ca73bb20919b50b585880672bf1 *R/talk.R
2ab62ddc6a399cb00ab0e31d930ef785 *R/utils.R
6a756300d524f71789374dbc9d18685b *README.md
ae94d1d32fd17584b2220cb8ba8a43a2 *README.md
8c2433c156fb4e1c4c91f02443239e99 *build/vignette.rds
82b70636e9eb2631e99b573ccf1cc2a8 *inst/doc/cloudfs.R
73eeaedff3747aee079f543b66cfe788 *inst/doc/cloudfs.Rmd
fc9d11f6ff10f46a7724ac46571a3661 *inst/doc/cloudfs.html
d4cfd7c3679c4c4e2503c610591d5ee8 *inst/doc/cloudfs.html
bc3d32ba48b3451774bf49fa676caf0a *man/check_args.Rd
bbfebb7516c46cacb3a4259b8d3976aa *man/check_bool.Rd
5fa67a399bcae8c4b12d93c06f9aad5f *man/check_class.Rd
c87c07aed45a8d4bf069eb86bfc0fc0e *man/check_length.Rd
6531e43bf0a5af9433d6b9191faa9aa2 *man/check_null_cond.Rd
49751374c2f0ede4eeaf9deb57e6c188 *man/check_path.Rd
79f8189f6d4642bb86b9473a8c8b060f *man/check_scalar.Rd
21d88cfc8ac0b086c109dbe7b65ef266 *man/cli_yeah.Rd
6f2bd51c6adcb828e3a1b5474595a244 *man/cloud_drive_attach.Rd
Expand All @@ -43,8 +45,8 @@ bde1789f04ceabc58fd9f39439691cab *man/cloud_drive_read_bulk.Rd
b8fd49e38fabdd2a225adcca12c2d5b3 *man/cloud_drive_spreadsheet_autofit.Rd
1ca97d7263c17b496a1a81bd33209d69 *man/cloud_drive_upload.Rd
c854245d54b20aa84ad4e617f0568348 *man/cloud_drive_upload_bulk.Rd
37e128691a86538ac6c22eb2d5525179 *man/cloud_drive_write.Rd
908852a11c815bdbcac8057ad20b1aac *man/cloud_drive_write_bulk.Rd
37f62135d291c07fad9b961914666109 *man/cloud_drive_write.Rd
f0b2d7ccb2a4586bc3b5d1944cf9ad0a *man/cloud_drive_write_bulk.Rd
672247b0a0addb2f52dbca7d7acfd91a *man/cloud_get_roots.Rd
f60ebc26dc3d8b97027d976dd15edc65 *man/cloud_guess_read_fun.Rd
887edf929df9eeb8c11d0afab3d70965 *man/cloud_guess_write_fun.Rd
Expand All @@ -63,10 +65,11 @@ b93f91297fc3695c49c13f0f9510d0c5 *man/cloud_prep_ls.Rd
f77b30846875f85fcb0cc33d501d6a4c *man/cloud_s3_read_bulk.Rd
fe65ec23430347aef9e543200c739314 *man/cloud_s3_upload.Rd
7e36a73dda8f01cf493dfce5fce33a1a *man/cloud_s3_upload_bulk.Rd
b4b28536a2af6c67c0f1565562410797 *man/cloud_s3_write.Rd
98221da98d2b5959d47688bd2e7c1a63 *man/cloud_s3_write_bulk.Rd
7a2b341c161bb0cb6b984f2b5ad5d972 *man/cloud_validate_file_path.Rd
38280e663ef4175255bcddba5d4bcf83 *man/cloud_s3_write.Rd
7d7ff79f61c126c84227dc39533a3538 *man/cloud_s3_write_bulk.Rd
2588e844e9589f26d7c8fc0bd773650a *man/cloudfs-package.Rd
680b10ad8ff9213bb0e18c5459dafe6d *man/doc_file.Rd
0da27d8652f8704bfb66c21349498d24 *man/doc_local.Rd
97d0742af647ccca8b5da48a481a54fd *man/figures/cloudfs_logo.png
e15b884dd351db69497e4d3b5e7006c6 *man/figures/logo.png
5600765d4e008143338fd7b97c9a915d *man/figures/logo.svg
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# cloudfs 0.1.3

* Updated `cloud_object_ls()` to support paths containing spaces.
* Improved various sections of the documentation.
* Enabled multipart upload for S3 writing and uploading functions, with the
default part size of 100 MB.

# cloudfs 0.1.2

* Initial version.
32 changes: 32 additions & 0 deletions R/cli.R
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,35 @@ check_bool <- function(x, alt_null = FALSE, add_msg = NULL) {
))
}
}


#' @title Validate a path
#'
#' @description Makes sure that a path passed to a cloud function is in the
#' right format.
#'
#' @param path A path relative to the project folder root. Can contain only
#' letters, digits, '-', '_', '.', spaces and '/' symbols.
#' @param error if `TRUE` (default), throws an error if `file` is not a valid
#' file path.
#'
#' @return Either `TRUE` or `FALSE` if `error` is `FALSE`. Either `TRUE` or
#' an error if `error` is `TRUE`.
#'
#' @keywords internal
check_path <- function(path, error = TRUE) {
res <- grepl("^([A-Za-z]|[0-9]|-|_|\\.| |/)+$", path)
if (error) {
if (path == "") cli::cli_abort("A valid path must not be empty.")
if (!res) cli_abort(c(
"Path '{path}' is not valid",
"A valid path must consist of:",
"*" = "uppercase/lowercase letters",
"*" = "digits",
"*" = "'/' symbols to separate directories in the path",
"*" = "'_', '-', '.' symbols or spaces"
))
}
res
}

14 changes: 2 additions & 12 deletions R/cloud_local.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,12 @@ cloud_object_ls <- function(x, path, extension, prefix = "", suffix = "") {
check_string(extension)
check_string(prefix)
check_string(suffix)

if (!grepl("^([A-Za-z]|[0-9]|-|_|\\.|/)+$", path)) {
cli::cli_abort(c(
"Directory path {.path {path}} is not valid. A valid directory path may \\
consist of:",
"*" = "uppercase/lowercase letters",
"*" = "digits",
"*" = "'/' symbols to describe its location inside project's folder",
"*" = "'_', '-', '.' symbols or spaces."
))
}
check_path(path)

if (!grepl("^([A-Za-z]|[0-9])+$", extension)) {
cli::cli_abort(c(
"{.arg extension} {.val {extension}} is not valid. A valid extension path \\
may consist of:",
must consist of:",
"*" = "uppercase/lowercase letters",
"*" = "digits"
))
Expand Down
32 changes: 0 additions & 32 deletions R/common.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,6 @@ proj_desc_get <- function(key, project = ".") {
unname(value)
}

#' @title Validate file path for cloud functions
#'
#' @description Makes sure that file path passed to a cloud function is in the
#' right format.
#'
#' @param file Path to a file relative to project folder root. Can contain only
#' letters, digits, '-', '_', '.', spaces and '/' symbols.
#' @param error if `TRUE` (default), throws an error if `file` is not a valid
#' file path.
#'
#' @return Either `TRUE` or `FALSE` if `error` is `FALSE`. Either `TRUE` or
#' an error if `error` is `TRUE`.
#'
#' @keywords internal
cloud_validate_file_path <- function(file, error = TRUE) {
check_string(file)
res <- grepl("^([A-Za-z]|[0-9]|-|_|\\.| |/)+$", file)
if (error) {
if (file == "") cli::cli_abort("A valid file name should not be empty.")
if (!res) cli_abort(c(
"File name '{file}' is not valid",
"A valid file name may consist of:",
"*" = "uppercase/lowercase letters",
"*" = "digits",
"*" = "spaces",
"*" = "'/' symbols to describe its location inside project's folder",
"*" = "'_', '-', '.' symbols"
))
}
res
}

#' @title Validate file names
#'
#' @description Given a character vector of filenames checks that all names pass
Expand Down
28 changes: 28 additions & 0 deletions R/doc.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#' @title Package-wide description of `file` parameter
#' @description A dummy function to be referred by `@inheritParams` for a
#' parameter documentation.
#'
#' @param file Path to a file relative to project folder root. Can contain only
#' letters, digits, '-', '_', '.', spaces and '/' symbols.
#'
#' @keywords internal
doc_file <- function(file) {}



#' @title Package-wide description of `local` parameter
#' @description A dummy function to be referred by `@inheritParams` for a
#' parameter documentation.
#'
#' @param local Logical, defaulting to `FALSE`. If `TRUE`, the function will
#' also create a local copy of the file at the specified path. Note that some
#' writing functions might not overwrite existing files unless explicitly
#' allowed. Typically, such functions have a parameter (often named
#' `overwrite`) to control this behavior. Check the documentation of the
#' writing function used to determine the exact parameter name and pass it
#' through the `...` argument if necessary. Alternatively, you can define an
#' anonymous function for `fun` that calls a writing function with the
#' overwriting option enabled.
#'
#' @keywords internal
doc_local <- function(local) {}
19 changes: 9 additions & 10 deletions R/drive_transfer.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @description Uploads a local file from the project's directory to its
#' corresponding location within the project's Google Drive root folder.
#'
#' @inheritParams cloud_validate_file_path
#' @inheritParams doc_file
#' @inheritParams cloud_drive_ls
#'
#' @inherit cloud_drive_find_path details
Expand All @@ -25,7 +25,7 @@
#'
#' @export
cloud_drive_upload <- function(file, root = NULL) {
cloud_validate_file_path(file)
check_path(file)

if (!file.exists(file)) {
cli::cli_abort("File {.path {file}} does not exist.")
Expand All @@ -51,7 +51,7 @@ cloud_drive_upload <- function(file, root = NULL) {
#' saves it to the local project folder, maintaining the original folder
#' structure.
#'
#' @inheritParams cloud_validate_file_path
#' @inheritParams doc_file
#' @inheritParams cloud_drive_ls
#'
#' @inherit cloud_drive_find_path details
Expand All @@ -68,7 +68,7 @@ cloud_drive_upload <- function(file, root = NULL) {
#'
#' @export
cloud_drive_download <- function(file, root = NULL) {
cloud_validate_file_path(file)
check_path(file)

check_string(root, alt_null = TRUE)
if (is.null(root)) root <- cloud_drive_get_root()
Expand All @@ -95,15 +95,14 @@ cloud_drive_download <- function(file, root = NULL) {
#' function will infer the appropriate writing method based on the file's
#' extension.
#'
#' @inheritParams cloud_validate_file_path
#' @inheritParams doc_file
#' @inheritParams cloud_drive_ls
#' @inheritParams doc_local
#'
#' @param x An R object to be written to Google Drive.
#' @param fun A custom writing function. If `NULL` (default), the appropriate
#' writing function will be inferred based on the file's extension.
#' @param ... Additional arguments to pass to the writing function `fun`.
#' @param local Logical. If `TRUE`, a local copy of the file will also be
#' created at the specified path. Default is `FALSE`.
#'
#' @inheritSection cloud_guess_write_fun Default writing functions
#'
Expand All @@ -121,7 +120,7 @@ cloud_drive_download <- function(file, root = NULL) {
#' @export
cloud_drive_write <- function(x, file, fun = NULL, ..., local = FALSE,
root = NULL) {
cloud_validate_file_path(file)
check_path(file)
check_bool(local)

if (is.null(fun)) {
Expand Down Expand Up @@ -162,7 +161,7 @@ cloud_drive_write <- function(x, file, fun = NULL, ..., local = FALSE,
#' reading function based on the file's extension. However, you can specify a
#' custom reading function if necessary.
#'
#' @inheritParams cloud_validate_file_path
#' @inheritParams doc_file
#' @inheritParams cloud_drive_ls
#'
#' @param fun A custom reading function. If `NULL` (default), the appropriate
Expand All @@ -185,7 +184,7 @@ cloud_drive_write <- function(x, file, fun = NULL, ..., local = FALSE,
#'
#' @export
cloud_drive_read <- function(file, fun = NULL, ..., root = NULL) {
cloud_validate_file_path(file)
check_path(file)
if (is.null(fun)) {
fun <- cloud_guess_read_fun(file)
}
Expand Down
6 changes: 3 additions & 3 deletions R/drive_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cloud_drive_download_by_id <- function(file, path, overwrite = FALSE) {
#'
#' @noRd
cloud_drive_guess_type <- function(file) {
cloud_validate_file_path(file)
check_path(file)
ext <- tolower(tools::file_ext(file))
switch (
ext,
Expand Down Expand Up @@ -112,7 +112,7 @@ cloud_drive_put <- function(media, path) {
#' @description Finds the spreadsheet by path relative to a project root.
#' Applies [googlesheets4::range_autofit()] to each sheet.
#'
#' @inheritParams cloud_validate_file_path
#' @inheritParams doc_file
#' @inheritParams cloud_drive_ls
#'
#' @return The file ID of the resized Google spreadsheet as an invisible result.
Expand All @@ -123,7 +123,7 @@ cloud_drive_put <- function(media, path) {
#'
#' @export
cloud_drive_spreadsheet_autofit <- function(file, root = NULL) {
cloud_validate_file_path(file)
check_path(file)
check_string(root, alt_null = TRUE)

if (is.null(root)) root <- cloud_drive_get_root()
Expand Down
8 changes: 4 additions & 4 deletions R/read_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @description Take a look at the switch call. That's basically it. Returns an
#' appropriate function or throws an error if wasn't able to find one.
#'
#' @inheritParams cloud_validate_file_path
#' @inheritParams doc_file
#'
#' @section Default writing functions:
#'
Expand All @@ -21,7 +21,7 @@
#'
#' @keywords internal
cloud_guess_write_fun <- function(file) {
cloud_validate_file_path(file)
check_path(file)
ext <- tolower(tools::file_ext(file))
if (ext == "") stop("Missing file extension, unable to guess writing function.")
fun <- switch (
Expand All @@ -47,7 +47,7 @@ cloud_guess_write_fun <- function(file) {
#' @description Take a look at the switch call. That's basically it. Returns an
#' appropriate function or throws an error if wasn't able to find one.
#'
#' @inheritParams cloud_validate_file_path
#' @inheritParams doc_file
#'
#' @section Default reading functions:
#'
Expand All @@ -64,7 +64,7 @@ cloud_guess_write_fun <- function(file) {
#'
#' @keywords internal
cloud_guess_read_fun <- function(file) {
cloud_validate_file_path(file)
check_path(file)
ext <- tolower(tools::file_ext(file))
if (ext == "") stop("Missing file extension, unable to guess reading function.")
fun <- switch (
Expand Down

0 comments on commit 960595c

Please sign in to comment.