diff options
author | Josh Cooper <josh@puppet.com> | 2018-09-25 07:48:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-25 07:48:25 -0700 |
commit | 47fba6a321f31c327520f3a3428e94f3590431d1 (patch) | |
tree | 6ccc2acfc63cdb913f3e1bede6d2c10d06036dc5 | |
parent | 3241fbdbb117247490a6f662c32c21fb56af03ef (diff) | |
parent | 3a91f8cf69dc6ba643f8d06f9d3aa61bd69d6b8a (diff) | |
download | puppet-augeas_core-47fba6a321f31c327520f3a3428e94f3590431d1.tar.gz puppet-augeas_core-47fba6a321f31c327520f3a3428e94f3590431d1.tar.bz2 |
Merge pull request #8 from Lavinia-Dan/fix-for-undefined-strip-for-nil
(MODULES-7814) Ignore nil values when parsing commands. Fix for: Could not evaluate: undefined method strip! for nil:NilClass
-rw-r--r-- | lib/puppet/provider/augeas/augeas.rb | 3 | ||||
-rw-r--r-- | spec/unit/provider/augeas/augeas_spec.rb | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index a22a506..7704955 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -79,8 +79,9 @@ Puppet::Type.type(:augeas).provide(:augeas) do data = data.flatten args = [] data.each do |line| + next if line.nil? line.strip! - next if line.nil? || line.empty? + next if line.empty? argline = [] sc = StringScanner.new(line) cmd = sc.scan(%r{\w+|==|!=}) diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb index 180f89c..7c9336a 100644 --- a/spec/unit/provider/augeas/augeas_spec.rb +++ b/spec/unit/provider/augeas/augeas_spec.rb @@ -46,6 +46,16 @@ describe Puppet::Type.type(:augeas).provider(:augeas) do end describe 'command parsing' do + it 'ignores nil values when parsing commands' do + commands = [nil, 'set Jar/Jar Binks'] + tokens = provider.parse_commands(commands) + expect(tokens.size).to eq(1) + expect(tokens[0].size).to eq(3) + expect(tokens[0][0]).to eq('set') + expect(tokens[0][1]).to eq('Jar/Jar') + expect(tokens[0][2]).to eq('Binks') + end + it 'breaks apart a single line into three tokens and clean up the context' do resource[:context] = '/context' tokens = provider.parse_commands('set Jar/Jar Binks') |