[ap4r-devel] [364] trunk/ap4r/Rakefile: Change: create a namespace "todos" for tasks to list TODOs
shino at rubyforge.org
shino at rubyforge.org
Thu Jan 10 23:21:39 EST 2008
Revision: 364
Author: shino
Date: 2008-01-10 23:21:38 -0500 (Thu, 10 Jan 2008)
Log Message:
-----------
Change: create a namespace "todos" for tasks to list TODOs
Add: tasks which list todos under rails_plugin/ and spec/
Modified Paths:
--------------
trunk/ap4r/Rakefile
Modified: trunk/ap4r/Rakefile
===================================================================
--- trunk/ap4r/Rakefile 2008-01-11 02:33:16 UTC (rev 363)
+++ trunk/ap4r/Rakefile 2008-01-11 04:21:38 UTC (rev 364)
@@ -163,26 +163,40 @@
end
end
-desc "List TODO comments in files"
-task :todos => "release:copy_plugin" do
- todo_pattern = /#\s*TODO\s*:?\s*(.*)\s(\d{4}\/\d{2}\/\d{2})\s*,?(?:by)?\s*(\S+)/i
- Pathname.glob("lib/**/*") do |file|
- next unless file.file?
+todos_dirs = %w(lib rails_plugin spec)
- line_no = 0
- first_time = true
- file.each_line do |line|
- line_no += 1
- m = todo_pattern.match(line)
- if m
+desc "List TODO comments in #{todos_dirs.join(", ")} directories"
+task :todos => todos_dirs.map{ |dir| "todos:#{dir}" }
+
+namespace :todos do
+ todos_dirs.each do |dir|
+ desc "List TODO comments in #{dir} directory"
+ task dir => "release:copy_plugin" do
+ print_todos(dir)
+ end
+ end
+
+ def print_todos(dir)
+ todo_pattern = /#\s*TODO\s*:?\s*(.*)\s(\d{4}\/\d{2}\/\d{2})\s*,?(?:by)?\s*(\S+)/i
+ exclude_file_patterns = [/~$/, /^#/]
+ Pathname.glob("#{dir}/**/*") do |file|
+ next unless file.file?
+ next if exclude_file_patterns.any? { |p| file.to_s =~ p }
+
+ line_no = 0
+ first_time = true
+ file.each_line do |line|
+ line_no += 1
+ next unless todo_pattern.match(line)
+
if first_time
puts file
first_time = false
end
- puts "L.#{"%4d" % line_no}: #{m[1]} -- #{m[2].strip} by #{m[3].strip}"
+ puts "L.#{"%4d" % line_no}: #{$1} -- #{$2.strip} by #{$3.strip}"
end
+ puts unless first_time
end
- puts unless first_time
end
-
+
end
More information about the ap4r-devel
mailing list