Class: Benoit::Filters::MoveToRootFilter

Inherits:
Rake::Pipeline::Filter
  • Object
show all
Defined in:
lib/benoit/filters/move_to_root_filter.rb

Instance Method Summary collapse

Constructor Details

#initializeMoveToRootFilter

Returns a new instance of MoveToRootFilter.



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/benoit/filters/move_to_root_filter.rb', line 3

def initialize
    block = proc { |input|
        components = input.split('/')
        if components.length == 1 # Already at root
            components.first
        elsif components.first.start_with? '_'
            components.shift
        end
        components.join('/')
    }
    super &block
end

Instance Method Details

#generate_output(inputs, output) ⇒ Object



16
17
18
19
20
# File 'lib/benoit/filters/move_to_root_filter.rb', line 16

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