aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2009-12-28 16:21:48 -0800
committerCarl Lerche <carllerche@mac.com>2009-12-28 17:53:04 -0800
commitc02f2782631a1893e2e880e3ccc65fb9a734567a (patch)
tree66eff8ee7fedc93f0cc34901953cced52bda075f /railties/lib
parent9a650a6547d2a83004db1bf913e26a8daa1c0b6e (diff)
downloadrails-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.rb5
-rw-r--r--railties/lib/rails/plugin.rb10
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