Signed-off-by: Luke Kanies <[email protected]>
---
 lib/puppet/indirector/rest.rb          |    1 +
 lib/puppet/network/http/handler.rb     |    2 ++
 spec/unit/indirector/rest.rb           |   10 ++++++++++
 spec/unit/network/http/mongrel/rest.rb |   12 ++++++++++++
 4 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb
index ce459b9..23ed56d 100644
--- a/lib/puppet/indirector/rest.rb
+++ b/lib/puppet/indirector/rest.rb
@@ -94,6 +94,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
             case value
             when nil; next
             when true, false; value = value.to_s
+            when Fixnum, Bignum, Float; value = value # nothing
             when String; value = URI.escape(value)
             when Symbol; value = URI.escape(value.to_s)
             when Array; value = URI.escape(YAML.dump(value))
diff --git a/lib/puppet/network/http/handler.rb 
b/lib/puppet/network/http/handler.rb
index cce6798..7f6bd41 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -193,6 +193,8 @@ module Puppet::Network::HTTP::Handler
             else
                 value = true if value == "true"
                 value = false if value == "false"
+                value = Integer(value) if value =~ /^\d+$/
+                value = value.to_f if value =~ /^\d+\.\d+$/
             end
             result[param.to_sym] = value
             result
diff --git a/spec/unit/indirector/rest.rb b/spec/unit/indirector/rest.rb
index 4fa30b2..8ed50d3 100755
--- a/spec/unit/indirector/rest.rb
+++ b/spec/unit/indirector/rest.rb
@@ -194,6 +194,16 @@ describe Puppet::Indirector::REST do
             @searcher.query_string(@request).should == "?one=#{escaping}"
         end
 
+        it "should convert to a string all option values that are integers" do
+            @request.stubs(:options).returns(:one => 50)
+            @searcher.query_string(@request).should == "?one=50"
+        end
+
+        it "should convert to a string all option values that are floating 
point numbers" do
+            @request.stubs(:options).returns(:one => 1.2)
+            @searcher.query_string(@request).should == "?one=1.2"
+        end
+
         it "should convert to a string and URI-escape all option values that 
are symbols" do
             escaping = URI.escape("sym bol")
             @request.stubs(:options).returns(:one => :"sym bol")
diff --git a/spec/unit/network/http/mongrel/rest.rb 
b/spec/unit/network/http/mongrel/rest.rb
index e72d4f5..c03698d 100755
--- a/spec/unit/network/http/mongrel/rest.rb
+++ b/spec/unit/network/http/mongrel/rest.rb
@@ -128,6 +128,18 @@ describe "Puppet::Network::HTTP::MongrelREST" do
                 result[:foo].should be_false
             end
 
+            it "should convert integer arguments to Integers" do
+                @request.expects(:params).returns('QUERY_STRING' => 'foo=15')
+                result = @handler.params(@request)
+                result[:foo].should == 15
+            end
+
+            it "should convert floating point arguments to Floats" do
+                @request.expects(:params).returns('QUERY_STRING' => 'foo=1.5')
+                result = @handler.params(@request)
+                result[:foo].should == 1.5
+            end
+
             it "should YAML-load and URI-decode values that are YAML-encoded" 
do
                 escaping = URI.escape(YAML.dump(%w{one two}))
                 @request.expects(:params).returns('QUERY_STRING' => 
"foo=#{escaping}")
-- 
1.6.1


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to