diff options
author | Chris Price <chris@puppetlabs.com> | 2012-10-20 00:08:06 -0700 |
---|---|---|
committer | Chris Price <chris@puppetlabs.com> | 2012-10-20 00:08:06 -0700 |
commit | c2c26de9b10c3675e1044d5571e47e195a5d0167 (patch) | |
tree | 873024609da221f418b3acf642cd8ac75de2b3c8 /lib/puppet/util/ini_file | |
parent | a5eebcfca0c1c8e8fb8130205a6ec623c8691326 (diff) | |
download | puppet-inifile-c2c26de9b10c3675e1044d5571e47e195a5d0167.tar.gz puppet-inifile-c2c26de9b10c3675e1044d5571e47e195a5d0167.tar.bz2 |
Respect indentation / spacing for existing sections and settings
This commit adds some cosmetic functionality. The main two
improvements are:
* We'll now pay attention to indentation within existing
sections, and when we write new settings or update
existing ones, we'll match the existing indentation.
* When modifying existing settings, the regex now captures
a greater portion of the original line and preserves it.
Basically, the original whitespacing in the line should
remain intact and only the value should be modified.
Diffstat (limited to 'lib/puppet/util/ini_file')
-rw-r--r-- | lib/puppet/util/ini_file/section.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/puppet/util/ini_file/section.rb b/lib/puppet/util/ini_file/section.rb index 16f19d3..c565872 100644 --- a/lib/puppet/util/ini_file/section.rb +++ b/lib/puppet/util/ini_file/section.rb @@ -2,15 +2,16 @@ module Puppet module Util class IniFile class Section - def initialize(name, start_line, end_line, settings) + def initialize(name, start_line, end_line, settings, indentation) @name = name @start_line = start_line @end_line = end_line @existing_settings = settings.nil? ? {} : settings @additional_settings = {} + @indentation = indentation end - attr_reader :name, :start_line, :end_line, :additional_settings + attr_reader :name, :start_line, :end_line, :additional_settings, :indentation def get_value(setting_name) @existing_settings[setting_name] || @additional_settings[setting_name] |