My little Rails project source code search plugin, Grape, now includes the ability to display search results in context with their surrounding source code, rather than just listing matching file paths. Par example:
>rake grape q=Initializer
Found 3 files matching your search.
- /config/boot.rb : 14, 16, 30, 40, 44
- /config/environment.rb : 13
- /public/javascripts/prototype.js : 1639, 1657, 1670, 1684, 1698
>rake grape q=Initializer v=
Found 11 matches for your search.
1. /config/boot.rb
12. end
13.
14. unless defined?(Rails::Initializer)
15. if File.directory?("#{RAILS_ROOT}/vendor/rails")
16. require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
2. /config/boot.rb
14. unless defined?(Rails::Initializer)
15. if File.directory?("#{RAILS_ROOT}/vendor/rails")
16. require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
17. else
18. require 'rubygems'
3. /config/boot.rb
28. if rails_gem
29. gem "rails", "=#{rails_gem.version.version}"
30. require rails_gem.full_gem_path + '/lib/initializer'
31. else
32. STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
...
The v=
is short for ‘verbose’, doncherknow. If you give v
an actual value,
say v=4
, then Grape will print 4 lines of code above and below each match it
finds. Install away:
ruby script/plugin install
http://svn.jcoglan.com/grape/trunk/grape