Class: Rake::Pipeline::Web::Filters::IifeFilter
- Inherits:
-
Filter
- Object
- Filter
- Rake::Pipeline::Web::Filters::IifeFilter
- Defined in:
- lib/rake-pipeline-web-filters/iife_filter.rb
Overview
A filter that wraps input files in an IIFE (immediately invoked functional expression)
Instance Method Summary collapse
-
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API.
-
#initialize(&block) ⇒ IifeFilter
constructor
A new instance of IifeFilter.
Constructor Details
#initialize(&block) ⇒ IifeFilter
Returns a new instance of IifeFilter.
17 18 19 20 |
# File 'lib/rake-pipeline-web-filters/iife_filter.rb', line 17 def initialize(&block) block ||= proc { |input| input } super(&block) end |
Instance Method Details
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API. Wraps each input in an IIFE.
30 31 32 33 34 35 36 |
# File 'lib/rake-pipeline-web-filters/iife_filter.rb', line 30 def generate_output(inputs, output) inputs.each do |input| output.write "(function() {\n" output.write input.read output.write "})();" end end |