Sha256: 458a7176626c2d3a5b8c299921a1593df78689c932a0f3de9d97518eada5b860
Contents?: true
Size: 866 Bytes
Versions: 20
Compression:
Stored size: 866 Bytes
Contents
# frozen_string_literal: true require_relative '../../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
20 entries across 20 versions & 1 rubygems