- Rake Task Management Essentials
- Andrey Koleshko
- 300字
- 2021-07-16 12:01:40
Introducing rake tasks
From the previous error message, it's clear that first you need to have Rakefile
. As you can see, there are four variants of its name: rakefile
, Rakefile
, rakefile.rb
, and Rakefile.rb
. The most popularly used variant is Rakefile
. Rails also uses it. However, you can choose any variant for your project. There is no convention that prohibits the user from using any of the four suggested variants.
Rakefile
is a file that is required for any Rake-based project. Apart from the fact that its content usually contains DSL, it's also a general Ruby file. Also, you can write any Ruby code in it. Perform the following steps to get started:
- Let's create a
Rakefile
in the current folder, which will just sayHello Rake
, using the following commands:$ echo "puts 'Hello Rake'" > Rakefile $ cat Rakefile puts 'Hello Rake'
Here, the first line creates a
Rakefile
with the content,puts 'Hello Rake'
, and the second line just shows us its content to make sure that we've done everything correctly. - Now, run
rake
as we tried it before, using the following command:$ rake Hello Rake rake aborted! Don't know how to build task 'default' (See full trace by running task with --trace)
The message has changed and it says
Hello Rake
. Then, it gets aborted because of another error message. At this moment, we have made the first step in learning Rake. - Now, we have to define a default rake task that will be executed when you try to start Rake without any arguments. To do so, open your editor and change the created Rakefile with the following content:
task :default do puts 'Hello Rake' end
- Now, run
rake
again:$ rake Hello, Rake
The output that says Hello, Rake
demonstrates that the task works correctly.
- Learn Type:Driven Development
- PowerCLI Cookbook
- Blender 3D Incredible Machines
- C程序設(shè)計案例教程
- Mastering Apache Spark 2.x(Second Edition)
- R大數(shù)據(jù)分析實用指南
- 零基礎(chǔ)入門學(xué)習(xí)Python(第2版)
- Cybersecurity Attacks:Red Team Strategies
- RESTful Java Web Services(Second Edition)
- Java語言程序設(shè)計教程
- 深入解析Java編譯器:源碼剖析與實例詳解
- 遠(yuǎn)方:兩位持續(xù)創(chuàng)業(yè)者的點滴思考
- 黑莓(BlackBerry)開發(fā)從入門到精通
- 用Python動手學(xué)統(tǒng)計學(xué)
- Backbone.js Patterns and Best Practices