Module: Lab419::Config::Parser

Included in:
Reader
Defined in:
lib/lab419/config/parser.rb

Constant Summary collapse

SyntaxError =
Class::new RuntimeError

Instance Method Summary collapse

Instance Method Details

#parse(params = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lab419/config/parser.rb', line 10

def parse params={}
  check_source_setup
  @params = params
  @parsed = true
  loop do
    @source.next while @source.current && @source.current =~ comment
    return self if @source.eos?
    key, value = @source.current.split separator_rgx, 2
    raise SyntaxError, "No = found in line \"#{key}\"" unless value
    @config[key.strip] = parse_value value, params
    @source.next
  end
end