Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add board_deparse for board_url() #774

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ S3method(board_deparse,pins_board_gcs)
S3method(board_deparse,pins_board_kaggle_competition)
S3method(board_deparse,pins_board_kaggle_dataset)
S3method(board_deparse,pins_board_s3)
S3method(board_deparse,pins_board_url)
S3method(board_desc,default)
S3method(board_desc,pins_board_folder)
S3method(board_pin_create,pins_board)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Fixed how dots are checked in `pin_write()` to make user-facing messages more
clear (#770).

* Added `board_deparse` for `board_url()` (#774).

# pins 1.2.1

* New environment variable `PINS_CACHE_DIR` controls the location of the
Expand Down
7 changes: 7 additions & 0 deletions R/board_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ pin_fetch.pins_board_url <- function(board, name, version = NULL, ...) {
meta
}

#' @rdname board_deparse
#' @export
board_deparse.pins_board_url <- function(board, ...) {
urls <- check_board_deparse(board, "urls")
expr(board_url(!!urls))
}

# Unsupported features ----------------------------------------------------

#' @export
Expand Down
6 changes: 5 additions & 1 deletion man/board_deparse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions tests/testthat/_snaps/board_url.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# provides key methods

Code
board_deparse(board)
Output
board_url(c(rds = "https://raw.githubusercontent.com/rstudio/pins-r/master/tests/testthat/pin-rds/"))

# raw pins can only be downloaded

Pin does not declare file type so can't be automatically read
Expand Down Expand Up @@ -36,11 +43,6 @@
Condition
Error in `pin_version_delete()`:
! `board_url()` is read only
Code
board %>% board_deparse()
Condition
Error in `board_deparse()`:
! This board doesn't support deparsing
Code
pin(1:5, name = "x", board = board)
Condition
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-board_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ test_that("provides key methods", {
board %>%
pin_read("rds") %>%
expect_equal(data.frame(x = 1:10))

expect_snapshot(board_deparse(board))
})

test_that("absent pins handled consistently", {
Expand Down Expand Up @@ -158,7 +160,6 @@ test_that("useful errors for unsupported methods", {
board %>% pin_meta("x", version = "x")
board %>% pin_versions("x")
board %>% pin_version_delete("x")
board %>% board_deparse()
pin(1:5, name = "x", board = board)
pin_get(name = "x", board = board)
})
Expand Down
Loading