James Turnbull wrote:
> +task :todo do
> + Dir.glob('{lib,spec}/**/*.rb') do |file|
> + lastline = todo = comment = long_comment = false
> +
> + File.readlines(file).each_with_index do |line, lineno|
> + lineno += 1
> + comment = line =~ /^\s*?#.*?$/
> + long_comment = line =~ /^=begin/
> + long_comment = line =~ /^=end/
> + todo = true if line =~ /TODO|FIXME|THINK/ and (long_comment or comment)
> + todo = false if line.gsub('#', '').strip.empty?
> + todo = false unless comment or long_comment
> + if todo
> + unless lastline and lastline + 1 == lineno
> + puts
> + puts "vim #{file} +#{lineno}"
> + end
> +
> + l = line.strip.gsub(/^#\s*/, '')
> + print ' ' unless l =~ /^-/
> + puts l
> + lastline = lineno
> + end
> + end
> + end
> +end
I don't know how fast this runs, but perhaps git grep can do the job
nearly as well and a bit faster? Something like this:
git grep -A10 -E -e '^\s*#|^=(begin|end)' --and -e 'TODO|FIXME|THINK'
This is practically instant on my aging laptop. It doesn't open up
the editor for each file, but with 38 matches, I'm not sure I'd want
it to spawn a separate vim process for each match. :)
--
Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The future isn't what it used to be.
-- Arthur C. Clarke
pgplcfxedPQMk.pgp
Description: PGP signature
