diff --git a/lib/puppet/provider/postgresql_conf/.parsed.rb.swp b/lib/puppet/provider/postgresql_conf/.parsed.rb.swp new file mode 100644 index 0000000..5a5c170 Binary files /dev/null and b/lib/puppet/provider/postgresql_conf/.parsed.rb.swp differ diff --git a/lib/puppet/provider/postgresql_conf/parsed.rb b/lib/puppet/provider/postgresql_conf/parsed.rb index ebe1f70..7c597a8 100644 --- a/lib/puppet/provider/postgresql_conf/parsed.rb +++ b/lib/puppet/provider/postgresql_conf/parsed.rb @@ -18,12 +18,12 @@ Puppet::Type.type(:postgresql_conf).provide( :to_line => proc { |h| # simple string and numeric values don't need to be enclosed in quotes - if h[:value].is_a?(Fixnum) + if h[:value].is_a?(Numeric) val = h[:value].to_s else val = h[:value] end - dontneedquote = val.match(/^(\w+)$/) + dontneedquote = val.match(/^([\d\.]+|\w+)$/) dontneedequal = h[:name].match(/^(include|include_if_exists)$/i) str = h[:name].downcase # normalize case diff --git a/spec/unit/provider/postgresql_conf/.parsed_spec.rb.swp b/spec/unit/provider/postgresql_conf/.parsed_spec.rb.swp new file mode 100644 index 0000000..60e5484 Binary files /dev/null and b/spec/unit/provider/postgresql_conf/.parsed_spec.rb.swp differ diff --git a/spec/unit/provider/postgresql_conf/parsed_spec.rb b/spec/unit/provider/postgresql_conf/parsed_spec.rb index a9a155e..7646e3f 100644 --- a/spec/unit/provider/postgresql_conf/parsed_spec.rb +++ b/spec/unit/provider/postgresql_conf/parsed_spec.rb @@ -124,6 +124,19 @@ describe provider_class do "wal_segments = 32" ) end + + it "should allow numbers" do + expect(provider.to_line( {:name=>"integer", :value=>42, :comment=>nil, :record_type=>:parsed })).to eq( + "integer = 42" + ) + end + + it "should allow floats" do + expect(provider.to_line( {:name=>"float", :value=>2.71828182845, :comment=>nil, :record_type=>:parsed })).to eq( + "float = 2.71828182845" + ) + end + end end