Finding files with tiny fruit

I had to rename a bunch of variables in my current project and I wanted to know which files needed adjusting. Problem is, I’m on Windows, and searching for anything in Windows blows really hard. Even Google Desktop with the any-text-file-indexer wasn’t as helpful as I’d like. So, I wrote this tiny tiny plugin that gives you a command line search for your Rails project.

ruby script/plugin install

http://svn.jcoglan.com/grape/trunk/grape

Because rake + grep = grape. I know, I’m brilliant, I know. Now I can regexp-search my whole Rails project from the command line:

rake grape q="chunky bacon"

It’s case-insensitive by default, but you can change that by tacking cs= at the end. Grape will then tell you how many files match, and list them with line numbers of matching lines. It searches Ruby files, (R)HTML, (R)XML, RJS and JavaScript files, CSS, ERB, rakefiles, YAML, SQL, plain text, (f)cgi and htaccess. If I’ve left anything off the list don’t hesitate to tell me.

If you've enjoyed this article, you might enjoy my recently published book JavaScript Testing Recipes. It's full of simple techniques for writing modular, maintainable JavaScript apps in the browser and on the server.