22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/header_detector.rb', line 22
def HeaderDetector.detect(path, template, )
template_lines = Comment.(template, ).lines("\n")
template_regexp_lines = template_lines.map do |line|
TemplateUtils.create_detection_regexp_for_line(line)
end
= 0
matches = []
File.open(path, "r").each do |line|
match = template_regexp_lines[matches.length].match(line)
if match
matches << match
if matches.length == template_regexp_lines.length
return {
start: ,
matches: matches
}
end
else
+= matches.length + 1
matches = []
end
end
nil
end
|