Merge pull request #158 from bmjen/modules-1876-fix
Modules 1876 - Setting names containing spaces fail
This commit is contained in:
commit
5d70bafff5
3 changed files with 28 additions and 6 deletions
|
@ -10,9 +10,8 @@ module Util
|
||||||
k_v_s = key_val_separator.strip
|
k_v_s = key_val_separator.strip
|
||||||
|
|
||||||
@@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/
|
@@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/
|
||||||
@@SETTING_REGEX = /^(\s*)([^\s#{k_v_s}]*)(\s*#{k_v_s}\s*)(.*)\s*$/
|
@@SETTING_REGEX = /^(\s*)([^#;\s]|[^#;\s].*?[^\s#{k_v_s}])(\s*#{k_v_s}\s*)(.*)\s*$/
|
||||||
@@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([^\s#{k_v_s}]*)(\s*#{k_v_s}[ \t]*)(.*)\s*$/
|
@@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)(.*?[^\s#{k_v_s}])(\s*#{k_v_s}[ \t]*)(.*)\s*$/
|
||||||
|
|
||||||
|
|
||||||
@path = path
|
@path = path
|
||||||
@key_val_separator = key_val_separator
|
@key_val_separator = key_val_separator
|
||||||
|
|
|
@ -147,9 +147,10 @@ describe 'ini_setting resource' do
|
||||||
|
|
||||||
describe 'section, setting, value parameters' do
|
describe 'section, setting, value parameters' do
|
||||||
{
|
{
|
||||||
"section => 'test', setting => 'foo', value => 'bar'," => /\[test\]\nfoo = bar/,
|
"section => 'test', setting => 'foo', value => 'bar'," => /\[test\]\nfoo = bar/,
|
||||||
"section => 'more', setting => 'baz', value => 'quux'," => /\[more\]\nbaz = quux/,
|
"section => 'more', setting => 'baz', value => 'quux'," => /\[more\]\nbaz = quux/,
|
||||||
"section => '', setting => 'top', value => 'level'," => /top = level/,
|
"section => '', setting => 'top', value => 'level'," => /top = level/,
|
||||||
|
"section => 'z', setting => 'sp aces', value => 'foo bar'," => /\[z\]\nsp aces = foo bar/,
|
||||||
}.each do |parameter_list, content|
|
}.each do |parameter_list, content|
|
||||||
context parameter_list do
|
context parameter_list do
|
||||||
pp = <<-EOS
|
pp = <<-EOS
|
||||||
|
|
|
@ -262,4 +262,26 @@ EOS
|
||||||
subject.get_value("Drive names", "C:").should eq 'Winchester'
|
subject.get_value("Drive names", "C:").should eq 'Winchester'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'Configuration with spaces in setting names' do
|
||||||
|
let(:sample_content) do
|
||||||
|
template = <<-EOS
|
||||||
|
[global]
|
||||||
|
# log files split per-machine:
|
||||||
|
log file = /var/log/samba/log.%m
|
||||||
|
|
||||||
|
kerberos method = system keytab
|
||||||
|
passdb backend = tdbsam
|
||||||
|
security = ads
|
||||||
|
EOS
|
||||||
|
template.split("\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expose settings for sections" do
|
||||||
|
subject.get_value("global", "log file").should eq '/var/log/samba/log.%m'
|
||||||
|
subject.get_value("global", "kerberos method").should eq 'system keytab'
|
||||||
|
subject.get_value("global", "passdb backend").should eq 'tdbsam'
|
||||||
|
subject.get_value("global", "security").should eq 'ads'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue