Method: Junoser::Squash#transform

Defined in:
lib/junoser/squash.rb

#transformObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/junoser/squash.rb', line 15

def transform
  config = Junoser::Input.new(@input).read.split("\n")
  config.each do |l|
    l.strip!
    case l
    when /^(set|deactivate) /
      @lines << l
    when /^delete /
      delete_lines delete_pattern(l.gsub(/^delete /, 'set '))
    when /^activate /
      delete_lines l.gsub(/^activate /, 'deactivate ')
    when /^insert (.*) before (.*)/
      insert_before "set #{::Regexp.last_match(1)}", ::Regexp.last_match(2)
    when /^insert (.*) after (.*)/
      insert_after "set #{::Regexp.last_match(1)}", ::Regexp.last_match(2)
    end
  end

  @lines.uniq!
  remove_command_context(@lines).map(&:strip).join("\n")
end