Class: Rake::Pipeline::Web::Filters::YUICssFilter
- Inherits:
-
Filter
- Object
- Filter
- Rake::Pipeline::Web::Filters::YUICssFilter
- Includes:
- FilterWithDependencies
- Defined in:
- lib/rake-pipeline-web-filters/yui_css_filter.rb
Overview
A filter that compresses CSS input files using the YUI CSS compressor.
Requires yui-compressor
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
A hash of options to pass to the YUI compressor when compressing.
Instance Method Summary collapse
-
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API.
-
#initialize(options = {}, &block) ⇒ YUICssFilter
constructor
A new instance of YUICssFilter.
Constructor Details
#initialize(options = {}, &block) ⇒ YUICssFilter
Returns a new instance of YUICssFilter.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rake-pipeline-web-filters/yui_css_filter.rb', line 30 def initialize(={}, &block) block ||= proc { |input| if input =~ %r{min.css$} input else input.sub /\.css$/, '.min.css' end } super(&block) @options = end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns a hash of options to pass to the YUI compressor when compressing.
24 25 26 |
# File 'lib/rake-pipeline-web-filters/yui_css_filter.rb', line 24 def @options end |
Instance Method Details
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API. Compresses each input file with the YUI CSS compressor.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rake-pipeline-web-filters/yui_css_filter.rb', line 52 def generate_output(inputs, output) compressor = YUI::CssCompressor.new() inputs.each do |input| if input.path !~ /min\.css/ output.write compressor.compress(input.read) else output.write input.read end end end |