-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
48 lines (40 loc) · 1020 Bytes
/
Rakefile
1
2
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require "bundler/gem_tasks"
begin
require "rspec/core/rake_task"
desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.rspec_opts = %w(-fp --color)
t.ruby_opts = %w(-w)
end
rescue LoadError
puts "You must run `bundle` to install development dependencies."
end
desc "List TODOs"
task :todo do
dirs = %w(lib spec)
lines = {}
dirs.each do |dir|
Dir["#{dir}/**/*"].each do |path|
if File.directory? path
next
elsif path =~ /.*\.rb$/
line_num = 0
File.readlines(path).each do |line|
line_num += 1
next unless line =~ /TODO/
unless lines.fetch(path, nil)
lines[path] = []
end
lines[path] = lines[path] + [{ :number => line_num, :line => line }]
end
end
end
end
lines.each do |path, matches|
puts "#{path}:"
matches.each do |match|
sanitized = match[:line].gsub(/(^.*TODO)/, "").strip
puts " * TODO L#{match[:number]}: #{sanitized}"
end
end
end