Created
December 5, 2011 13:05
-
-
Save jodosha/1433535 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :assets do | |
task :check => "assets:environment" do | |
# If the asset pipeline isn't enabled, safely exit. | |
if not Rails.application.config.assets.enabled | |
exit(0) | |
end | |
require 'sprockets/checker' | |
# Ensure that action view is loaded and the appropriate | |
# sprockets hooks get executed | |
_ = ActionView::Base | |
assets = Sprockets::Checker.run | |
if assets.any? | |
puts "There are some assets not scheduled for pre-compilation:\n#{assets.join("\n")}" | |
exit(1) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sprockets/static_compiler' | |
module Sprockets | |
class Checker < StaticCompiler | |
def self.run | |
new(Rails.application).check | |
end | |
def initialize(app) | |
@env, @paths, @manifest = app.assets, app.config.assets.precompile, true | |
end | |
def check | |
compile | |
[].tap do |missing_assets| | |
env.each_logical_path do |logical_path| | |
missing_assets.push(logical_path) unless @manifest.has_key?(logical_path) | |
end | |
end | |
end | |
def write_manifest(manifest) | |
@manifest = manifest | |
end | |
def write_asset(asset) | |
# We dont' want to write for real. | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment