53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/metric_fu/flog.rb', line 53
def parse(text)
score = text[/\w+ = (\d+\.\d+)/, 1]
return nil unless score
page = Page.new(score)
text.each_line do |method_line|
if match = method_line.match(METHOD_LINE_REGEX)
page.scanned_methods << ScannedMethod.new(match[1], match[2])
end
if match = method_line.match(OPERATOR_LINE_REGEX)
return if page.scanned_methods.empty?
page.scanned_methods.last.operators << Operator.new(match[1], match[2])
end
end
page
end
|