# encoding: utf-8 require 'sprockets' module ClassyAssets class Sprockets attr_accessor :asset_root, :environment def initialize @config = ClassyAssets.config @asset_root = @config.asset_root @environment = new_sprockets_environment end private def new_sprockets_environment sprockets_environment = ::Sprockets::Environment.new(asset_root) do @version = @config.asset_version end @config.asset_paths.each do |asset_path| sprockets_environment.append_path asset_path end if @config.asset_compress sprockets_environment.css_compressor = @config.css_compressor sprockets_environment.js_compressor = @config.js_compressor end sprockets_environment.context_class.class_eval do def asset_path(path, options = {}) ClassyAssets.asset_url_for(path) end end sprockets_environment end end end