Class: SmartAsset::Stasis

Inherits:
Stasis::Plugin
  • Object
show all
Defined in:
lib/smart_asset/adapters/stasis.rb

Constant Summary collapse

REGEX =
/.*\.(js|css|coffee|sass|scss|less)/

Instance Method Summary collapse

Constructor Details

#initialize(stasis) ⇒ Stasis

Returns a new instance of Stasis.



9
10
11
12
# File 'lib/smart_asset/adapters/stasis.rb', line 9

def initialize(stasis)
  @stasis = stasis
  SmartAsset.load_config(@stasis.root)
end

Instance Method Details

#before_allObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/smart_asset/adapters/stasis.rb', line 14

def before_all
  SmartAsset.env = @stasis.options[:development] ?
    'development' : 'production'
  SmartAsset.cache = nil
  
  @asset_rendered = false
  @packaged = false

  priority = {}
  priority[REGEX] = 100
  @stasis.controller.priority(priority)
  
  @stasis.controller.helpers do
    include SmartAsset::Helper
  end
end

#before_renderObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/smart_asset/adapters/stasis.rb', line 31

def before_render
  return if @stasis.options[:development] || @stasis.path.nil?
  if @stasis.path =~ REGEX
    @asset_rendered = true
  elsif @asset_rendered && !@packaged
    @packaged = true
    SmartAsset.compress 'javascripts'
    SmartAsset.compress 'stylesheets'
  end
end