Skip to content

Commit

Permalink
Merge pull request redhat-openstack#134 from johnsyweb/less-restricti…
Browse files Browse the repository at this point in the history
…ve-setting-names

Less restrictive setting names
  • Loading branch information
hunner committed Nov 20, 2014
2 parents 792d35c + 3e46c13 commit 19ddca4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/util/ini_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module Util
class IniFile

@@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/
@@SETTING_REGEX = /^(\s*)([\w\d\.\\\/\-\s\[\]\']*[\w\d\.\\\/\-\]])([ \t]*=[ \t]*)([\S\s]*?)\s*$/
@@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([\w\d\.\\\/\-\s\[\]\']*[\w\d\.\\\/\-\]])([ \t]*=[ \t]*)([\S\s]*?)\s*$/
@@SETTING_REGEX = /^(\s*)([^\s=]*)(\s*=\s*)(.*)\s*$/
@@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([^\s=]*)(\s*=[ \t]*)(.*)\s*$/

def initialize(path, key_val_separator = ' = ')
@path = path
Expand Down
35 changes: 35 additions & 0 deletions spec/unit/puppet/util/ini_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,39 @@
]
end
end

context 'KDE Configuration with braces in setting names' do
let(:sample_content) do
template = <<-EOS
[khotkeys]
_k_friendly_name=khotkeys
{5465e8c7-d608-4493-a48f-b99d99fdb508}=Print,none,PrintScreen
{d03619b6-9b3c-48cc-9d9c-a2aadb485550}=Search,none,Search
EOS
template.split("\n")
end

it "should expose settings for sections" do
subject.get_value("khotkeys", "{5465e8c7-d608-4493-a48f-b99d99fdb508}").should == "Print,none,PrintScreen"
subject.get_value("khotkeys", "{d03619b6-9b3c-48cc-9d9c-a2aadb485550}").should == "Search,none,Search"
end
end

context 'Configuration with colons in setting names' do
let(:sample_content) do
template = <<-EOS
[Drive names]
A:=5.25" Floppy
B:=3.5" Floppy
C:=Winchester
EOS
template.split("\n")
end

it "should expose settings for sections" do
subject.get_value("Drive names", "A:").should eq '5.25" Floppy'
subject.get_value("Drive names", "B:").should eq '3.5" Floppy'
subject.get_value("Drive names", "C:").should eq 'Winchester'
end
end
end

0 comments on commit 19ddca4

Please sign in to comment.