Grape

Installation

script/plugin install
    http://svn.jcoglan.com/grape/trunk/grape

Grape is a small plugin that aims to provide grep-like functionality to Rails projects. It‘s what you get if you mash the words rake and grep together. Its author spends too much time on Windows machines and needs to search his .rb files without opening all of them at once in Notepad++. Usage is simple:

  rake grape q="your phrase here"

where you should replace "your phrase here" with the regexp you want to search with. You don‘t need to use delimiters (apart from quote marks if your string includes spaces) and searches are case-insensitive by default. ^ and $ match the beginning and end of a line. To get case-sensitive matching, add cs=:

  rake grape q=CamelCasePhrase cs=

Grape will tell you how many files it found and list them alphabetically, with line numbers of lines that match. It is set to look inside files with extensions:

  %w(rb rhtml rxml rjs erb haml builder rake yml yaml sql html htm xml js css txt cgi fcgi htaccess)

If you want more detail, you can ask Grape to display source code from the lines surrounding any matches it finds. To do this, just add the ‘verbose’ flag:

  rake grape q="chunky bacon" v=

You can assign a value to v, which will tell Grape how many lines of code you want to see either side of each result. Leaving v unassigned will cause Grape to print 2 lines either side (5 lines total) for each result it finds.

License

Copyright (c) 2007 James Coglan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.