diff options
author | Adrien Thebo <git@somethingsinistral.net> | 2013-03-27 14:04:00 -0700 |
---|---|---|
committer | Adrien Thebo <git@somethingsinistral.net> | 2013-03-27 14:04:00 -0700 |
commit | 87c0f0c45418b276942e3de6deb8a2b681566019 (patch) | |
tree | d6e00ece57167148343ed93b6fef7ff5ea306898 /lib/puppet/parser/functions/min.rb | |
parent | c0a0682706ccc1ed8c927c5529c08ffe2a7a4a5e (diff) | |
parent | 755d3d2de505d098faa323fa751497d7f4a3dad1 (diff) | |
download | puppet-stdlib-87c0f0c45418b276942e3de6deb8a2b681566019.tar.gz puppet-stdlib-87c0f0c45418b276942e3de6deb8a2b681566019.tar.bz2 |
Merge branch '2.x' into 3.x
Diffstat (limited to 'lib/puppet/parser/functions/min.rb')
-rw-r--r-- | lib/puppet/parser/functions/min.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/min.rb b/lib/puppet/parser/functions/min.rb index abf1b62..6bd6ebf 100644 --- a/lib/puppet/parser/functions/min.rb +++ b/lib/puppet/parser/functions/min.rb @@ -8,6 +8,14 @@ module Puppet::Parser::Functions raise(Puppet::ParseError, "min(): Wrong number of arguments " + "need at least one") if args.size == 0 - return args.min + # Sometimes we get numbers as numerics and sometimes as strings. + # We try to compare them as numbers when possible + return args.min do |a,b| + if a.to_s =~ /\A^-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then + a.to_f <=> b.to_f + else + a.to_s <=> b.to_s + end + end end end |