diff --git a/NEWS.md b/NEWS.md index 1ca74620a..5d92f7cae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # pins (development version) +* `pin_meta()` now includes pin `name` (#544). + * `board_deparse()` is more likely to generate runnable code when used with `board_rsconnect()` (#553). diff --git a/R/board_azure.R b/R/board_azure.R index 2e645dd3f..0e0d370a9 100644 --- a/R/board_azure.R +++ b/R/board_azure.R @@ -137,6 +137,7 @@ pin_meta.pins_board_azure <- function(board, name, version = NULL, ...) { azure_download(board, metadata_blob, progress = FALSE) local_meta( read_meta(fs::path(board$cache, name, version)), + name = name, dir = path_version, version = version ) diff --git a/R/board_folder.R b/R/board_folder.R index 08f0b4d1a..530dbb548 100644 --- a/R/board_folder.R +++ b/R/board_folder.R @@ -101,7 +101,7 @@ pin_meta.pins_board_folder <- function(board, name, version = NULL, ...) { } meta <- read_meta(path_version) - local_meta(meta, dir = path_version, version = version) + local_meta(meta, name = name, dir = path_version, version = version) } #' @export diff --git a/R/board_kaggle.R b/R/board_kaggle.R index 06a6085fd..c60b6aa23 100644 --- a/R/board_kaggle.R +++ b/R/board_kaggle.R @@ -140,6 +140,7 @@ pin_meta.pins_board_kaggle_competition <- function(board, name, ...) { api_version = 1 ) local_meta(meta, + name = name, version = NA_character_, dir = fs::path(board$cache, name), url = competition$url @@ -289,6 +290,7 @@ pin_meta.pins_board_kaggle_dataset <- function(board, name, version = NULL, ...) api_version = 1 ) local_meta(meta, + name = name, version = view$currentVersionNumber, dir = fs::path(board$cache, name), url = view$url diff --git a/R/board_ms365.R b/R/board_ms365.R index 41fbef741..2f855c6fe 100644 --- a/R/board_ms365.R +++ b/R/board_ms365.R @@ -156,6 +156,7 @@ pin_meta.pins_board_ms365 <- function(board, name, version = NULL, ...) { ms365_download(board, metadata_key) local_meta( read_meta(fs::path(board$cache, name, version)), + name = name, dir = path_version, version = version ) diff --git a/R/board_rsconnect.R b/R/board_rsconnect.R index 4a9b68c7d..09d4e2f95 100644 --- a/R/board_rsconnect.R +++ b/R/board_rsconnect.R @@ -199,6 +199,7 @@ pin_meta.pins_board_rsconnect <- function(board, name, version = NULL, ...) { meta <- read_meta(cache_path) local_meta(meta, + name = name, dir = cache_path, url = url, version = bundle_id, diff --git a/R/board_s3.R b/R/board_s3.R index 4d199c8d0..ddd2e02d5 100644 --- a/R/board_s3.R +++ b/R/board_s3.R @@ -188,6 +188,7 @@ pin_meta.pins_board_s3 <- function(board, name, version = NULL, ...) { s3_download(board, metadata_key, immutable = TRUE) local_meta( read_meta(fs::path(board$cache, name, version)), + name = name, dir = path_version, version = version ) diff --git a/R/board_url.R b/R/board_url.R index 55cb6464a..57f7677e8 100644 --- a/R/board_url.R +++ b/R/board_url.R @@ -90,6 +90,7 @@ pin_meta.pins_board_url <- function(board, name, version = NULL, ...) { ) meta <- read_meta(cache_dir) local_meta(meta, + name = name, dir = cache_dir, url = url, file_url = paste0(url, meta$file) @@ -102,6 +103,7 @@ pin_meta.pins_board_url <- function(board, name, version = NULL, ...) { api_version = 1 ) local_meta(meta, + name = name, dir = cache_dir, url = url, file_url = url diff --git a/R/pin-meta.R b/R/pin-meta.R index 679d82a83..be9802748 100644 --- a/R/pin-meta.R +++ b/R/pin-meta.R @@ -4,6 +4,7 @@ #' Pin metadata comes from three sources: #' #' * Standard metadata added by `pin_upload()`/`pin_write()`. This includes: +#' * `$name` - the pin's name. #' * `$file` - names of files stored in the pin. #' * `$file_size` - size of each file. #' * `$pin_hash` - hash of pin contents. @@ -71,7 +72,8 @@ multi_meta <- function(board, names) { #' @noRd #' @param dir Path to local cache directory #' @param url Remote url to pin; used `pin_browser()` -local_meta <- function(x, dir, url = NULL, version = NULL, ...) { +local_meta <- function(x, name, dir, url = NULL, version = NULL, ...) { + x$name <- name x$local <- list( dir = dir, url = url, @@ -85,6 +87,7 @@ test_api_meta <- function(board) { testthat::test_that("can round-trip pin metadata", { name <- local_pin(board, 1, title = "title", description = "desc", metadata = list(a = "a")) meta <- pin_meta(board, name) + testthat::expect_equal(meta$name, name) testthat::expect_equal(meta$title, "title") testthat::expect_equal(meta$description, "desc") testthat::expect_equal(meta$user$a, "a")