Module: YAML
- Defined in:
- lib/yip.rb
Overview
yip; YAML + YPATH Interpolation
© 2003-2004 Bruce Williams <[email protected]> Free software; modify and redistribute it under the same terms as Ruby itself
Defined Under Namespace
Modules: Syck Classes: MissingInterpolationError, RecursiveInterpolationError
Constant Summary collapse
- INTERPOLATION_PATTERN =
/(%\((.+?)\)([^[:alpha:]]*[[:alpha:]]+)\b|%(.+?)%)/
Class Method Summary collapse
-
.interpolate(data) ⇒ Object
Interpolation method * Works similar to YAML::load.
Class Method Details
.interpolate(data) ⇒ Object
Interpolation method
-
Works similar to YAML::load
Interpolation of values occurs within all YAML strings. Interpolation is done using one of two formats:
%<YPATH ADDRESS>%
%(<YPATH ADDRESS>)<Kernel::printf FORMAT STRING>
Examples:
%general/server description%
%(general/server description)10s
For more examples, see examples/
Note: YPATH addresses that resolve to collections
interpolate as YAML (sans document separator)
Resources: yaml.freepan.org/index.cgi?YpathBrainstorm
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/yip.rb', line 42 def YAML::interpolate( data ) # get the node tree nodes = YAML::parse( data ) # give the DefaultLoader access to the node tree YAML::Syck::DefaultLoader.instance_eval{ @nodes = nodes } # do the deed nodes.transform rescue SystemStackError raise YAML::RecursiveInterpolationError::new( "Circular YPATH references found; could not interpolate" ) end |