Sha256: 149dc58e13ca94c42616b2c931ccf2bead1e9c364f83e79dd6d2ad7cc7868391

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

# stdlib
require "pathname"


# 3rd-party
require "sprockets"


module Jekyll
  module AssetsPlugin
    class Environment < Sprockets::Environment

      class AssetNotFound < StandardError
        def initialize path
          super "Couldn't find file '#{path}'"
        end
      end


      attr_reader :site


      def initialize site
        super site.source

        @site = site

        # append asset paths
        site.assets_config.sources.each { |p| append_path p }

        self.js_compressor   = site.assets_config.js_compressor
        self.css_compressor  = site.assets_config.css_compressor

        if site.assets_config.cache_assets?
          self.cache = Sprockets::Cache::FileStore.new cache_path
        end

        # reset cache if config changed
        self.version = site.assets_config.marshal_dump

        # bind jekyll and Sprockets context together
        context_class.instance_variable_set :@site, site
        context_class.send :include, Patches::ContextPatch
      end


      def cache_path
        Pathname.new(@site.source).join @site.assets_config.cache_path
      end


      def find_asset path, *args
        super or raise AssetNotFound, path
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jekyll-assets-0.7.6 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.7.5 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.7.4 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.7.3 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.7.2 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.7.1 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.7.0 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.6.1 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.6.0 lib/jekyll/assets_plugin/environment.rb
jekyll-assets-0.5.4 lib/jekyll/assets_plugin/environment.rb