diff options
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r-- | lib/puppet/parser/functions/deprecation.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/functions/ensure_resources.rb | 2 | ||||
-rw-r--r-- | lib/puppet/parser/functions/join_keys_to_values.rb | 15 |
3 files changed, 15 insertions, 6 deletions
diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb index e30f3a0..cd64fe2 100644 --- a/lib/puppet/parser/functions/deprecation.rb +++ b/lib/puppet/parser/functions/deprecation.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:deprecation, :type => :rvalue, :doc => <<-EOS + newfunction(:deprecation, :doc => <<-EOS Function to print deprecation warnings (this is the 3.X version of it), The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method.). EOS ) do |arguments| @@ -9,7 +9,7 @@ EOS key = arguments[0] message = arguments[1] - + if ENV['STDLIB_LOG_DEPRECATIONS'] == "true" warning("deprecation. #{key}. #{message}") end diff --git a/lib/puppet/parser/functions/ensure_resources.rb b/lib/puppet/parser/functions/ensure_resources.rb index 30d57a8..b3c51e6 100644 --- a/lib/puppet/parser/functions/ensure_resources.rb +++ b/lib/puppet/parser/functions/ensure_resources.rb @@ -36,7 +36,7 @@ ENDOFDOC params ||= {} if title.is_a?(Hash) - resource_hash = Hash(title) + resource_hash = title.dup resources = resource_hash.keys Puppet::Parser::Functions.function(:ensure_resource) diff --git a/lib/puppet/parser/functions/join_keys_to_values.rb b/lib/puppet/parser/functions/join_keys_to_values.rb index e9924fe..e3baf9f 100644 --- a/lib/puppet/parser/functions/join_keys_to_values.rb +++ b/lib/puppet/parser/functions/join_keys_to_values.rb @@ -5,7 +5,8 @@ module Puppet::Parser::Functions newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-EOS This function joins each key of a hash to that key's corresponding value with a -separator. Keys and values are cast to strings. The return value is an array in +separator. Keys are cast to strings. If values are arrays, multiple keys +are added for each element. The return value is an array in which each element is one joined key/value pair. *Examples:* @@ -13,6 +14,10 @@ which each element is one joined key/value pair. join_keys_to_values({'a'=>1,'b'=>2}, " is ") Would result in: ["a is 1","b is 2"] + + join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") + +Would result in: ["a is 1","b is 2","b is 3"] EOS ) do |arguments| @@ -38,8 +43,12 @@ Would result in: ["a is 1","b is 2"] # Join the keys to their values. hash.map do |k,v| - String(k) + separator + String(v) - end + if v.is_a?(Array) + v.map { |va| String(k) + separator + String(va) } + else + String(k) + separator + String(v) + end + end.flatten end end |