diff options
author | Morgan Haskel <morgan@puppetlabs.com> | 2015-03-02 11:09:33 -0800 |
---|---|---|
committer | Morgan Haskel <morgan@puppetlabs.com> | 2015-03-02 11:09:33 -0800 |
commit | 6d07a6a8095961ad58c155a62bcfea26136549bd (patch) | |
tree | ca1ace730605023a3eac479c1be5307856482d0a /lib/puppet/parser | |
parent | cd6568039f53a59c145239012e9ada14685eed88 (diff) | |
parent | 85e81f9bdf9d482338c504ff3c658993a24978a0 (diff) |
Merge pull request #419 from cyberious/master
Loosen the restrictions of upcase and allow for recursion of the objects...
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/functions/upcase.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/puppet/parser/functions/upcase.rb b/lib/puppet/parser/functions/upcase.rb index 2b05db4..0226a88 100644 --- a/lib/puppet/parser/functions/upcase.rb +++ b/lib/puppet/parser/functions/upcase.rb @@ -17,22 +17,22 @@ Will return: ) do |arguments| raise(Puppet::ParseError, "upcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + "given (#{arguments.size} for 1)") if arguments.size != 1 value = arguments[0] - unless value.is_a?(Array) || value.is_a?(String) || value.is_a?(Hash) + unless value.is_a?(Array) || value.is_a?(Hash) || value.respond_to?(:upcase) raise(Puppet::ParseError, 'upcase(): Requires an ' + - 'array, string or hash to work with') + 'array, hash or object that responds to upcase in order to work') end if value.is_a?(Array) # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? i.upcase : i } + result = value.collect { |i| function_upcase([i]) } elsif value.is_a?(Hash) result = {} value.each_pair do |k, v| - result.merge!({k.upcase => v.collect! { |p| p.upcase }}) + result[function_upcase([k])] = function_upcase([v]) end else result = value.upcase |