cmar blog

Spree Engineer.

Bundle Searching

Jim Gay (@saturnflyer) posted a great tip for using The Silver Searcher to find the occurrence of a word within the gem dependencies for your project.

Bundler has had requests for search capabilities. Rule #2 of the Unix Philosophy is make each program do one thing well. The Silver Searcher is my current favorite searching tool. Its replaced grep and ack for all my code searching. Following rule #2, we don’t need bundler to search for us, we just need to compose it together with the best search tool.

Its a simple idea. Jim Gay wrote about it. I thought it was brilliant. I created an alias to make it easy to use:

1
alias bs="bundle show --paths | xargs ag"

Now, inside a project I can run ‘bs user’ to search for the word ‘user’ within all the gems included in my project. Is this fast? Yes! Inside a Spree sandbox - which has 81 gem dependencies - I can search for a common word like ‘user’ in 3.339s.

Thanks for the idea Jim!

Comments