extract_yaml_dir: Extract all YAML fragments from all files in a directory

Description Usage Arguments Value Examples

View source: R/extract_yaml_dir.R

Description

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

Usage

1
2
3
4
5
6
7
8
9
extract_yaml_dir(
  path,
  recursive = TRUE,
  fileRegexes = c("^[^\\.]+.*$"),
  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 (.).

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).

Value

A list of character vectors.

Examples

1
2
3
4
5
6
7
8
### 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::extract_yaml_dir(path=examplePath);

yum documentation built on July 17, 2021, 1:07 a.m.