Created
July 1, 2013 01:53
-
-
Save jyfeather/5897892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
rake 会在当前目录下寻找Rakefile/rakefile/Rakefile.rb/rakefile.rb等rake文件 | |
* rake --tasks: 列出所有任务 | |
* rake [TASK_NAME]:执行特定任务 | |
--- --- | |
Rails中的rake任务: | |
存在于rails目录的lib/tasks目录下,以.rake作为后缀名 | |
=end | |
task :default => [:today] # 默认的任务,rake即可调用 | |
desc "今天的任务" | |
task :today do | |
Rake::Task["home:cook"].invoke # 在一个任务中调用另外的任务 | |
Rake::Task["home:laundry"].invoke | |
end | |
namespace :home do # 加入命名空间,home:cook | |
desc "任务1-买菜" | |
task :purchaseVegetables do | |
puts "到沃尔玛去买菜。" | |
end | |
desc "任务2-做饭" | |
task :cook => :purchaseVegetables do # 加入依赖关系,cook依赖purchaseVegetables先执行 | |
puts "做一顿香喷喷的饭。" | |
end | |
desc "任务3-洗衣机" | |
task :laundry do | |
puts "把衣服都扔进洗衣机" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment