aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-10-05 01:17:04 +0200
committerJosé Valim <jose.valim@gmail.com>2011-10-05 01:25:55 +0200
commitac2f6bd6431311b1eae9d8ac6c217d2c2fbc2b3d (patch)
treee3b791733d7a4c218e987a42e67530f28ef2b4f4
parent110ce85482a3f57f7776067f206408ecc36b9363 (diff)
downloadrails-ac2f6bd6431311b1eae9d8ac6c217d2c2fbc2b3d.tar.gz
rails-ac2f6bd6431311b1eae9d8ac6c217d2c2fbc2b3d.tar.bz2
rails-ac2f6bd6431311b1eae9d8ac6c217d2c2fbc2b3d.zip
Encapsulate common rake invocation logic in a method.
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r--actionpack/lib/sprockets/assets.rake31
1 files changed, 14 insertions, 17 deletions
diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake
index e2536e4ac1..a801050084 100644
--- a/actionpack/lib/sprockets/assets.rake
+++ b/actionpack/lib/sprockets/assets.rake
@@ -2,25 +2,29 @@ require "fileutils"
namespace :assets do
def ruby_rake_task(task)
- env = ENV['RAILS_ENV'] || 'production'
+ env = ENV['RAILS_ENV'] || 'production'
groups = ENV['RAILS_GROUPS'] || 'assets'
- args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"]
+ args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"]
args << "--trace" if Rake.application.options.trace
ruby *args
end
- desc "Compile all the assets named in config.assets.precompile"
- task :precompile do
+ # We are currently running with no explicit bundler group
+ # and/or no explicit environment - we have to reinvoke rake to
+ # execute this task.
+ def invoke_or_reboot_rake_task(task)
if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?
- # We are currently running with no explicit bundler group
- # and/or no explicit environment - we have to reinvoke rake to
- # execute this task.
- ruby_rake_task "assets:precompile:all"
+ ruby_rake_task task
else
- Rake::Task["assets:precompile:all"].invoke
+ Rake::Task[task].invoke
end
end
+ desc "Compile all the assets named in config.assets.precompile"
+ task :precompile do
+ invoke_or_reboot_rake_task "assets:precompile:all"
+ end
+
namespace :precompile do
def internal_precompile(digest=nil)
unless Rails.application.config.assets.enabled
@@ -70,14 +74,7 @@ namespace :assets do
desc "Remove compiled assets"
task :clean do
- if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?
- # We are currently running with no explicit bundler group
- # and/or no explicit environment - we have to reinvoke rake to
- # execute this task.
- ruby_rake_task "assets:clean:all"
- else
- Rake::Task["assets:clean:all"].invoke
- end
+ invoke_or_reboot_rake_task "assets:clean:all"
end
namespace :clean do