48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/td/config.rb', line 48
def read(path=@path)
@path = path
begin
data = File.read(@path)
rescue
e = ConfigNotFoundError.new($!.to_s)
e.set_backtrace($!.backtrace)
raise e
end
section = ""
data.each_line {|line|
line.strip!
case line
when /^#/
next
when /\[(.+)\]/
section = $~[1]
when /^(\w+)\s*=\s*(.+?)\s*$/
key = $~[1]
val = $~[2]
@conf["#{section}.#{key}"] = val
else
raise ConfigParseError, "invalid config line '#{line}' at #{@path}"
end
}
self
end
|