jimweirich/rake — pull request #168 by jasoares (2013-02-19 03:27:03+00:00)
Title: Add Rake::Task#prerequisite_tasks!

Add Rake::Task#prerequisite_tasks! method to return a full list of prerequisite tasks from the receiver tasks and its prerequisite tasks tasks, recursively.

This is usefull if one needs to call reenable on a task and all of its prerequisite tasks.
As a use case example, when writing integration tests for rake tasks it is common to call ```ruby
Rake::Task#reenable
```before or after every Rake::Task#invoke.
If the task has prerequisites they will not be invoked beyond the first call because they are not affected by #reenable. Calling #reenable on every task's prerequisite task can be done with just task.prerequisite_tasks.each(&:reenable) but that is not so simple when those prerequisites have themselves prerequisite tasks, that's when this comes in handy.
I hope the example is clear enough.

Other alternatives for the method name may be #deep_prerequisite_tasks based on deep_clone or deep_copy.

The implementation proposed sets a default depth limit of 30 to avoid circular dependency(SystemStackError: stack level too deep).