Class: Germinate::TransformProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/germinate/transform_process.rb

Instance Method Summary collapse

Instance Method Details

#call(hunk) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/germinate/transform_process.rb', line 14

def call(hunk)
  ordered_transforms.inject(hunk) { |input, transform|
    if hunk.send("#{transform}?")
      log.debug "Performing text transform #{transform} on #{hunk}"
      Germinate::TextTransforms.send(transform).call(input) 
    else
      log.debug "Skipping text transform #{transform} on #{hunk} lines"
      input
    end
  }
end

#ordered_transformsObject

We can’t just use TextTransforms.singleton_methods because order is important



8
9
10
11
12
# File 'lib/germinate/transform_process.rb', line 8

def ordered_transforms
  %w[expand_insertions strip_blanks erase_comments
     uncomment         join_lines   rstrip_lines   
     pipeline          bracket      flatten_nested]
end