diff options
author | Chris Price <chris@puppetlabs.com> | 2012-08-14 13:48:57 -0700 |
---|---|---|
committer | Chris Price <chris@puppetlabs.com> | 2012-08-14 13:48:57 -0700 |
commit | 1740608847714d5a1e500df20ba2df0ffdc07240 (patch) | |
tree | c595fff1d891d4660639448a832cf109c71f0f98 /lib/puppet/util/ini_file.rb | |
parent | e2954b26c191055fb084162a31d63058677d3026 (diff) | |
parent | 8d2a8c859d928700350d48965dcf01d279289393 (diff) | |
download | puppet-inifile-1740608847714d5a1e500df20ba2df0ffdc07240.tar.gz puppet-inifile-1740608847714d5a1e500df20ba2df0ffdc07240.tar.bz2 |
Merge pull request #4 from stephenrjohnson/miscfixes
Updated Section/ Setting regex, fixed bug with empty files and updated provider to not care about variable type
Diffstat (limited to 'lib/puppet/util/ini_file.rb')
-rw-r--r-- | lib/puppet/util/ini_file.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb index 51dfda7..b951b3f 100644 --- a/lib/puppet/util/ini_file.rb +++ b/lib/puppet/util/ini_file.rb @@ -5,14 +5,13 @@ module Puppet module Util class IniFile - SECTION_REGEX = /^\s*\[([\w\d\.]+)\]\s*$/ - SETTING_REGEX = /^\s*([\w\d\.]+)\s*=\s*([\w\d\.]+)\s*$/ + SECTION_REGEX = /^\s*\[([\w\d\.\\\/\-]+)\]\s*$/ + SETTING_REGEX = /^\s*([\w\d\.\\\/\-]+)\s*=\s*([\S]+)\s*$/ def initialize(path) @path = path @section_names = [] @sections_hash = {} - parse_file end @@ -43,7 +42,8 @@ module Util def save File.open(@path, 'w') do |fh| first_section = @sections_hash[@section_names[0]] - (0..first_section.start_line - 1).each do |line_num| + first_section.start_line == nil ? start_line = 0 : start_line = first_section.start_line + (0..start_line - 1).each do |line_num| fh.puts(lines[line_num]) end @@ -93,7 +93,6 @@ module Util elsif (match = SETTING_REGEX.match(line)) settings[match[1]] = match[2] end - line_iter.next end end @@ -129,4 +128,4 @@ module Util end end -end +end
\ No newline at end of file |