tags:

views:

81

answers:

1

I want to automate things like:

  • Creating a new Rails app with pre-selected database, git initialize it, create heroku project, commit all files etc

  • Upload all files in folder to another computer through ssh, but do not overwrite files

  • Upgrade Ubuntu, install all basic packages through apt-get

These kind of tasks.

From what I have understood, tools for this are Rake and Thor.

However, which one should I use?

Rake seems to me more de-facto and popular. I have heard people recommending Thor.

How do these stand to each other in a rundown?

+3  A: 

Rake and Thor serve different purposes.

Rake is a general build script tool that is project-specific. In other words, you put your rakefile your project folder and in your project's source control, and you create build and other automation tasks that are specific to your project in that rakefile. rake requires a rakefile to run.

Thor is a general purpose command line scripting tool that makes it very easy to re-use scripts across many projects and to do project setup, etc. like you are suggesting. Thor allows you to "install" an executable script that you can call from anywhere on your system, similar to calling "ruby", "gem" or "rake" command lines. However, thor's scripts are more suited to general purpose, cross-application automation because the thor script does not rely on a file sitting in your project specific folder. a Thor script is the entire script, packed and installed for re-use anywhere.

Based on your stated needs, you are better off using Thor because you will be able to install your script in one location and have it work anywhere on your system. you will not be bound to a rakefile sitting or anything like that.

...

by the way: Rails 3 uses Thor for pretty much everything that is not project specific. you still have a rakefile and you still run things like "rake db:migrate" or "rake test:units". Thor is used for things like "rails new ...", "rails server" and "rails generate ..." The use of Thor AND Rake in rails 3 is the perfect illustration of where each of these tools is best suited.

Derick Bailey
Excellent explanation! I wished this was on some blog or on Thor's homepage =) Is the "rails" command a Thor script or does it use Thor somehow?
never_had_a_name
thanks. :) the "rails" command is a thor script
Derick Bailey