class Puppet::Settings::ConfigFile

@api private

Parses puppet configuration files

Constants

ALLOWED_SECTION_NAMES
Conf
Meta
NO_META
Section
Setting

Public Instance Methods

parse_file(file, text) click to toggle source
# File lib/puppet/settings/config_file.rb, line 19
def parse_file(file, text)
  result = Conf.new

  ini = Puppet::Settings::IniFile.parse(StringIO.new(text))
  unique_sections_in(ini, file).each do |section_name|
    section = Section.new(section_name.to_sym)
    result.with_section(section)

    ini.lines_in(section_name).each do |line|
      if line.is_a?(Puppet::Settings::IniFile::SettingLine)
        parse_setting(line, section)
      elsif line.text !~ /^\s*#|^\s*$/
        raise Puppet::Settings::ParseError.new("Could not match line #{line.text}", file, line.line_number)
      end
    end
  end

  result
end

Public Class Methods

new(value_converter) click to toggle source

@param value_converter [Proc] a function that will convert strings into ruby types

# File lib/puppet/settings/config_file.rb, line 15
def initialize(value_converter)
  @value_converter = value_converter
end