Sha256: 6ed515da2b1de32fff10c7d951ad166e42c80a0ecfd4dc6c11a51cf7643c913c

Contents?: true

Size: 818 Bytes

Versions: 254

Compression:

Stored size: 818 Bytes

Contents

require 'puppet/parameter'

# 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.
#
class Puppet::Parameter::PackageOptions < Puppet::Parameter
  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

  # @api private
  def quote(value)
    value.include?(' ') ? %Q["#{value.gsub(/"/, '\"')}"] : value
  end
end

Version data entries

254 entries across 254 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/parameter/package_options.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/parameter/package_options.rb
puppet-4.10.12 lib/puppet/parameter/package_options.rb
puppet-4.10.12-x86-mingw32 lib/puppet/parameter/package_options.rb
puppet-4.10.12-x64-mingw32 lib/puppet/parameter/package_options.rb
puppet-4.10.12-universal-darwin lib/puppet/parameter/package_options.rb
puppet-4.10.11 lib/puppet/parameter/package_options.rb
puppet-4.10.11-x86-mingw32 lib/puppet/parameter/package_options.rb
puppet-4.10.11-x64-mingw32 lib/puppet/parameter/package_options.rb
puppet-4.10.11-universal-darwin lib/puppet/parameter/package_options.rb
puppet-4.10.10 lib/puppet/parameter/package_options.rb
puppet-4.10.10-x86-mingw32 lib/puppet/parameter/package_options.rb
puppet-4.10.10-x64-mingw32 lib/puppet/parameter/package_options.rb
puppet-4.10.10-universal-darwin lib/puppet/parameter/package_options.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/parameter/package_options.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/parameter/package_options.rb
puppet-4.10.9 lib/puppet/parameter/package_options.rb
puppet-4.10.9-x86-mingw32 lib/puppet/parameter/package_options.rb
puppet-4.10.9-x64-mingw32 lib/puppet/parameter/package_options.rb
puppet-4.10.9-universal-darwin lib/puppet/parameter/package_options.rb