Method: Puppet::Settings::IniFile.parse

Defined in:
lib/puppet/settings/ini_file.rb

.parse(config_fh) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/puppet/settings/ini_file.rb', line 14

def self.parse(config_fh)
  config = new([DefaultSection.new])
  config_fh.each_line do |line|
    case line.chomp
    when /^(\s*)\[([[:word:]]+)\](\s*)$/
      config.append(SectionLine.new(::Regexp.last_match(1), ::Regexp.last_match(2), ::Regexp.last_match(3)))
    when /^(\s*)([[:word:]]+)(\s*=\s*)(.*?)(\s*)$/
      config.append(SettingLine.new(::Regexp.last_match(1), ::Regexp.last_match(2), ::Regexp.last_match(3), ::Regexp.last_match(4), ::Regexp.last_match(5)))
    else
      config.append(Line.new(line))
    end
  end

  config
end