Ayush's Blog

Rake Tips

  • Dependancies are in Hash syntax
  • Dependancies run only once.
    • So if a, b depend on c and a task d has both a, b as dependancy, running task d wouldn’t run c twice.
  • Also, tasks are not functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
task :default => :mm
# do
#   puts "running default"
# end

task :mm => [:oo, :nn] do
  puts "mm working"
end

task :nn do
  puts "nn working"
end

task :oo => [:nn] do
  puts "oo working"
end
  • Namespaced tasks make it easier to have tasks with same names task
1
2
3
4
5
6
7
8
9
10
11
:go_to_store do
  puts "Going to store"
end

# To call this use `rake apple:go_to_store`:

namespace :apple do
  task :go_to_store do
    puts "Going to Apple Store"
  end
end
  • Adding task description:
1
2
3
4
desc "Some task description"
task :named_task do
  puts "Named task"
end