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_float.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/puppet/parser/functions/is_float.rb (limited to 'lib/puppet/parser/functions/is_float.rb') diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb new file mode 100644 index 0000000..2a5a923 --- /dev/null +++ b/lib/puppet/parser/functions/is_float.rb @@ -0,0 +1,12 @@ +# +# is_float.rb +# + +module Puppet::Parser::Functions + newfunction(:is_float, :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_float.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/puppet/parser/functions/is_float.rb') diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb index 2a5a923..39d097f 100644 --- a/lib/puppet/parser/functions/is_float.rb +++ b/lib/puppet/parser/functions/is_float.rb @@ -6,6 +6,12 @@ module Puppet::Parser::Functions newfunction(:is_float, :type => :rvalue, :doc => <<-EOS EOS ) do |arguments| + + if (arguments.size != 1) then + raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+ + "given #{arguments.size} for 1") + end + end end -- cgit v1.2.3 From a55930368afe2e8177608472653c4696eccec92f Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Thu, 28 Jul 2011 15:38:19 +0100 Subject: (#2) - Added is_float and is_integer functionality. --- lib/puppet/parser/functions/is_float.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/puppet/parser/functions/is_float.rb') diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb index 39d097f..8aed848 100644 --- a/lib/puppet/parser/functions/is_float.rb +++ b/lib/puppet/parser/functions/is_float.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 then + return false + else + return true + 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_float.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/puppet/parser/functions/is_float.rb') diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb index 8aed848..2fc05ba 100644 --- a/lib/puppet/parser/functions/is_float.rb +++ b/lib/puppet/parser/functions/is_float.rb @@ -4,6 +4,7 @@ module Puppet::Parser::Functions newfunction(:is_float, :type => :rvalue, :doc => <<-EOS +Returns true if the variable passed to this function is a float. EOS ) do |arguments| -- cgit v1.2.3