Is it possible to know the current rake task within ruby:
# Rakefile
task :install do
MyApp.somemethod(options)
end
# myapp.rb
class MyApp
def somemetod(opts)
## current_task?
end
end
Edit
I’m asking about any enviroment|global variable that can be queried about that, because I wanted to make an app smart about rake, not modify the task itself. I’m thinking of making an app behave differently when it was run by rake.
Is it already enough to check
caller, if it is called from rake, or do you need also which task?I hope, it is ok, when you can modify the rakefile. I have a version which introduce
Rake.application.current_task.Two remarks on it: