From 7c53b2163abe5cee415b81ff63de6670396fea39 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 30 Aug 2023 12:23:38 -0600 Subject: [PATCH 1/3] Add `board_deparse()` for `board_url()` --- R/board_url.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/board_url.R b/R/board_url.R index 3cba6a04..295c9a86 100644 --- a/R/board_url.R +++ b/R/board_url.R @@ -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 From 4a60f0ce780229b3df78133059cf1b539e0b19a5 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 30 Aug 2023 12:24:02 -0600 Subject: [PATCH 2/3] Document and update tests --- NAMESPACE | 1 + man/board_deparse.Rd | 6 +++++- tests/testthat/_snaps/board_url.md | 12 +++++++----- tests/testthat/test-board_url.R | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index a9763052..9ed69696 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/man/board_deparse.Rd b/man/board_deparse.Rd index 4d4de2ab..133ab419 100644 --- a/man/board_deparse.Rd +++ b/man/board_deparse.Rd @@ -1,6 +1,7 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/board.R, R/board_azure.R, R/board_connect.R, -% R/board_folder.R, R/board_gcs.R, R/board_kaggle.R, R/board_s3.R +% R/board_folder.R, R/board_gcs.R, R/board_kaggle.R, R/board_s3.R, +% R/board_url.R \name{board_deparse} \alias{board_deparse} \alias{board_deparse.pins_board_azure} @@ -10,6 +11,7 @@ \alias{board_deparse.pins_board_kaggle_competition} \alias{board_deparse.pins_board_kaggle_dataset} \alias{board_deparse.pins_board_s3} +\alias{board_deparse.pins_board_url} \title{Deparse a board object} \usage{ board_deparse(board, ...) @@ -27,6 +29,8 @@ board_deparse(board, ...) \method{board_deparse}{pins_board_kaggle_dataset}(board, ...) \method{board_deparse}{pins_board_s3}(board, ...) + +\method{board_deparse}{pins_board_url}(board, ...) } \arguments{ \item{board}{A pin board, created by \code{\link[=board_folder]{board_folder()}}, \code{\link[=board_connect]{board_connect()}}, diff --git a/tests/testthat/_snaps/board_url.md b/tests/testthat/_snaps/board_url.md index 735df98f..e3da38ea 100644 --- a/tests/testthat/_snaps/board_url.md +++ b/tests/testthat/_snaps/board_url.md @@ -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 @@ -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 diff --git a/tests/testthat/test-board_url.R b/tests/testthat/test-board_url.R index 2d4e7761..58a0bcbe 100644 --- a/tests/testthat/test-board_url.R +++ b/tests/testthat/test-board_url.R @@ -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", { @@ -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) }) From 630c53bdc8dca8b95934315e13241feeed7e8bdd Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 30 Aug 2023 12:26:19 -0600 Subject: [PATCH 3/3] Update NEWS --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 7b6359f7..0f1e3bdf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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