I was thinking of this on my way home, but could not come up with a good
answer… what is the extra bit that Rake gives me, which I don’t get
from a Ruby script?
I’m sorry it’s a bit of a naive question, but I was wondering when would
it be more appropriate to use Rake compared to vanilla Ruby!
Thanks,
Mohit.
14/5/2010 | 11:33 PM.
On Fri, May 14, 2010 at 10:20 AM, Mohit S. [email protected]
wrote:
extra bit that Rake gives me, which I don’t get from a Ruby script?
I’m sorry it’s a bit of a naive question, but I was wondering when would it
be more appropriate t
Rake allows you to create tasks that are dependent on one another,
like Makefiles except with much nicer Ruby code. That’s why I like it
anyway…
-Jonathan N.
Mohit S. wrote:
I was thinking of this on my way home, but could not come up with a good
answer… what is the extra bit that Rake gives me, which I don’t get
from a Ruby script?
I’m sorry it’s a bit of a naive question, but I was wondering when would
it be more appropriate to use Rake compared to vanilla Ruby!
Off the top of my head:
- Dependency chain management
- Ability to re-use other people’s *.rake files
- Handy means to get a list of commands
That last one is quite useful. I have a habit of knocking out helper
scripts for little project tasks, and I end up with a set files whose
actual purpose or behavior is not entirely clear. If I move the code
into Rake tasks with a decent namespace then I can more easily see what
helper code I have by running rake -T | grep my-cool-namespace
And I have a global helper script, rt, that calls rake -T and if you
pass an argument it will grep the output to filter the results:
$ rt # Same as rake -T
$ rt jimbo # Same as rake -T | grep jimbo
Since your rake files can have plain old Ruby methods in them there’s
nothing you can do in vanilla Ruby you can’t do in Rake, though calling
Rake can have some start-up overhead. Oh, and passing command-line
arguments in Rake sucks ass. So there are trade-offs.
–
James B.
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff
www.neurogami.com - Smart application development
On May 14, 2010, at 10:44 AM, James B. wrote:
[snip]…end up with a set files whose actual purpose or behavior is not entirely clear. If I move the code into Rake tasks with a decent namespace then I can more easily see what helper code I have by running rake -T | grep my-cool-namespace
FYI:
$ rake -T | grep collation
rake db:collation # Retrieves the coll…
$ rake -T collation
rake db:collation # Retrieves the coll…
The grep is unnecessary. -T will do it for you.
~ j.
John B. wrote:
The grep is unnecessary. -T will do it for you.
Interesting. Does not grep the description, though.
James