as_config {path.chain}R Documentation

Prepare list to be saved as config .yaml file

Description

This function is provided to keep compatibility with 'config' package, which requires existence of default key. Additionally, we can at once wrap our structure with some other keys, in order to not to mix directory structur with different keys.

Usage

as_config(x, config = "default", wrap = "dirs", ...)

## S3 method for class 'path_chain'
as_config(x, config = "default", wrap = "dirs",
  ..., root.name = "root.dir")

## S3 method for class 'list'
as_config(x, config = "default", wrap = "dirs", ...)

Arguments

x

list with directory structure

config

configuration name

wrap

key name to wrap directory structure

...

additional arguments (not used at the moment)

root.name

key for root directory (for path_chain only)

Value

list compatible with 'config' package

Examples

library(magrittr)
# Initalizaing sample directory
tmp <- create_temp_dir("files")
create_sample_dir(tmp, override = TRUE)
full_path_chain(tmp, "kRoot", naming_k) %>%
   list(kDirs = .) %>%
   list(default = .) %>%
   yaml::write_yaml(temp_path("config.yaml"))
# We can simply use such function
full_path_chain(tmp, "kRoot", naming_k) %>%
   as_config("default", "kDirs") %>%
   yaml::write_yaml(temp_path("config.yaml"))

[Package path.chain version 0.2.0 Index]