Class: Mutant::Differ

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/differ.rb

Overview

Class to create diffs from source code

Instance Method Summary collapse

Instance Method Details

#colorized_diffString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return colorized source diff

Returns:

  • (String)


29
30
31
32
33
# File 'lib/mutant/differ.rb', line 29

def colorized_diff
  diff.lines.map do |line|
    self.class.colorize_line(line)
  end.join
end

#diffString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return source diff

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
# File 'lib/mutant/differ.rb', line 12

def diff
  output = ''
  @diffs.each do |piece|
    hunk = Diff::LCS::Hunk.new(@old, @new, piece, CONTEXT_LINES, length_difference)
    output << hunk.diff(FORMAT)
    output << "\n"
  end
  output
end