Have you ever wondered if you can search a piece of ruby codes inside all your gigantic macbook pro storage?

For example, you might want to search one of your codes that contains this code module AdpointDir

How would you do that? From a command line? Yes, that’s one option. Another option is: Ruby Importer

What I do to search that code on my 13″ Macbook Pro is just press Apple Command + Space to invoke Spotlight on the top right of my Mac OS X 10.5.8 Leopard Desktop. Then just type there module AdpointDir.

That’s one way to reach the file. Another way is using mdfind “module AdpointDir”.

This spotlight is really a must for a Serious Rubyist on Leopard! As we know since Leopard, we really rely on Spotlight, I even don’t need to have “QuickSilver” anymore to call my apps quickly because it’s been already indexed well on spotlight, anyway.

What I did to have this was after downloading the plugin from here I placed RubyImporter.mdimporter file to my ~/Library/Spotlight, there wasn’t Spotlight directory over there, I just created it by myself.

Then I opened my Terminal, go to that directory ~/Library/Sportlight/ and typed mdimport -L | grep Ruby and I saw RubyImporter on the list!

So what I did after that was tell my mac to re-index all Ruby files with this command:

mdimport -r ~/Library/Spotlight/RubyImporter.mdimporter

Then, welcome to the heaven! So whenever I need to search my ruby codes, Apple Command + Space + “class Twitter” for example, et voila! ;-)

Notes: I wrote this blog post intentionally because I wasn’t clear enough of README from RubyImporter. I hope this write-up makes me (and my ruby fellows around me) more clear. When I need to search my piece of codes in a smaller, more reasonable environments, for example inside one of Rails or Ruby projects, {1} I can just enter ViM, then type :vimgrep /regexp/ . to get what I want. Or, {2} do Apple Command + Shift + F to search my piece of code in my whole ruby projects that I opened using my Textmate.