Rake vs. Thor的自动化脚本? [英] Rake vs. Thor for automation scripts?

查看:133
本文介绍了Rake vs. Thor的自动化脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动化诸如此类的事情

I want to automate things like:

  • 使用预先选择的数据库创建一个新的Ruby on Rails应用程序,Git对其进行初始化,并创建一个 Heroku 项目,提交所有文件,等等.
  • 通过SSH将文件夹中的所有文件上传到另一台计算机,但不要覆盖文件.
  • 升级Ubuntu,通过apt-get安装所有基本软件包.
  • Creating a new Ruby on Rails application with pre-selected database, Git initialize it, create a 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.

据我了解,用于此目的的工具是Rake和Thor,我应该使用哪个工具?

From what I understand, tools for this are Rake and Thor, however, which one should I use?

在我看来,Rake实际上更受欢迎.我听说有人推荐雷神.

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?

推荐答案

Rake和Thor具有不同的用途.

Rake and Thor serve different purposes.

Rake是特定于项目的常规构建脚本工具.换句话说,您将rakefile放入项目文件夹和项目的源代码管理中,并且可以在该rakefile中创建,构建和执行其他特定于您的项目的自动化任务. Rake需要一个rakefile才能运行.

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

Thor是一个通用的命令行脚本工具,使您可以很轻松地在许多项目中重复使用脚本以及进行项目设置等,就像您所建议的那样. Thor允许您安装"可执行脚本,您可以从系统上的任何位置调用该脚本,类似于调用"ruby","gem"或"rake"命令行.但是,Thor脚本更适合于通用的跨应用程序自动化,因为Thor脚本不依赖于项目专用文件夹中的文件. Thor脚本是完整的脚本,打包并安装后可以在任何地方重复使用.

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.

根据您的陈述的需求,您最好使用Thor,因为您可以将脚本安装在一个位置上,并可以在系统上的任何位置使用它.您将不会受到Rake文件所在位置或类似位置的约束.

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 where a Rake file is sitting or anything like that.

顺便说一句,Rails 3使用Thor来处理几乎所有与项目无关的事情.您仍然有一个Rake文件,并且仍然运行"rake db:migrate"或"rake test:units"之类的东西. Thor用于"rails new ...","rails server"和"rails generate ..."之类的东西.在Rails 3中使用Thor和Rake可以很好地说明这些工具最适合的位置.

By the way, Rails 3 uses Thor for pretty much everything that is not project specific. You still have a 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 ..." The use of Thor AND Rake in Rails 3 is the perfect illustration of where each of these tools is best suited.

这篇关于Rake vs. Thor的自动化脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆