From aafce9c99b779855e1e10e5a337848fa9f676a01 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Sat, 30 Apr 2011 16:00:49 +0200 Subject: Moved more functions into lib/puppet/parser/functions/ --- lib/puppet/parser/functions/is_numeric.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/puppet/parser/functions/is_numeric.rb (limited to 'lib/puppet/parser/functions/is_numeric.rb') diff --git a/lib/puppet/parser/functions/is_numeric.rb b/lib/puppet/parser/functions/is_numeric.rb new file mode 100644 index 0000000..7a64091 --- /dev/null +++ b/lib/puppet/parser/functions/is_numeric.rb @@ -0,0 +1,12 @@ +# +# is_numeric.rb +# + +module Puppet::Parser::Functions + newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS + EOS + ) do |arguments| + end +end + +# vim: set ts=2 sw=2 et : -- cgit v1.2.3 From 790818116e953118ba9eab5e5bef6d63f7bbc1fa Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Wed, 29 Jun 2011 21:21:55 +0100 Subject: Added tests for each function, fixing functions as we hit bugs. --- lib/puppet/parser/functions/is_numeric.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/puppet/parser/functions/is_numeric.rb') diff --git a/lib/puppet/parser/functions/is_numeric.rb b/lib/puppet/parser/functions/is_numeric.rb index 7a64091..96e8674 100644 --- a/lib/puppet/parser/functions/is_numeric.rb +++ b/lib/puppet/parser/functions/is_numeric.rb @@ -6,6 +6,12 @@ module Puppet::Parser::Functions newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS EOS ) do |arguments| + + if (arguments.size != 1) then + raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+ + "given #{arguments.size} for 1") + end + end end -- cgit v1.2.3 From 313df566bf5cfcbef73fc8182ccb07ddf2f13feb Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Thu, 28 Jul 2011 21:03:33 +0100 Subject: (#2) unstub is_numeric function. --- lib/puppet/parser/functions/is_numeric.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/puppet/parser/functions/is_numeric.rb') diff --git a/lib/puppet/parser/functions/is_numeric.rb b/lib/puppet/parser/functions/is_numeric.rb index 96e8674..c2c0fb5 100644 --- a/lib/puppet/parser/functions/is_numeric.rb +++ b/lib/puppet/parser/functions/is_numeric.rb @@ -12,6 +12,14 @@ module Puppet::Parser::Functions "given #{arguments.size} for 1") end + value = arguments[0] + + if value == value.to_f.to_s or value == value.to_i.to_s then + return true + else + return false + end + end end -- cgit v1.2.3 From a1cae426f1d6b8f2c19184ec8aac3ebc47d97744 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Fri, 29 Jul 2011 23:09:30 +0100 Subject: (#3) Provide documentation for remaining functions. --- lib/puppet/parser/functions/is_numeric.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/puppet/parser/functions/is_numeric.rb') diff --git a/lib/puppet/parser/functions/is_numeric.rb b/lib/puppet/parser/functions/is_numeric.rb index c2c0fb5..ce13ece 100644 --- a/lib/puppet/parser/functions/is_numeric.rb +++ b/lib/puppet/parser/functions/is_numeric.rb @@ -4,6 +4,7 @@ module Puppet::Parser::Functions newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS +Returns true if the variable passed to this function is a number. EOS ) do |arguments| -- cgit v1.2.3