The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Ack in Project Skipping Rake

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
john hume

Posts: 82
Nickname: duelnmrkrs
Registered: Oct, 2005

John Hume is a developer and consultant with ThoughtWorks.
Ack in Project Skipping Rake Posted: Jan 16, 2009 1:18 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by john hume.
Original Post: Ack in Project Skipping Rake
Feed Title: El Humidor
Feed URL: http://feeds.feedburner.com/ElHumidor
Feed Description: John D. Hume on Ruby and development with agile teams.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by john hume
Latest Posts From El Humidor

Advertisement

Ack in Project is probably the TextMate bundle I use the most (after the Ruby bundle, I suppose, which I constantly use without even thinking about it). If you haven't already, you should install it immediately for very fast project searches (and recursive searches of just the selected directory, which on its own is hugely useful).

What it took me a while to realize, though, is that my project's Rake files weren't being searched. It turns out this is because Ack will by default search every file of a known type and ignore everything else. Ack knows Ruby as .rb, .rhtml, .rjs, .rxml and .erb, but that's all by default. (You can see what extensions are associated with what types from the command line with ack --help types. This assumes you've got ack installed on your path somewhere.)

To teach Ack about new extensions or entirely new types, create an .ackrc file in your home directory and fill it with things like this:

# Add the .rake extension to the existing ruby type.
--type-add
ruby=.rake

# Create a new type for Clojure source files.
--type-set
clojure=.clj

(type-set can also be used to completely replace a built in type definition. Read about this and all sorts of other ack options from the command line with ack --man.)

In addition to getting .ackrc in place, you also have to tell the TextMate bundle that you want to use it. From inside TextMate do an Ack in Project, hit the "Advanced Options" twisty, and check "load defaults from .ackrc." You're all set.

It may have occurred to you that your top-level Rakefile doesn't have an extension. Likewise for the executables in your Rails projects' script directory. And your Capfile.

Damn.

Luckily, Ack knows unix-ey people like dropping extensions from executables and using a shebang line to tell the shell how to run them. So any file with an unrecognized extension (or none at all) will be checked for a shebang line that might qualify it for the perl, ruby, php, python, shell or xml types!

So that takes care of RAILS_ROOT/script/*. As far as Rakefile and Capfile ... well, the shebang line would really be a lie, since they're not executable without the supporting Rake and Capistrano libraries loaded, but the workaround of adding the shebang will get them into your Ack results. I leave it to you to decide whether the lying shebang or excluded files is a lesser evil, and promise to let you know if I find a better way to get Ack to consider them Ruby.

Thanks for reading!

Read: Ack in Project Skipping Rake

Topic: Links for 2009-01-15 [del.icio.us] Previous Topic   Next Topic Topic: /usr/bin/gems reports

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use