Gem::Ag
Quickly search through all the code in your installed gems using ag
.
RubyGems plugin to search with The Silver Searcher, this was inspired by Jim Gay's Searching Through Your Bundled Gems blog post.
Installation
Install it with rubygems:
$ gem install gem-ag
Or to include it with your app add this line to your application's Gemfile:
gem 'gem-ag'
And then execute:
$ bundle
Usage
The gem ag
command attempts to support all the same command line options as ag
out of the box. The big difference is you cannot specify paths to search. Instead you can pass in a list of gem names.
$ gem ag PATTERN [GEMNAME ...] [options]
To see a full list of supported options run:
$ gem help ag
Examples
Search for "Hello World" in Rails and Active Record gems.
$ gem ag "Hello World" rails active-record
Search for "def" in the rake gem, and print ag stats.
$ gem ag --stats "def" rake
Search in all installed gems:
$ gem ag "Hello World"
By using bundle exec
you can search only in the gems in yoru bundle. This does require you to include it in your application's Gemfile
.
Search in all bundled gems:
$ bundle exec gem ag "Hello World"
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
), with a nice commit message. - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request