Skip to content

Commit d7f4228

Browse files
committed
tar_format_get()
1 parent 71d9b17 commit d7f4228

22 files changed

+90
-0
lines changed

Diff for: NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ export(tar_exist_process)
433433
export(tar_exist_progress)
434434
export(tar_exist_script)
435435
export(tar_format)
436+
export(tar_format_get)
436437
export(tar_github_actions)
437438
export(tar_glimpse)
438439
export(tar_group)

Diff for: NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Implement `format = "auto"` (#1311, @hadley).
1212
* Replace `pingr` dependency with `base::socketConnection()` for local URL utilities (#1317, #1318, @Adafede).
1313
* Implement `tar_repository_cas()`, `tar_repository_cas_local()`, and `tar_repository_cas_local_gc()` for content-addressable storage (#1232, #1314, @noamross).
14+
* Add `tar_format_get()` to make implementing CAS systems easier.
1415

1516
# targets 1.7.1
1617

Diff for: R/tar_format_get.R

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#' @title Current storage format.
2+
#' @export
3+
#' @family utilities
4+
#' @description Get the storage format of the target currently running.
5+
#' @details This function is meant to be called inside a target in a
6+
#' running pipeline. If it is called outside a target in the running
7+
#' pipeline, it will return the default format given by
8+
#' `tar_option_get("format")`.
9+
#' @return A character string, storage format of the target currently
10+
#' running in the pipeline. If called outside a target in the running
11+
#' pipeline, [tar_format_get()] will return the default format given by
12+
#' `tar_option_get("format")`.
13+
#' @examples
14+
#' tar_target(x, tar_format_get(), format = "qs")
15+
tar_format_get <- function() {
16+
tar_definition()$settings$format
17+
}

Diff for: _pkgdown.yml

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ reference:
172172
- 'tar_definition'
173173
- 'tar_described_as'
174174
- 'tar_envir'
175+
- 'tar_format_get'
175176
- 'tar_group'
176177
- 'tar_name'
177178
- 'tar_path_script'

Diff for: man/tar_active.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_backoff.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_call.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_cancel.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_definition.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_described_as.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_envir.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_format_get.Rd

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_group.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_name.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_path.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_path_script.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_path_script_support.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_path_store.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_path_target.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_source.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/tar_store.Rd

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: tests/testthat/test-tar_format_get.R

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tar_test("tar_format_get()", {
2+
skip_cran()
3+
skip_if_not_installed("qs")
4+
expect_equal(tar_format_get(), tar_option_get("format"))
5+
tar_script(tar_target(x, tar_format_get(), format = "qs"))
6+
tar_make(callr_function = NULL)
7+
expect_equal(tar_read(x), "qs")
8+
})

0 commit comments

Comments
 (0)