load_yaml_dir {yum}R Documentation

Load all YAML fragments from all files in a directory

Description

These function extracts all YAML fragments from all files in a directory returning a list of character vectors containing the extracted fragments.

Usage

load_yaml_dir(
  path,
  recursive = TRUE,
  fileRegexes = c("^[^\\.]+.*$"),
  select = ".*",
  delimiterRegEx = "^---$",
  ignoreOddDelimiters = FALSE,
  encoding = "UTF-8",
  silent = TRUE
)

Arguments

path

The path containing the files.

recursive

Whether to also process subdirectories (TRUE) or not (FALSE).

fileRegexes

A vector of regular expressions to match the files against: only files matching one or more regular expressions in this vector are processed. The default regex (⁠^[^\.]+.*$⁠) matches all files except those that start with a period (.).

select

A vector of regular expressions specifying object names to retain. The default (⁠.*⁠) matches everything, so by default, all objects are retained.

delimiterRegEx

The regular expression used to locate YAML fragments.

ignoreOddDelimiters

Whether to throw an error (FALSE) or delete the last delimiter (TRUE) if an odd number of delimiters is encountered.

encoding

The encoding to use when calling readLines(). Set to NULL to let readLines() guess.

silent

Whether to be silent (TRUE) or informative (FALSE).

Details

These function extracts all YAML fragments from all files in a directory and then calls yaml::yaml.load() to parse them. It then returns a list where each element is a list with the parsed fragments in a file.

Value

A list of lists of objects.

Examples

### First get the directory where 'yum' is installed
yumDir <- system.file(package="yum");
### Specify the path of some example files
examplePath <- file.path(yumDir, "extdata");
### Show files (should be three .dct files)
list.files(examplePath);
### Load these files
yum::load_yaml_dir(path=examplePath);

[Package yum version 0.1.0 Index]