Merge pull request #44 from cprice-puppet/maint/master/change-constants-to-class-vars
Maint/master/change constants to class vars
This commit is contained in:
commit
f46fe29fad
3 changed files with 22 additions and 10 deletions
12
CHANGELOG
12
CHANGELOG
|
@ -1,3 +1,15 @@
|
|||
2013-05-21 - Chris Price <chris@puppetlabs.com>
|
||||
* Change constants to class variables to avoid ruby warnings (6b19864)
|
||||
|
||||
2013-04-10 - Erik Dalén <dalen@spotify.com>
|
||||
* Style fixes (c4af8c3)
|
||||
|
||||
2013-04-02 - Dan Bode <dan@puppetlabs.com>
|
||||
* Add travisfile and Gemfile (c2052b3)
|
||||
|
||||
2013-04-02 - Chris Price <chris@puppetlabs.com>
|
||||
* Update README.markdown (ad38a08)
|
||||
|
||||
2013-02-15 - Karel Brezina <karel.brezina@gmail.com> - 0.10.0
|
||||
* Added 'ini_subsetting' custom resource type (4351d8b)
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue