This helper module parses YAML files and make them available from code.
Public function to parse yaml into Bash
variables that could be evaluated by the caller.
Note: Remember to set _YAML_NAMESPACE uniquely for each document loaded.
Use like this:
local _YAML_PREFIX_ext
local _YAML_NAMESPACE333
local evals()
parseYAML $file "_evals"
eval "${_evals[@]}"
Then use space's functions to read the YAML structure.
$1: YAML file path.
$2: out array variable name.
We use this internally for chainer functions to not pollute with SPACE_ENV.
Helper function for _sort, to pad number parts of string.
- $1: name of variable to store result in.
- $2: string to zero pad to 10 digits.
parse well formatted YAML document into Bash variables.
Caveats:
arrays items must be indented at least one space from it's parent.
parent:
- first: item
- $1: name of variable to read YAML from.
- $2: name of array variable to append to.
- $3: name of array to use as completion array.
MACRO helper to _pp_yaml and _parse_yaml.
takes no arguments because it uses existing inherited variables.
- $1: preprocessing switch
MACRO helper to get a single row from the feed
and substitute preprocess variables in that row.
- $1: row index
- $2: preprocessing switch
- $1: preprocessing switch
Translate parsed YAML into Bash variables.
$1: variable name of input array.
$2: variable name of output array.
Peek into object for the given indentation level.
List all nodes below a given node.
- $1: name of output array to append to
- $2: slash separated path, starts and ends with slash.
- $3: include_hidden, set to "1" to include leaf nodes beginning with underscore.
- $4: include leaf node, set to "1" to include leaf nodes.
Copy a YAML variable (leaf) to another variable by assignment.
- $1: the name of the variable to copy to.
- $2: the slash separated _path of the variable to copy, do not end with slash.
env:
$_nodes
Array to add results to.
$1: name of array containing sorted list of nodes.
$2: pattern to match against list of nodes, ex: "/sites/.*/".
$3: include hidden nodes. set to 1 to include hidden leave nodes
beginning with an underscore.
$4: simple, set to 1 to only return the last node part.
$5: includeleafs, set to 1 to include leaf nodes.
Search for a modules YAML file using defaults and
trying all the different YAML file name variants.
- $1: module name: [username/]reponame
- $2: variable name to assign found YAML file path to.