-
-
Notifications
You must be signed in to change notification settings - Fork 168
Expand file tree
/
Copy pathcached_environment.rb
More file actions
52 lines (46 loc) · 1.12 KB
/
cached_environment.rb
File metadata and controls
52 lines (46 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Frozen-string-literal: true
# Copyright: 2012 - 2020 - ISC License
# Author: Jordon Bedwell
# Encoding: utf-8
module Jekyll
module Assets
module Patches
module CachedEnvironment
include Utils
# --
attr_reader :manifest
attr_reader :asset_config
attr_reader :jekyll
# --
# @param [Env] env the environment.
# Patches initialize so we can give access to `#jekyll`.
# @return [self]
# --
def initialize(env)
super
@manifest = env.manifest
@asset_config = env.asset_config
@jekyll = env.jekyll
end
# --
# @note this is used internally.
# Wraps around #super and adds environment.
# @return [Sprockets::Asset]
# --
%i(find_asset find_asset!).each do |v|
define_method v do |*a, **b|
super(*a, **b).tap do |m|
m&.environment = self
end
end
end
end
end
end
end
# --
module Sprockets
class CachedEnvironment
prepend Jekyll::Assets::Patches::CachedEnvironment
end
end