rake速记

[b]参考教程[/b]
[list]
[*][url]http://jasonseifer.com/2010/04/06/rake-tutorial[/url]
[/list]

[b]hello rake[/b]

#rakefile.rb
task :default => [:hello]
task :hello do
puts 'hello rake'
end
#$ rake
#$ rake hello
#$ rake rakefile.rb


[b]namespace[/b]

task :default => "morning:turn_of_alarm"
namespace :morning do
task :turn_of_alarm do
puts 'ding...'
end
end
#$rake moring:turn_of_alarm


[b]task description[/b]

desc "description of task "
task :hello do
end
#$ rake -T
#=>
# rake hello # description of task



[b]redefined task[/b]

task :default => 'morning:turn_of_alarm'
namespace :morning do
desc "turn of alarm"
task :turn_of_alarm do
puts 'hello'
end
end

namespace :morning do
task :turn_of_alarm do
puts 'world'
end
end
#$ rake
#=>
# hello
# world



[b]invoking other task[/b]

task :default => 'task:world'
namespace :task do
desc "hello world"
task :hello do
puts 'hello'
end
end

namespace :task do
task :world do
puts '...'
Rake::Task['task:hello'].invoke
puts 'world'
end
end
#Rake::Task['task:hello'].invoke(args.args_name)



[b]task dependencies[/b]

task :default => 'task:world'
namespace :task do
task :hello do
puts 'hello'
end
end

namespace :task do
task :world => :hello do
puts 'world'
end
end


[b]task arguments[/b]

task :say, [:name,:gender] do |t, args|
args.with_defaults(:name=>'john',:gender=>'boy')
puts "hello #{args.name} #{args.gender}"
end
#rake say[Lucy,girl]


[b]multitask[/b]
Declare a task that performs its prerequisites in parallel. Multitasks does not guarantee that its prerequisites will execute in any given order (which is obvious when you think about it)

multitask :deploy => [:deploy_gem, :deploy_rdoc]


[b]mkdir task[/b]

directory "tmp/abc"
#rake tmp/abc
#mkdir -p tmp/abc

#执行前会先建立tmp/abc
task :task_a => "tmp/abc" do

end


[b]rule task[/b]

rule '.o' => ['.c'] do |t|
sh "cp #{t.source} #{t.name}"
end
#touch a.c
#rake a.o
#cp a.c a.o
#t.source指a.c, t.name是a.o
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值