lib/hiera/backend.rb
# Parse a string like '%{foo}' against a supplied
# scope and additional scope.  If either scope or
# extra_scope includes the varaible 'foo' it will
# be replaced else an empty string will be placed.
#
# If both scope and extra_data has "foo" scope
# will win.  See hiera-puppet for an example of
# this to make hiera aware of additional non scope
# variables
Parse a string like '%{foo}' against a supplied
scope and additional scope.  If either scope or
extra_scope includes the varaible 'foo' it will
be replaced else an empty string will be placed.

If both scope and extra_data has "foo" scope
will win.  See hiera-puppet for an example of
this to make hiera aware of additional non scope
variables
Parse a string like ' % { foo } ' against a supplied scope and additional scope . If either scope or extra_scope includes the varaible ' foo ' it will be replaced else an empty string will be placed . If both scope and extra_data has " foo " scope will win . See hiera - puppet for an example of this to make hiera aware of additional non scope variables
def parse_string(data, scope, extra_data={})
        return nil unless data
        tdata = data.clone
        if tdata.is_a?(String)
          while tdata =~ /%\{(.+?)\}/
            begin
              var = $1
              val = ""
              scope_val = scope[var]
              if !scope_val.nil? && scope_val != :undefined
                  val = scope_val
              elsif extra_data[var]
                  val = extra_data[var]
              end
            end until val != "" || var !~ /::(.+)/
            tdata.gsub!(/%\{(::)?#{var}\}/, val)
          end
        end
        return tdata
      end
def parse_string ( data , scope , extra_data = { } ) return nil unless data tdata = data . clone if tdata . is_a? ( String ) while tdata =~ / % \{ (.+?) \} / begin var = $1 val = "" scope_val = scope [ var ] if ! scope_val . nil? && scope_val != :undefined val = scope_val elsif extra_data [ var ] val = extra_data [ var ] end end until val != "" || var !~ / ::(.+) / tdata . gsub! ( / % \{ (::)? #{ var } \} / , val ) end end return tdata end
Parse a string like '%{foo}' against a supplied
scope and additional scope.
Parse a string like ' % { foo } ' against a supplied scope and additional scope .
# Puppet can return :undefined for unknown scope vars, # If it does then we still need to evaluate extra_data # before returning an empty string.
data
<not_specific>
scope
<not_specific>
extra_data
<not_specific>