From 6b198641ea97d20cd685e46736dcc6008946243a Mon Sep 17 00:00:00 2001 From: Chris Price Date: Tue, 21 May 2013 15:19:33 -0700 Subject: [PATCH 1/2] Change constants to class variables Because of the way that puppet's autoloader and pluginsync work, modules on the master get loaded twice, which means that you can't use Ruby constants at all w/o getting warning messages. This commit changes all of the constants in `ini_file` to class variables, which will avoid the warning messages. --- lib/puppet/util/ini_file.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb index b6927f9..340fe18 100644 --- a/lib/puppet/util/ini_file.rb +++ b/lib/puppet/util/ini_file.rb @@ -5,9 +5,9 @@ module Puppet module Util class IniFile - SECTION_REGEX = /^\s*\[([\w\d\.\\\/\-\:]+)\]\s*$/ - SETTING_REGEX = /^(\s*)([\w\d\.\\\/\-]+)(\s*=\s*)([\S\s]*\S)\s*$/ - COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([\w\d\.\\\/\-]+)(\s*=\s*)([\S\s]*\S)\s*$/ + @@SECTION_REGEX = /^\s*\[([\w\d\.\\\/\-\:]+)\]\s*$/ + @@SETTING_REGEX = /^(\s*)([\w\d\.\\\/\-]+)(\s*=\s*)([\S\s]*\S)\s*$/ + @@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)([\w\d\.\\\/\-]+)(\s*=\s*)([\S\s]*\S)\s*$/ def initialize(path, key_val_separator = ' = ') @path = path @@ -172,7 +172,7 @@ module Util line, line_num = line_iter.next while line - if (match = SECTION_REGEX.match(line)) + if (match = @@SECTION_REGEX.match(line)) section = read_section(match[1], line_num, line_iter) add_section(section) end @@ -186,9 +186,9 @@ module Util min_indentation = nil while true line, line_num = line_iter.peek - if (line_num.nil? or match = SECTION_REGEX.match(line)) + if (line_num.nil? or match = @@SECTION_REGEX.match(line)) return Section.new(name, start_line, end_line_num, settings, min_indentation) - elsif (match = SETTING_REGEX.match(line)) + elsif (match = @@SETTING_REGEX.match(line)) settings[match[2]] = match[4] indentation = match[1].length min_indentation = [indentation, min_indentation || indentation].min @@ -200,7 +200,7 @@ module Util def update_line(section, setting, value) (section.start_line..section.end_line).each do |line_num| - if (match = SETTING_REGEX.match(lines[line_num])) + if (match = @@SETTING_REGEX.match(lines[line_num])) if (match[2] == setting) lines[line_num] = "#{match[1]}#{match[2]}#{match[3]}#{value}" end @@ -210,7 +210,7 @@ module Util def remove_line(section, setting) (section.start_line..section.end_line).each do |line_num| - if (match = SETTING_REGEX.match(lines[line_num])) + if (match = @@SETTING_REGEX.match(lines[line_num])) if (match[2] == setting) lines.delete_at(line_num) end @@ -249,7 +249,7 @@ module Util def find_commented_setting(section, setting) return nil if section.is_new_section? (section.start_line..section.end_line).each do |line_num| - if (match = COMMENTED_SETTING_REGEX.match(lines[line_num])) + if (match = @@COMMENTED_SETTING_REGEX.match(lines[line_num])) if (match[3] == setting) return { :match => match, :line_num => line_num } end From 530b053f71c60837573899cd6a8b3c9ec13f7196 Mon Sep 17 00:00:00 2001 From: Chris Price Date: Tue, 21 May 2013 15:28:42 -0700 Subject: [PATCH 2/2] Update Modulefile and CHANGELOG for 0.10.1 release --- CHANGELOG | 12 ++++++++++++ Modulefile | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 50884bc..b2cc726 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,15 @@ +2013-05-21 - Chris Price + * Change constants to class variables to avoid ruby warnings (6b19864) + +2013-04-10 - Erik Dalén + * Style fixes (c4af8c3) + +2013-04-02 - Dan Bode + * Add travisfile and Gemfile (c2052b3) + +2013-04-02 - Chris Price + * Update README.markdown (ad38a08) + 2013-02-15 - Karel Brezina - 0.10.0 * Added 'ini_subsetting' custom resource type (4351d8b) diff --git a/Modulefile b/Modulefile index 883dbe7..a255fcb 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'cprice404-inifile' -version '0.10.0' +version '0.10.1' source 'git://github.com/cprice-puppet/puppetlabs-inifile.git' author 'Chris Price' description 'Resource types for managing settings in INI files'