summaryrefslogtreecommitdiff
path: root/lib/puppet/util/ini_file/section.rb
diff options
context:
space:
mode:
authorChris Price <chris@puppetlabs.com>2012-10-26 17:27:28 -0700
committerChris Price <chris@puppetlabs.com>2012-10-26 17:27:28 -0700
commit85afa277bcbe14ff9c56719268bfd6fc2508b086 (patch)
tree8fec4645f400965c3402df673c7276d2ed012e6f /lib/puppet/util/ini_file/section.rb
parent8a0d1fa1f289a5f1fc3f72cd0ebb3c52e923d024 (diff)
parenta45ab6593035cfbbd4cbcb535a8b8324b212ef4e (diff)
downloadpuppet-inifile-85afa277bcbe14ff9c56719268bfd6fc2508b086.tar.gz
puppet-inifile-85afa277bcbe14ff9c56719268bfd6fc2508b086.tar.bz2
Merge pull request #20 from cprice-puppet/feature/master/detect-commented-settings
Add detection for commented versions of settings
Diffstat (limited to 'lib/puppet/util/ini_file/section.rb')
-rw-r--r--lib/puppet/util/ini_file/section.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/puppet/util/ini_file/section.rb b/lib/puppet/util/ini_file/section.rb
index d7ff159..ba1a783 100644
--- a/lib/puppet/util/ini_file/section.rb
+++ b/lib/puppet/util/ini_file/section.rb
@@ -52,6 +52,19 @@ class IniFile
end
end
+ # This is a hacky method; it's basically called when we need to insert
+ # a new setting but we don't want it to appear at the very end of the
+ # section. Instead we hack it into the existing settings list and
+ # increment our end_line number--this assumes that the caller (`ini_file`)
+ # is doing some babysitting w/rt the other sections and the actual data
+ # of the lines.
+ def insert_inline_setting(setting_name, value)
+ @existing_settings[setting_name] = value
+ if @end_line
+ @end_line = @end_line + 1
+ end
+ end
+
def set_additional_setting(setting_name, value)
@additional_settings[setting_name] = value
end
@@ -68,6 +81,18 @@ class IniFile
end
end
+ # Increment the start and end line numbers for the section (if they are
+ # defined); this is intended to be called when an inline setting is added
+ # to a section that comes before this section in the ini file.
+ def increment_line_nums()
+ if @start_line
+ @start_line = @start_line + 1
+ end
+ if @end_line
+ @end_line = @end_line + 1
+ end
+ end
+
end
end
end