-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#' @title List projects. | ||
#' @export | ||
#' @family configuration | ||
#' @description List the names of projects defined in `_targets.yaml`. | ||
#' @return Character vector of names of projects defined in `_targets.yaml`. | ||
#' @inheritSection tar_meta Storage access | ||
#' @inheritSection tar_config_set Configuration | ||
#' @inheritParams tar_config_set | ||
#' @examples | ||
#' yaml <- tempfile() | ||
#' tar_config_set(store = "my_store_a", config = yaml, project = "project_a") | ||
#' tar_config_set(store = "my_store_b", config = yaml, project = "project_b") | ||
#' tar_config_projects(config = yaml) | ||
tar_config_projects <- function( | ||
config = Sys.getenv("TAR_CONFIG", "_targets.yaml") | ||
) { | ||
names(tar_config_yaml(config = config)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#' @title Read `_targets.yaml`. | ||
#' @export | ||
#' @family configuration | ||
#' @description Read the YAML content of `_targets.yaml`. | ||
#' @return Nested list of fields defined in `_targets.yaml`. | ||
#' @inheritSection tar_meta Storage access | ||
#' @inheritSection tar_config_set Configuration | ||
#' @inheritParams tar_config_set | ||
#' @examples | ||
#' yaml <- tempfile() | ||
#' tar_config_set(store = "my_store_a", config = yaml, project = "project_a") | ||
#' tar_config_set(store = "my_store_b", config = yaml, project = "project_b") | ||
#' str(tar_config_yaml(config = yaml)) | ||
tar_config_yaml <- function( | ||
config = Sys.getenv("TAR_CONFIG", "_targets.yaml") | ||
) { | ||
tar_assert_chr(config) | ||
tar_assert_scalar(config) | ||
yaml <- tar_config_read_yaml(config) | ||
if_any( | ||
tar_config_is_multi_project(yaml, config), | ||
yaml, | ||
tar_config_convert_multi_project(yaml, config) | ||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test_that("tar_config_projects()", { | ||
yaml <- tempfile() | ||
tar_config_set(store = "my_store_a", config = yaml, project = "project_a") | ||
tar_config_set(store = "my_store_b", config = yaml, project = "project_b") | ||
out <- tar_config_projects(config = yaml) | ||
expect_equal(sort(out), sort(c("project_a", "project_b"))) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
test_that("tar_config_projects()", { | ||
yaml <- tempfile() | ||
tar_config_set(store = "my_store_a", config = yaml, project = "project_a") | ||
tar_config_set(store = "my_store_b", config = yaml, project = "project_b") | ||
out <- tar_config_yaml(config = yaml) | ||
exp <- list( | ||
project_a = list(store = "my_store_a"), | ||
project_b = list(store = "my_store_b") | ||
) | ||
expect_equal(out, exp) | ||
}) |