From 713d8a092b2516fe934e00258ce4399c48f30051 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 22 Jul 2014 16:38:05 +0200 Subject: [PATCH] Rake task for displaying TODO/FIXME notes. --- task/todo.rake | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 task/todo.rake diff --git a/task/todo.rake b/task/todo.rake new file mode 100644 index 0000000..3b12fad --- /dev/null +++ b/task/todo.rake @@ -0,0 +1,25 @@ +desc 'Extracts TODO tags and the likes' +task :todo do + pattern = /(NOTE|FIXME|TODO|THINK|@todo)(.+)/ + found = Hash.new { |hash, key| hash[key] = [] } + + Dir.glob('lib/**/*.{rb,rl,y}').each do |file| + File.open(file, 'r') do |handle| + handle.each_line.each_with_index do |line, index| + if line =~ pattern + found[file] << [index + 1, $1 + $2] + end + end + end + end + + found.each do |file, notes| + puts file + + notes.each do |(nr, line)| + puts "#{nr}: #{line}" + end + + puts + end +end