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
|
# File 'lib/ar/parser.rb', line 7
def parse( str )
, body = {}, []
, body_start = true, false
str.lines.each_with_index do |line, idx|
if and not body_start
if line =~ /^\s*$/
if idx == 0
= false
body << line
else
body_start = true
body = []
end
else
body << line
name, value = (line)
if name
[name] = value
else
= false
end
end
else
body << line
end
end
= nil unless and body_start
res_body = body.join
[, res_body]
end
|