Skip to content

Commit

Permalink
Add board_deparse for board_url() (#774)
Browse files Browse the repository at this point in the history
* Add `board_deparse()` for `board_url()`

* Document and update tests

* Update NEWS
  • Loading branch information
juliasilge authored Aug 30, 2023
1 parent a296324 commit 1d15a31
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
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

0 comments on commit 1d15a31

Please sign in to comment.