Sha256: b52d7a71d6fda07ad886c417b4e65bd87be9ee82c16fa98e8cb7d97217d83b33

Contents?: true

Size: 947 Bytes

Versions: 1

Compression:

Stored size: 947 Bytes

Contents

class SmartAsset
  class Stasis < ::Stasis::Plugin

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

    before_all :before_all
    before_render :before_render

    def initialize(stasis)
      @stasis = stasis

      SmartAsset.env = stasis.options[:development] ? 'development' : 'production'
      SmartAsset.load_config(@stasis.root)
    end

    def before_all
      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

    def before_render
      if @stasis.path =~ REGEX
        @asset_rendered = true
      elsif @asset_rendered && !@packaged
        @packaged = true
        SmartAsset.compress 'javascripts'
        SmartAsset.compress 'stylesheets'
      end
    end
  end
end

Stasis.register(SmartAsset::Stasis)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_asset-0.5.7 lib/smart_asset/adapters/stasis.rb