R6 Class representing a configuration object
R6 Class representing a configuration object
config_list
The list representation of the Config object
new()
Create a new Config object
Config$new(config_list, versions = NULL)
config_list
either a list or a filepath to a YAML file containing that list
versions
(default NULL) A named list containing versions for versioned
directories. If passed, used to define or update items in config_list$versions
.
...
Nested indices (character or numeric) down the config list
If no parameters are passed, returns the entire config_list
A subset of the list. If the item is NULL or missing, returns an error
get_dir_path()
Construct a directory path from the config object
Config$get_dir_path(
dir_name,
custom_version = NULL,
fail_if_does_not_exist = FALSE
)
dir_name
Directory name
custom_version
(character, default NULL) A custom version that will be
applied to this folder, rather than pulling from config_list$versions[[dir]]
.
Only applies to versioned folders.
fail_if_does_not_exist
(logical, default FALSE) should this method return an error if the directory in question does not already exist?
Works differently for versioned and non-versioned directories. See the class description for more information.
The full path to the directory
get_file_path()
Construct a file path from the config object
Config$get_file_path(
dir_name,
file_name,
custom_version = NULL,
fail_if_does_not_exist = FALSE
)
dir_name
Directory name
file_name
File name within that directory
custom_version
(character, default NULL) A custom version that will be
applied to this folder, rather than pulling from config_list$versions[[dir]]
.
Only applies to versioned folders.
fail_if_does_not_exist
(logical, default FALSE) should this method return an error if the directory in question does not already exist?
Looks for the file path under:
config_list$directories[[dir_name]]$files[[file_name]]
The full path to the file Read a file based on the config
read()
Config$read(dir_name, file_name, ..., custom_version = NULL)
dir_name
Directory name
file_name
File name within that directory
...
Optional file reading arguments to pass to autoread()
custom_version
(character, default NULL) A custom version that will be
applied to this folder, rather than pulling from config_list$versions[[dir]]
.
Only applies to versioned folders. If passed, this argument must always be
explicitly named.
The object loaded by autoread()
Write an object to file based on the config
write()
Config$write(x, dir_name, file_name, ..., custom_version = NULL)
x
Object to write
dir_name
Directory name
file_name
File name within that directory
...
Optional file writing arguments to pass to autowrite()
custom_version
(character, default NULL) A custom version that will be
applied to this folder, rather than pulling from config_list$versions[[dir]]
.
Only applies to versioned folders. If passed, this argument must always be
explicitly named.
Invisibly passes TRUE if successful Convenience function: write the config list to a folder as 'config.yaml'
write_self()
Config$write_self(dir_name, ..., custom_version = NULL)
dir_name
Directory name
...
Optional file writing arguments to pass to autowrite()
custom_version
(character, default NULL) A custom version that will be
applied to this folder, rather than pulling from config_list$versions[[dir]]
.
Only applies to versioned folders. If passed, this argument must always be
explicitly named.
Invisibly passes TRUE if successful
clone()
The objects of this class are cloneable with this method.
Config$clone(deep = FALSE)
deep
Whether to make a deep clone.
The special sublist directories
is structured to contain three items for each
directory name:
versioned
: a T/F value specifying whether the directory is versioned
path
: the full path to the top level of that directory.
files
: A named list referencing file paths within that directory.
If the directory is versioned, a version must be set in the versions
sublist of the
config list. versions
is itself a named list where each key corresponds to a
versioned folder in directories
and the value gives the particular folder version
(for example, a timestamp) that corresponds to the particular run.
pull_from_list()