瑞克的目的是什么? [英] What is the purpose of Rake?

查看:30
本文介绍了瑞克的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Rake 代表 Ruby Make,我知道 Make 是一个 unix 构建实用程序.现在,我在 Xcode 中为 Ruby 构建 iPhone 应用程序,所以我以前从未使用过 Make,而且我唯一一次使用 rake 是在 Rails 中或安装一些第三方包时,我输入了类似 rake db 的命令:迁移.我不明白的是......构建实用程序究竟是什么?耙子的目的是什么?它让我做什么?因此,如果有人能帮助我回答这些问题中的任何一个,我将不胜感激.

I know Rake stands for Ruby Make, and I know Make is a unix build utility. Now, I come from working in Xcode building iPhone apps to Ruby, so I have never used Make before, and the only time I use rake is when in rails or installing some third party package and I type a command like rake db:migrate. The things I don't understand are ... What exactly is a build utility? What is the purpose of rake? What does it let me do? So if anyone can help answer any of these questions for me, it would be much appreciated.

推荐答案

Rake 允许您在每个项目的基础上编写某些任务的脚本,就像 Makefile 允许 Unix 开发人员编写其编译和构建过程的脚本一样.到目前为止,您使用 Rake 定义的任务包含在它们随附的包中(例如 rake db:migrate 随 Rails 一起提供,或至少随 ActiveRecord 一起提供)并自动执行与这些包相关的某些任务(例如,为 Rails 项目安装所需的 gem).

Rake lets you script certain tasks on a per-project basis, much as a Makefile allows a Unix developer to script their compile and build process. The defined tasks you've used Rake with so far were included with the packages they came with (e.g. rake db:migrate comes with Rails, or at least with ActiveRecord) and automate certain tasks related to those packages (e.g. installing required gems for a Rails project).

如果您的项目有某些重复执行的任务,您可以编写一个 rake 任务来运行那些包含在项目的 SCM 树中并在该项目的上下文中运行的任务;在 Rails 中,它们位于 lib/tasks 中.例如,您可以编写一个 Rake 任务来清除数据库中过时的会话记录,然后设置一个 cron 作业来运行它.

If your project has certain tasks which are performed repeatedly, you can write a rake task to run those tasks which gets included in the SCM tree for the project and runs in the context of that project; in Rails they're in lib/tasks. You could write a Rake task to purge stale session records from your database, for example, and then set up a cron job to run it.

这篇关于瑞克的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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