Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cache public/assets if rake assets:clean_expired is successful

  • Loading branch information...
commit ea6763a632022253bcd4fabe6005ed76249b8564 1 parent a815917
@ndbroadbent authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/language_pack/rails3.rb
View
20 lib/language_pack/rails3.rb
@@ -43,6 +43,9 @@ def run_assets_precompile_rake_task
if File.exists?("public/assets/manifest.yml")
puts "Detected manifest.yml, assuming assets were compiled locally"
else
+ FileUtils.mkdir_p('public')
+ cache_load "public/assets"
+
ENV["RAILS_GROUPS"] ||= "assets"
ENV["RAILS_ENV"] ||= "production"
@@ -53,6 +56,23 @@ def run_assets_precompile_rake_task
if $?.success?
log "assets_precompile", :status => "success"
puts "Asset precompilation completed (#{"%.2f" % time}s)"
+
+ # If 'turbo-sprockets-rails3' gem is available, run 'assets:clean_expired' and
+ # cache assets if task was successful.
+ if gem_is_bundled?('turbo-sprockets-rails3')
+ log("assets_clean_expired") do
+ run("env PATH=$PATH:bin bundle exec rake assets:clean_expired 2>&1")
+ if $?.success?
+ log "assets_clean_expired", :status => "success"
+ cache_store "public/assets"
+ else
+ log "assets_clean_expired", :status => "failure"
+ cache_clear "public/assets"
+ end
+ end
+ else
+ cache_clear "public/assets"
+ end
else
log "assets_precompile", :status => "failure"
puts "Precompiling assets failed, enabling runtime asset compilation"
Please sign in to comment.
Something went wrong with that request. Please try again.