diff options
author | Chris Price <chris@puppetlabs.com> | 2012-09-20 12:53:59 -0700 |
---|---|---|
committer | Chris Price <chris@puppetlabs.com> | 2012-09-20 12:53:59 -0700 |
commit | 4ff4995d9efa15504eaf33e27385b5e2c4092087 (patch) | |
tree | 363d5bd285f3f03e113b08b1deae5eac45eb98da /lib/puppet/util/ini_file.rb | |
parent | 310a4b1575f7af903ac97108c6f1352d05f5f3fc (diff) | |
parent | e527908b7c6ac5d91677229a96d5a97194dc68b7 (diff) | |
download | puppet-inifile-4ff4995d9efa15504eaf33e27385b5e2c4092087.tar.gz puppet-inifile-4ff4995d9efa15504eaf33e27385b5e2c4092087.tar.bz2 |
Merge pull request #9 from cprice-puppet/feature/master/allow-override-of-separator-str
Allow overriding separator string between key/val pairs
Diffstat (limited to 'lib/puppet/util/ini_file.rb')
-rw-r--r-- | lib/puppet/util/ini_file.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb index 4fe4169..36bc8a6 100644 --- a/lib/puppet/util/ini_file.rb +++ b/lib/puppet/util/ini_file.rb @@ -8,8 +8,9 @@ module Util SECTION_REGEX = /^\s*\[([\w\d\.\\\/\-\:]+)\]\s*$/ SETTING_REGEX = /^\s*([\w\d\.\\\/\-]+)\s*=\s*([\S]+)\s*$/ - def initialize(path) + def initialize(path, key_val_separator = ' = ') @path = path + @key_val_separator = key_val_separator @section_names = [] @sections_hash = {} if File.file?(@path) @@ -56,7 +57,7 @@ module Util end section.additional_settings.each_pair do |key, value| - fh.puts("#{key} = #{value}") + fh.puts("#{key}#{@key_val_separator}#{value}") end end end @@ -106,7 +107,7 @@ module Util (section.start_line..section.end_line).each do |line_num| if (match = SETTING_REGEX.match(lines[line_num])) if (match[1] == setting) - lines[line_num] = "#{setting} = #{value}" + lines[line_num] = "#{setting}#{@key_val_separator}#{value}" end end end |