Class: Rake::Pipeline::ConcatFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/rake-pipeline/filters/concat.rb

Overview

A built-in filter that simply accepts a series of inputs and concatenates them into output files based on the output file name generator.

Examples:

Pipeline.build do
  input "app/assets", "**/*.js"
  output "public"

  # create a concatenated output file for each
  # directory of inputs.
  filter(Rake::Pipeline::ConcatFilter) do |input|
    # input files will look something like:
    #   javascripts/admin/main.js
    #   javascripts/admin/app.js
    #   javascripts/users/main.js
    #
    # and the outputs will look like:
    #   javascripts/admin.js
    #   javascripts/users.js
    directory = File.dirname(input)
    ext = File.extname(input)

    "#{directory}#{ext}"
  end
end

Instance Attribute Summary

Attributes inherited from Filter

#file_wrapper_class, #input_files, #output_name_generator, #output_root, #rake_application, #rake_tasks

Instance Method Summary (collapse)

Methods inherited from Filter

#generate_rake_tasks, #initialize, #output_files, #outputs, processes_binary_files

Constructor Details

This class inherits a constructor from Rake::Pipeline::Filter

Instance Method Details

- (String) encoding



33
# File 'lib/rake-pipeline/filters/concat.rb', line 33

processes_binary_files

- (Object) generate_output(inputs, output)

implement the #generate_output method required by the Filter API. In this case, simply loop through the inputs and write their contents to the output.

Recall that this method will be called once for each unique output file.



47
48
49
50
51
# File 'lib/rake-pipeline/filters/concat.rb', line 47

def generate_output(inputs, output)
  inputs.each do |input|
    output.write input.read
  end
end