diff options
author | Carl Lerche <carllerche@mac.com> | 2009-12-28 16:21:48 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2009-12-28 17:53:04 -0800 |
commit | c02f2782631a1893e2e880e3ccc65fb9a734567a (patch) | |
tree | 66eff8ee7fedc93f0cc34901953cced52bda075f /railties/lib | |
parent | 9a650a6547d2a83004db1bf913e26a8daa1c0b6e (diff) | |
download | rails-c02f2782631a1893e2e880e3ccc65fb9a734567a.tar.gz rails-c02f2782631a1893e2e880e3ccc65fb9a734567a.tar.bz2 rails-c02f2782631a1893e2e880e3ccc65fb9a734567a.zip |
Add the ability to have plugins load rake tasks.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/plugin.rb | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index cd579a1c0d..4c1f36f537 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -72,7 +72,12 @@ module Rails def load_tasks require "rails/tasks" + # Load all extension rake tasks + plugins.each(&:load_tasks) + # Load all plugin tasks Dir["#{root}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext } + # Load all application tasks + # TODO: extract out the path to the rake tasks Dir["#{root}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } task :environment do $rails_rake_task = true diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index aa325c6f76..be6cdec3fa 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -25,6 +25,16 @@ module Rails Configuration.default end + def self.rake_tasks(&blk) + @rake_tasks ||= [] + @rake_tasks << blk + end + + def self.load_tasks + return unless @rake_tasks + @rake_tasks.each { |blk| blk.call } + end + # Creates an initializer which includes all given modules to the given class. # # module Rails |