4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/dansguardian/parser.rb', line 4
def self.read(io)
h = {}
may_appear_multiple_times = [
:downloadmanager, :contentscanner, :authplugin]
io.each_line do |line|
line.sub! /#.*$/, ''
line.strip!
match = false
case line
when /^([^=\s]+)\s*=\s*([^=\s']*)$/
key = $1.to_sym
value = $2
match = true
when /^([^=\s]+)\s*=\s*'(.*)'$/
key = $1.to_sym
value = $2.gsub(/\\'/, "'")
match = true
end
if match
if may_appear_multiple_times.include? key
h[key] ||= []
h[key] << value
else
h[key] = value
end
end
end
return h
end
|