flowerbox-delivery/lib/flowerbox/delivery/sprockets_handler.rb
2012-01-23 12:21:11 -05:00

30 lines
586 B
Ruby

require 'sprockets'
module Flowerbox::Delivery
class SprocketsHandler
attr_reader :files, :options
def initialize(options)
@options = options
@files = UniqueAssetList.new
end
def add(asset)
@files.add(paths_for(asset))
end
def paths_for(asset)
environment.find_asset(asset).to_a.collect(&:pathname)
end
def environment
return @environment if @environment
@environment = Sprockets::Environment.new
options[:asset_paths].each { |path| @environment.append_path(path) }
@environment
end
end
end