Sha256: c540684b680cdd4e0f6ce37890ac0ebe027e7a0e8b7f22b3347cb1651b8aa81e

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

# encoding: utf-8


require 'sprockets'
module ClassyAssets
  class Sprockets
    attr_accessor :asset_root, :environment
    def initialize
      @asset_root = ClassyAssets.config.asset_root
      @environment = new_sprockets_environment
    end

    private

    def new_sprockets_environment
      @environment = ::Sprockets::Environment.new(asset_root)
      
      ClassyAssets.config.asset_paths.each do |asset_path|
        @environment.append_path asset_path
      end

      if ClassyAssets.config.asset_compress
        @environment.css_compressor = ClassyAssets.config.css_compressor
        @environment.js_compressor  = ClassyAssets.config.css_compressor
      end

      @environment.context_class.class_eval do
        def asset_path(path, options = {})
          ClassyAssets.asset_url_for(path)
        end
      end

      @environment
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
classy_assets-0.9.3 lib/classy_assets/sprockets.rb
classy_assets-0.9.2 lib/classy_assets/sprockets.rb