Skip to content

Instantly share code, notes, and snippets.

@sandheepg
Created March 8, 2017 07:31
Show Gist options
  • Save sandheepg/2b7193c302f7ec871fb2280c31ba6ffd to your computer and use it in GitHub Desktop.
Save sandheepg/2b7193c302f7ec871fb2280c31ba6ffd to your computer and use it in GitHub Desktop.
Understanding rake tasks

Rake is a build language (like make and ant), an internal DSL build in Ruby language.

task :task_name => [:clean] do
  ## ruby code comes here
  ## ruby code comes here
  ## ruby code comes here
end

task is a method that accepts two parameters, a hash and a block. The key in the hash is task name and the value is an array which contains the dependencies (optional). You can remove the square braces in case of single dependency and the value for the hash can be removed in case of no dependency.

The dependencies are executed first and then the task code specified in the block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment