Class: Rake::Pipeline::Web::Filters::YUIJavaScriptFilter
- Inherits:
-
Filter
- Object
- Filter
- Rake::Pipeline::Web::Filters::YUIJavaScriptFilter
- Includes:
- FilterWithDependencies
- Defined in:
- lib/rake-pipeline-web-filters/yui_javascript_filter.rb
Overview
A filter that compresses JavaScript input files using the YUI JavaScript 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) ⇒ YUIJavaScriptFilter
constructor
A new instance of YUIJavaScriptFilter.
Constructor Details
#initialize(options = {}, &block) ⇒ YUIJavaScriptFilter
Returns a new instance of YUIJavaScriptFilter.
30 31 32 33 34 |
# File 'lib/rake-pipeline-web-filters/yui_javascript_filter.rb', line 30 def initialize(={}, &block) block ||= proc { |input| input.sub(/\.js$/, '.min.js') } 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_javascript_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 JavaScript compressor.
45 46 47 48 49 50 |
# File 'lib/rake-pipeline-web-filters/yui_javascript_filter.rb', line 45 def generate_output(inputs, output) compressor = YUI::JavaScriptCompressor.new() inputs.each do |input| output.write compressor.compress(input.read) end end |