R/load_and_simplify.R
, R/load_and_simplify_dir.R
load_and_simplify.Rd
These function extracts all YAML fragments from a file or text (load_and_simplify
)
or from all files in a directory (load_and_simplify_dir
) and loads them
by calling load_yaml_fragments()
, and then calls simplify_by_flattening()
,
on the result, returning the resulting list.
load_and_simplify( text, file, yamlFragments = NULL, select = ".*", simplify = ".*", delimiterRegEx = "^---$", ignoreOddDelimiters = FALSE, encoding = "UTF-8", silent = TRUE ) load_and_simplify_dir( path, recursive = TRUE, fileRegexes = c("^[^\\.]+.*$"), select = ".*", simplify = ".*", delimiterRegEx = "^---$", ignoreOddDelimiters = FALSE, encoding = "UTF-8", silent = TRUE )
text | As |
---|---|
file | As |
yamlFragments | A character vector of class |
select | A vector of regular expressions specifying object names
to retain. The default ( |
simplify | A regular expression specifying which elements to simplify (default is everything) |
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 |
silent | Whether to be silent ( |
path | The path containing the files. |
recursive | Whether to also process subdirectories ( |
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 ( |
A list of objects, where each object corresponds to one
item specified in the read YAML fragment(s) from the source file
or text. If the convention of the rock
, dct
and justifier
packages is followed, each object in this list contains one or
more named objects (lists), where the name indicates the type
of information contained. Each of those objects (lists) then
contains one or more objects of that type, such as metadata or
codes for rock
, a decentralized construct taxonomy element
for dct
, and a justification, decision, assertion, or source
for justifier
.
yum::load_and_simplify(text=" --- firstObject: id: firstFragment --- Outside of YAML --- otherObjectType: - id: secondFragment parentId: firstFragment - id: thirdFragment parentId: firstFragment --- Also outside of YAML");#> $firstObject #> $firstObject$id #> [1] "firstFragment" #> #> #> $otherObjectType #> $otherObjectType$id #> [1] "secondFragment" #> #> $otherObjectType$parentId #> [1] "firstFragment" #> #> #> $otherObjectType #> $otherObjectType$id #> [1] "thirdFragment" #> #> $otherObjectType$parentId #> [1] "firstFragment" #> #> #> attr(,"class") #> [1] "simplifiedYum" "list"