lib/utilrb/pkgconfig.rb
# Helper method that expands ${word} in +value+ using the name to value
# map +variables+
#
# +current+ is a string that describes what we are expanding. It is used
# to detect recursion in expansion of variables, and to give meaningful
# errors to the user
Helper method that expands ${word} in +value+ using the name to value
map +variables+

+current+ is a string that describes what we are expanding. It is used
to detect recursion in expansion of variables, and to give meaningful
errors to the user
Helper method that expands $ { word } in + value + using the name to value map + variables + + current + is a string that describes what we are expanding . It is used to detect recursion in expansion of variables and to give meaningful errors to the user
def expand_variables(value, variables, current)
            value = value.gsub(/\$\{(\w+)\}/) do |rx|
                expand_name = $1
                if expand_name == current
                    raise "error in pkg-config file #{path}: #{current} contains a reference to itself"
                elsif !(expanded = variables[expand_name])
                    raise "error in pkg-config file #{path}: #{current} contains a reference to #{expand_name} but there is no such variable"
                end
                expanded
            end
            value
        end
def expand_variables ( value , variables , current ) value = value . gsub ( / \$ \{ ( \w +) \} / ) do | rx | expand_name = $1 if expand_name == current raise "error in pkg-config file #{path}: #{current} contains a reference to itself" elsif ! ( expanded = variables [ expand_name ] ) raise "error in pkg-config file #{path}: #{current} contains a reference to #{expand_name} but there is no such variable" end expanded end value end
Helper method that expands ${word} in +value+ using the name to value
map +variables+
Helper method that expands $ { word } in + value + using the name to value map + variables +
value
<not_specific>
variables
<not_specific>
current
<not_specific>