class Puppet::Parameter::PackageOptions

This specialized {Puppet::Parameter} handles munging of package options. Package options are passed as an array of key value pairs. Special munging is required as the keys and values needs to be quoted in a safe way.

Public Instance Methods

quote(value) click to toggle source

@api private

# File lib/puppet/parameter/package_options.rb, line 28
def quote(value)
  value.include?(' ') ? %Q["#{value.gsub(/"/, '\"')}"] : value
end
unsafe_munge(values) click to toggle source
# File lib/puppet/parameter/package_options.rb, line 8
def unsafe_munge(values)
  values = [values] unless values.is_a? Array

  values.collect do |val|
    case val
    when Hash
      safe_hash = {}
      val.each_pair do |k, v|
        safe_hash[quote(k)] = quote(v)
      end
      safe_hash
    when String
      quote(val)
    else
      fail("Expected either a string or hash of options")
    end
  end
end