summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/functions/sort.rb6
-rw-r--r--lib/puppet/parser/functions/squeeze.rb21
2 files changed, 23 insertions, 4 deletions
diff --git a/lib/puppet/parser/functions/sort.rb b/lib/puppet/parser/functions/sort.rb
index 974141c..54a4018 100644
--- a/lib/puppet/parser/functions/sort.rb
+++ b/lib/puppet/parser/functions/sort.rb
@@ -7,11 +7,13 @@ module Puppet::Parser::Functions
EOS
) do |arguments|
- if (arguments.size != 0) then
+ if (arguments.size != 1) then
raise(Puppet::ParseError, "sort(): Wrong number of arguments "+
- "given #{arguments.size} for 0")
+ "given #{arguments.size} for 1")
end
+ arguments[0].sort
+
end
end
diff --git a/lib/puppet/parser/functions/squeeze.rb b/lib/puppet/parser/functions/squeeze.rb
index 02eb00c..9a1dd20 100644
--- a/lib/puppet/parser/functions/squeeze.rb
+++ b/lib/puppet/parser/functions/squeeze.rb
@@ -7,9 +7,26 @@ module Puppet::Parser::Functions
EOS
) do |arguments|
- if (arguments.size != 2) then
+ if ((arguments.size != 2) and (arguments.size != 1)) then
raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+
- "given #{arguments.size} for 2")
+ "given #{arguments.size} for 2 or 1")
+ end
+
+ item = arguments[0]
+ squeezeval = arguments[1]
+
+ if item.is_a?(Array) then
+ if squeezeval then
+ item.collect { |i| i.squeeze(squeezeval) }
+ else
+ item.collect { |i| i.squeeze }
+ end
+ else
+ if squeezeval then
+ item.squeeze(squeezeval)
+ else
+ item.squeeze
+ end
end
end