From 681f5c0cb46cba66c0cae4d60524848eebda5c4b Mon Sep 17 00:00:00 2001 From: Huan Do Date: Mon, 8 Sep 2014 23:12:09 -0700 Subject: [PATCH] fix issue where single characters settings were not being saved. see https://github.com/boxen/puppet-git/issues/30 --- lib/puppet/util/ini_file.rb | 2 +- spec/unit/puppet/util/ini_file_spec.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb index 39775a5..bc2ce54 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*)([\w\d\.\\\/\-\s\[\]\']*[\w\d\.\\\/\-\]])([ \t]*=[ \t]*)([\S\s]*?)\s*$/ @@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([^\[]*[\w\d\.\\\/\-]+[\w\d\.\\\/\-\[\]\']+)([ \t]*=[ \t]*)([\S\s]*?)\s*$/ def initialize(path, key_val_separator = ' = ') diff --git a/spec/unit/puppet/util/ini_file_spec.rb b/spec/unit/puppet/util/ini_file_spec.rb index 8e8da9c..b68fb09 100644 --- a/spec/unit/puppet/util/ini_file_spec.rb +++ b/spec/unit/puppet/util/ini_file_spec.rb @@ -30,6 +30,7 @@ baz=bazvalue ; yet another comment zot = multi word value xyzzy['thing1']['thing2']=xyzzyvalue + l=git log EOS template.split("\n") } @@ -52,6 +53,7 @@ baz=bazvalue subject.get_value("section2", "baz").should == "bazvalue" subject.get_value("section2", "zot").should == "multi word value" subject.get_value("section2", "xyzzy['thing1']['thing2']").should == "xyzzyvalue" + subject.get_value("section2", "l").should == "git log" end end