Fixed SETTING_REGEX and COMMENTED_SETTING_REGEX to allow spaces in setting names.
This commit is contained in:
parent
70c7fb2974
commit
a747f6656f
2 changed files with 23 additions and 3 deletions
|
@ -10,9 +10,8 @@ module Util
|
|||
k_v_s = key_val_separator.strip
|
||||
|
||||
@@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/
|
||||
@@SETTING_REGEX = /^(\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*$/
|
||||
|
||||
@@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*$/
|
||||
|
||||
@path = path
|
||||
@key_val_separator = key_val_separator
|
||||
|
|
|
@ -262,4 +262,25 @@ EOS
|
|||
subject.get_value("Drive names", "C:").should eq 'Winchester'
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue