Class: WebResourceBundler::Filters::CompressFilter::Filter

Inherits:
BaseFilter
  • Object
show all
Defined in:
lib/web_resource_bundler/filters/compress_filter.rb

Constant Summary collapse

FILE_PREFIX =
'min_'

Instance Attribute Summary

Attributes inherited from BaseFilter

#settings

Instance Method Summary collapse

Constructor Details

#initialize(settings, file_manager) ⇒ Filter

Returns a new instance of Filter.



6
7
8
9
10
# File 'lib/web_resource_bundler/filters/compress_filter.rb', line 6

def initialize(settings, file_manager)
  super(settings, file_manager)
  @js_compressor  = YUI::JavaScriptCompressor.new(:munge => settings[:obfuscate_js])
  @css_compressor = YUI::CssCompressor.new
end

Instance Method Details

#apply!(block_data) ⇒ Object



19
20
21
22
23
# File 'lib/web_resource_bundler/filters/compress_filter.rb', line 19

def apply!(block_data)
  compress_styles!(block_data.styles)
  compress_scripts!(block_data.scripts)
  block_data
end

#set_settings(settings) ⇒ Object



12
13
14
15
16
17
# File 'lib/web_resource_bundler/filters/compress_filter.rb', line 12

def set_settings(settings)
  if @settings[:obfuscate_js] != settings[:obfuscate_js] 
    @js_compressor = YUI::JavaScriptCompressor.new(:munge => settings[:obfuscate_js]) 
  end
  @settings = settings
end