Class: Rake::Pipeline::Web::Filters::NeuterFilter
- Inherits:
-
ConcatFilter
- Object
- ConcatFilter
- Rake::Pipeline::Web::Filters::NeuterFilter
- Defined in:
- lib/rake-pipeline-web-filters/neuter_filter.rb
Overview
A filter that takes files with requires and collapses them into a single file without requires.
Instance Method Summary collapse
- #additional_dependencies(input) ⇒ Object
- #generate_output(inputs, output) ⇒ Object
-
#initialize(string = nil, config = {}, &block) ⇒ NeuterFilter
constructor
A new instance of NeuterFilter.
Constructor Details
#initialize(string = nil, config = {}, &block) ⇒ NeuterFilter
Returns a new instance of NeuterFilter.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rake-pipeline-web-filters/neuter_filter.rb', line 85 def initialize(string=nil, config={}, &block) if string.is_a?(Hash) config = string string = nil end @config = config super(string, &block) end |
Instance Method Details
#additional_dependencies(input) ⇒ Object
105 106 107 108 |
# File 'lib/rake-pipeline-web-filters/neuter_filter.rb', line 105 def additional_dependencies(input) method = @config[:additional_dependencies] method ? method.call(input).map{|p| File.(p, input.root) } : [] end |
#generate_output(inputs, output) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/rake-pipeline-web-filters/neuter_filter.rb', line 96 def generate_output(inputs, output) inputs.each do |input| known_files = [input.fullpath] + additional_dependencies(input) batch = NeuterBatch.new(@config, known_files) file = batch.file_wrapper(file_wrapper_class, input.root, input.path, input.encoding) output.write file.read end end |