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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/mentawai/util/properties.rb', line 7
def self.load(filename)
return nil if not File.exists?(filename)
properties = {}
value = key = ''
multiline = false
File.open(filename, 'r') do |file|
file.each do |line|
= line =~ /\\ +\n?$/
line.strip!
line.chop! if
if multiline then
value += "\n" + line
value += " " if
if value =~ /\\$/ then
value.chop!
next
else
multiline = false
end
else
next if line =~ /^\#/ || line == ''
index = line.index('=')
next if not index
key = line[0..index - 1].strip
value = line[index + 1..-1].strip
value += " " if
end
if value =~ /\\$/ then
multiline = true
value.chop!
next
end
properties[key] = value
end
end
properties
end
|