summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-07-24 00:39:17 +0100
committerKen Barber <ken@bob.sh>2011-07-24 00:39:17 +0100
commitfde64f37c98291f4a5b9ee1fcf634288e42b730a (patch)
tree8142aaf86b7d2bad9a213c1116c1ec37960c491d /lib
parent07ee33455439d960b9996e8110e011437181b42a (diff)
downloadpuppet-stdlib-fde64f37c98291f4a5b9ee1fcf634288e42b730a.tar.gz
puppet-stdlib-fde64f37c98291f4a5b9ee1fcf634288e42b730a.tar.bz2
(#1) - fleshed out some more tests.
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