# $Id$ # $URL$ require 'strscan' desc "Print all of the the TODOs" task :todos do tests = %w( app test lib components config ).inject([]) do |paths, dir| paths + FileList["./#{dir}/**/*.rb"] end tests.each do |file| ss = StringScanner.new(File::read(file)) todos = [] while true s = ss.scan_until(/.*?# ?TODO:/) break if ss.eos? or s.nil? s = ss.scan_until(/\n/) unless s.nil? string_before_todo = ss.string.slice(0,ss.pos()) line_number = string_before_todo.split("\n").length if s.strip.empty? # Find method name last_method = string_before_todo.split("\n").select { |l| l =~ /def /}.last todos << "#{line_number}: implement " + last_method.match(/def (.*)/)[1] else todos << "#{line_number}: " + s.strip end end break if ss.eos? end unless todos.empty? puts "TODOS for #{file}:" todos.each { |t| puts " - " + t } puts "\n" end end end