Sha256: 77c6c62a5850367d0a92fad54037aebfe55a2bff38e75aebc42d0543ac070210

Contents?: true

Size: 1.53 KB

Versions: 15

Compression:

Stored size: 1.53 KB

Contents

# stdlib
require "set"

# 3rd-party
require "sprockets"

module Jekyll
  module AssetsPlugin
    module Patches
      module ProcessedAssetPatch
        def self.included(base)
          base.class_eval do
            attr_reader :jekyll_assets

            alias_method :__orig_build_dependency_paths,
              :build_dependency_paths

            alias_method :build_dependency_paths,
              :__wrap_build_dependency_paths

            alias_method :__orig_init_with, :init_with
            alias_method :init_with, :__wrap_init_with

            alias_method :__orig_encode_with, :encode_with
            alias_method :encode_with, :__wrap_encode_with
          end
        end

        def __wrap_build_dependency_paths(environment, context)
          @jekyll_assets = Set.new

          context.jekyll_assets.each do |path|
            @jekyll_assets << path
            environment.find_asset(path)
              .jekyll_assets.each { |p| @jekyll_assets << p }
          end

          __orig_build_dependency_paths environment, context
        end

        def __wrap_init_with(environment, coder)
          __orig_init_with environment, coder

          @jekyll_assets = Set.new coder["jekyll_assets"]
            .map { |p| expand_root_path(p) }
        end

        def __wrap_encode_with(coder)
          __orig_encode_with coder

          coder["jekyll_assets"] = jekyll_assets.map do |path|
            relativize_root_path path
          end
        end

        ::Sprockets::ProcessedAsset.send :include, self
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
jekyll-assets-0.13.0 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.12.1 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.12.0 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.11.0 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.10.1 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.10.0 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.9.2 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.9.1 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.9.0 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.8.1 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.8.0 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
tgfa-jekyll-assets-0.7.9.2 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
tgfa-jekyll-assets-0.7.9.1 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.7.9 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb
jekyll-assets-0.7.8 lib/jekyll/assets_plugin/patches/processed_asset_patch.rb