Rake vs Thor for automation scripts?

I want to automate things like:

  • Creating a new Ruby on Rails application with a pre-selected database, Git initialize it, create a Heroku project, commit all files, etc.
  • Download all files to a folder on another computer via SSH, but do not overwrite files.
  • Update Ubuntu, install all the basic packages through apt-get.

From what I understand, does this require the Rake and Thor tools that I should use?

Rake seems to me more de facto and popular. I heard people recommend Thor.

How do they stand each other as a result?

+43
ruby rake thor
Aug 19 '10 at 17:08
source share
4 answers

Rake and Thor use different goals.

Rake is a generic script build tool that depends on the project. In other words, you put your rakefile in your project folder and in the original project control, and you can create, create and perform other automation tasks specific to your project in this rake file. Rake requires the launch of the rake file.

Thor is a general-purpose command-line command-line tool that makes it easy to reuse scripts in many projects, as well as for setting up a project, etc., as you suggest. Thor allows you to "install" an executable script file that you can call from anywhere on your system, like calling ruby , gem , or rake . However, Thor scripts are more suitable for general purpose, cross-application automation, because Thor script does not rely on the file sitting in your folder specific to your project. Thor script is an entire script packaged and installed for reuse anywhere.

According to your stated needs, you are better off using Thor because you can install the script in one place and work anywhere in your system. You will not be attached to where the rake file or something like that is located.

By the way, Rails 3 uses Thor for almost everything that is not related to the project. You still have the Rake file, 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 ... ". Using Thor AND Rake in Rails 3 is a great illustration of where each of these tools works best.

+95
Aug 20 '10 at 14:22
source share

A chef might be the best option to set up Ubuntu.

From your website:

Chef is an open source integration platform designed to provide the benefits of server configuration management for the entire infrastructure.

It is written in Ruby, and there are tons of chef recipes / recipes. Chef will work with configuring Ubuntu and installing packages, servers, etc.

I don’t know if you work with virtual machines, but Vagrant will configure the virtual machine, and then with the help of the chef will configure it.

+13
Apr 14 2018-11-11T00:
source share

I would go with puppet .

By the way, maybe vagrant is useful for you?

0
Sep 04
source share

There is something important here.

http://guides.rubyonrails.org/generators.html in Section 8, Application Templates.

You can execute git commands, select gems, capify project.

And you can also execute system commands to meet your last point: Upgrade Ubuntu, install all basic packages through apt-get .

0
Sep 07 '13 at 22:56
source share



All Articles