From d98e9bcb778834f249ad591d82156adb578c2939 Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Sat, 8 Nov 2014 17:05:59 +1100 Subject: [PATCH 1/5] Add failing spec for KDE Configuration with braces in setting names Refer https://github.com/puppetlabs/puppetlabs-inifile/pull/131 --- spec/unit/puppet/util/ini_file_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/unit/puppet/util/ini_file_spec.rb b/spec/unit/puppet/util/ini_file_spec.rb index dca6dab21..5e333bb55 100644 --- a/spec/unit/puppet/util/ini_file_spec.rb +++ b/spec/unit/puppet/util/ini_file_spec.rb @@ -227,4 +227,21 @@ ] 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 end From e65be6fb4b8ccbc648e0b32d1c14515dcc19baa5 Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Sat, 8 Nov 2014 17:07:01 +1100 Subject: [PATCH 2/5] Simplify SECTION_REGEX --- lib/puppet/util/ini_file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb index a8d715c49..1ba0805a5 100644 --- a/lib/puppet/util/ini_file.rb +++ b/lib/puppet/util/ini_file.rb @@ -6,7 +6,7 @@ module Util class IniFile @@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/ - @@SETTING_REGEX = /^(\s*)([\w\d\.\\\/\-\s\[\]\']*[\w\d\.\\\/\-\]])([ \t]*=[ \t]*)([\S\s]*?)\s*$/ + @@SETTING_REGEX = /^(\s*)([^\s=]*)(\s*=\s*)(.*)\s*$/ @@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([\w\d\.\\\/\-\s\[\]\']*[\w\d\.\\\/\-\]])([ \t]*=[ \t]*)([\S\s]*?)\s*$/ def initialize(path, key_val_separator = ' = ') From c6dcad26573f55d8a3d27c4650292523623f62be Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Sat, 8 Nov 2014 17:55:13 +1100 Subject: [PATCH 3/5] Simplify COMMENTED_SETTING_REGEX to match SETTING_REGEX --- lib/puppet/util/ini_file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb index 1ba0805a5..a5cefa763 100644 --- a/lib/puppet/util/ini_file.rb +++ b/lib/puppet/util/ini_file.rb @@ -7,7 +7,7 @@ class IniFile @@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/ @@SETTING_REGEX = /^(\s*)([^\s=]*)(\s*=\s*)(.*)\s*$/ - @@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([\w\d\.\\\/\-\s\[\]\']*[\w\d\.\\\/\-\]])([ \t]*=[ \t]*)([\S\s]*?)\s*$/ + @@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([^\s=]*)(\s*=[ \t]*)(.*)\s*$/ def initialize(path, key_val_separator = ' = ') @path = path From efeb174427a8df0aa16dce9f43636567b8a8327a Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Sat, 8 Nov 2014 18:47:08 +1100 Subject: [PATCH 4/5] Add spec for #123 I may have made this configuration file up --- spec/unit/puppet/util/ini_file_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/unit/puppet/util/ini_file_spec.rb b/spec/unit/puppet/util/ini_file_spec.rb index 5e333bb55..0c0ad216a 100644 --- a/spec/unit/puppet/util/ini_file_spec.rb +++ b/spec/unit/puppet/util/ini_file_spec.rb @@ -244,4 +244,22 @@ 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¼" Floppy +B:=3½" Floppy +C:=Winchester +EOS + template.split("\n") + end + + it "should expose settings for sections" do + subject.get_value("Drive names", "A:").should eq '5¼" Floppy' + subject.get_value("Drive names", "B:").should eq '3½" Floppy' + subject.get_value("Drive names", "C:").should eq 'Winchester' + end + end end From 3e46c13dc24b8d71e95595210885ee1a6a3788cb Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Sat, 8 Nov 2014 18:52:20 +1100 Subject: [PATCH 5/5] Fix Ruby 1.9.3 build --- spec/unit/puppet/util/ini_file_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/unit/puppet/util/ini_file_spec.rb b/spec/unit/puppet/util/ini_file_spec.rb index 0c0ad216a..41b3cebc1 100644 --- a/spec/unit/puppet/util/ini_file_spec.rb +++ b/spec/unit/puppet/util/ini_file_spec.rb @@ -249,16 +249,16 @@ let(:sample_content) do template = <<-EOS [Drive names] -A:=5¼" Floppy -B:=3½" Floppy +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¼" Floppy' - subject.get_value("Drive names", "B:").should eq '3½" Floppy' + 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