Sha256: 7da77c98add4109351014155f1be7f1ed2686a4f7ca2b11e601243eebe311870

Contents?: true

Size: 576 Bytes

Versions: 11

Compression:

Stored size: 576 Bytes

Contents

require 'puppet/parameter'

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
puppet-3.0.2 lib/puppet/parameter/package_options.rb
puppet-3.0.2.rc3 lib/puppet/parameter/package_options.rb
puppet-3.0.2.rc2 lib/puppet/parameter/package_options.rb
puppet-3.0.2.rc1 lib/puppet/parameter/package_options.rb
puppet-3.0.1 lib/puppet/parameter/package_options.rb
puppet-3.0.1.rc1 lib/puppet/parameter/package_options.rb
puppet-3.0.0 lib/puppet/parameter/package_options.rb
puppet-3.0.0.rc8 lib/puppet/parameter/package_options.rb
puppet-3.0.0.rc7 lib/puppet/parameter/package_options.rb
puppet-3.0.0.rc5 lib/puppet/parameter/package_options.rb
puppet-3.0.0.rc4 lib/puppet/parameter/package_options.rb