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
|
# File 'lib/scrubber.rb', line 11
def scrub(data, splitter = /\n/)
lines = data.split(splitter)
while(line = lines.shift)
line.strip!
@config.matchers.each do |matcher, prok|
if match = line.match(matcher)
prok.call(line, *match.captures)
end
end
@config.between_matchers.each do |matcher, options|
if line =~ matcher
end_matcher, prok, conditions = options
next_line = nil
while(next_line = lines.shift) && (next_line !~ end_matcher)
if conditions[:when]
if match = next_line.match(conditions[:when])
prok.call(next_line, *match.captures)
end
else
prok.call(next_line)
end
end
end
end
end
end
|