class Rake::SprocketsTask
end
t.assets = %w( application.js application.css )
t.output = “./public/assets”
t.environment = Sprockets::Environment.new
Rake::SprocketsTask.new do |t|
Simple Sprockets compilation Rake task macro.
def define
def define desc name == :assets ? "Compile assets" : "Compile #{name} assets" task name do with_logger do manifest.compile(assets) end end desc name == :assets ? "Remove all assets" : "Remove all #{name} assets" task "clobber_#{name}" do with_logger do manifest.clobber end end task :clobber => ["clobber_#{name}"] desc name == :assets ? "Clean old assets" : "Clean old #{name} assets" task "clean_#{name}" do with_logger do manifest.clean(keep) end end task :clean => ["clean_#{name}"] end
def environment
end
t.environment = Foo::Assets
Rake::SprocketsTask.new do |t|
You'll most likely want to reassign `environment` to your own.
`Environment` instance used for finding assets.
def environment if !@environment.is_a?(Sprockets::Base) && @environment.respond_to?(:call) @environment = @environment.call else @environment end end
def index
def index @index ||= environment.index end
def initialize(name = :assets)
def initialize(name = :assets) @name = name @environment = lambda { Sprockets::Environment.new(Dir.pwd) } @logger = Logger.new($stderr) @logger.level = Logger::INFO @keep = 2 yield self if block_given? define end
def log_level
def log_level @logger.level end
def log_level=(level)
t.log_level = :debug
t.log_level = Logger::INFO
Set logger level with constant or symbol.
def log_level=(level) if level.is_a?(Integer) @logger.level = level else @logger.level = Logger.const_get(level.to_s.upcase) end end
def manifest
def manifest @manifest ||= Sprockets::Manifest.new(index, output) end
def with_logger
Sub out environment logger with our rake task logger that
def with_logger old_logger = index.logger index.logger = @logger yield ensure index.logger = old_logger end