3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/codetip/app.rb', line 3
def parse(path, restrict = '*', user = nil)
result = {}
Dir.glob(path + '/**/' + restrict) do |filename|
if File.file?(filename)
= {}
lineNumber = 1
File.readlines(filename).each do |line|
if line.match(/\[(todo|warning|review|suggestion)\](\s*[:-]+\s*(.+))$/i)
type = $1.downcase
message = $3
next if (!user.nil? && !line.downcase.match(Regexp.new('@('+user.downcase + '|all)')))
([type] ||= []) << {
:line => lineNumber,
:message => message
}
end
lineNumber += 1
end
if (.count > 0)
result[filename] =
end
end
end
return result
end
|