Sha256: ace43c31d458c91604ca6ade52e18a2db630ff38791252cf4db66984f117d1bf

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

require 'fattr'
require File.expand_path("shared_style_attributes", File.dirname(__FILE__))

class Germinate::TransformProcess
  fattr(:log) { Germinate.logger }
  
  # We can't just use TextTransforms.singleton_methods because order is important
  def ordered_transforms
    %w[expand_insertions strip_blanks erase_comments
       uncomment         join_lines   rstrip_lines   
       pipeline          bracket      flatten_nested]
  end

  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
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
devver-germinate-1.2.0 lib/germinate/transform_process.rb
germinate-1.2.0 lib/germinate/transform_process.rb