Class: Jekyll::AssetsPlugin::Environment

Inherits:
Sprockets::Environment
  • Object
show all
Defined in:
lib/jekyll/assets_plugin/environment.rb

Defined Under Namespace

Classes: AssetNotFound

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Environment

Returns a new instance of Environment.



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
# File 'lib/jekyll/assets_plugin/environment.rb', line 21

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

  # load css autoprefix post-processor
  install_autoprefixer!

  # 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

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



19
20
21
# File 'lib/jekyll/assets_plugin/environment.rb', line 19

def site
  @site
end

Instance Method Details

#cache_pathObject



47
48
49
# File 'lib/jekyll/assets_plugin/environment.rb', line 47

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

#find_asset(path, *args) ⇒ Object



51
52
53
# File 'lib/jekyll/assets_plugin/environment.rb', line 51

def find_asset(path, *args)
  super || fail(AssetNotFound, path)
end