Skip to content

Commit

Permalink
Copy rake tasks from gem extensions on radiant:extensions:update_all
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh French committed Jan 5, 2010
1 parent 9e4829c commit 4399c0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/generators/extension/templates/tasks.rake
Expand Up @@ -22,6 +22,14 @@ namespace :radiant do
mkdir_p RAILS_ROOT + directory, :verbose => false
cp file, RAILS_ROOT + path, :verbose => false
end
unless <%= class_name %>.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
puts "Copying rake tasks from <%= class_name %>"
local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
mkdir_p local_tasks_path, :verbose => false
Dir[File.join <%= class_name %>.root, %w(lib tasks *.rake)].each do |file|
cp file, local_tasks_path, :verbose => false
end
end
end
end
end
Expand Down
11 changes: 10 additions & 1 deletion lib/tasks/extensions.rake
Expand Up @@ -70,9 +70,18 @@ namespace :spec do
end

namespace :radiant do
# TODO: load previously copied tasks just once.
# If update_all is run multiple times, previously copied tasks will be loaded twice,
# once from the local copy (RAILS_ROOT/lib/tasks) and once from the gem source.
task :extensions => :environment do
Radiant::ExtensionLoader.instance.extensions.each do |extension|
next if extension.root.starts_with? RAILS_ROOT
Dir[File.join extension.root, %w(lib tasks *.rake)].sort.each { |task| load task }
end
end
namespace :extensions do
desc "Runs update asset task for all extensions"
task :update_all => :environment do
task :update_all => [:environment, 'radiant:extensions'] do
extension_names = Radiant::ExtensionLoader.instance.extensions.map { |f| f.to_s.underscore.sub(/_extension$/, '') }
extension_update_tasks = extension_names.map { |n| "radiant:extensions:#{n}:update" }.select { |t| Rake::Task.task_defined?(t) }
extension_update_tasks.each {|t| Rake::Task[t].invoke }
Expand Down

0 comments on commit 4399c0e

Please sign in to comment.