Skip to content

Instantly share code, notes, and snippets.

@rplaurindo
Last active February 25, 2018 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rplaurindo/5923333 to your computer and use it in GitHub Desktop.
Save rplaurindo/5923333 to your computer and use it in GitHub Desktop.
$ rake namespace:task['Hello,Wolrd!']
# lib/tasks/task_example.rake
namespace :namespace_1 do
  # without this line the task will not be enumerated in rake -T
  desc "Description"

  task :task_name, [:params] => [:environment] do |t, arbitrary|
    # it works as splat operator
    params = arbitrary.extras.unshift arbitrary[:params] ? arbitrary[:params] : "no params"

    p params

  end

end

# run, without spaces between params: $ rake namespace_1:task_name[bla,bla2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment