Skip to content

Instantly share code, notes, and snippets.

@AnthonyMastrean
Created August 13, 2013 14:42
Show Gist options
  • Save AnthonyMastrean/6221825 to your computer and use it in GitHub Desktop.
Save AnthonyMastrean/6221825 to your computer and use it in GitHub Desktop.
Args for custom Rake tasks
task :default => [ :puts ]
def says(*args, &block)
copy = block
body = proc {
copy.call
puts args.message
}
Rake::Task.define_task *args, &body
end
task :puts, [ :message ] do |t, args|
args.with_defaults :message => 'Hello, rake!'
puts args.message
end
says :says, [ :message ] do |t, args|
args.with_defaults :message => 'Hello, rake!'
end
@AnthonyMastrean
Copy link
Author

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