Merge pull request #82 from fcharlier/greedy_provider

'=' characters are legal in the values
This commit is contained in:
Dan Bode 2012-04-24 09:17:17 -07:00
commit 8e81967068
3 changed files with 9 additions and 3 deletions

View File

@ -19,8 +19,8 @@ Puppet::Type.type(:nova_config).provide(
:fields => %w{line},
:match => /--(.*)/ ,
:post_parse => proc { |hash|
Puppet.debug("nova config line:#{hash[:line]} has been parsed")
if hash[:line] =~ /^\s*(\S+)\s*=\s*([\S ]+)\s*$/
Puppet.debug("nova config line:#{hash[:line]} has been parsed")
if hash[:line] =~ /^\s*(\S+?)\s*=\s*([\S ]+)\s*$/
hash[:name]=$1
hash[:value]=$2
elsif hash[:line] =~ /^\s*(\S+)\s*$/

View File

@ -20,7 +20,7 @@ Puppet::Type.type(:nova_config).provide(
:match => /(.*)/ ,
:post_parse => proc { |hash|
Puppet.debug("nova config line:#{hash[:line]} has been parsed")
if hash[:line] =~ /^\s*(\S+)\s*=\s*([\S ]+?)\s*$/
if hash[:line] =~ /^\s*(\S+?)\s*=\s*([\S ]+?)\s*$/
hash[:name]=$1
hash[:value]=$2
elsif hash[:line] =~ /^\s*(\S+)\s*$/

View File

@ -25,6 +25,12 @@ describe provider_class do
record[:value].should == 'bar or baz'
record[:record_type].should == :parsed
end
it 'should be able to parse values with equal signs' do
record = @provider.class.parse('--foo = bar=baz').first
record[:name].should == 'foo'
record[:value].should == 'bar=baz'
record[:record_type].should == :parsed
end
it 'should be able to create a valid line from a resource' do
provider_class.to_line({:name => 'foo', :value => 'bar'}).should == '--foo=bar'
end