Class: Mutant::Differ
- Inherits:
-
Object
- Object
- Mutant::Differ
- Includes:
- Adamantium::Flat
- Defined in:
- lib/mutant/differ.rb
Overview
Class to create diffs from source code
Class Method Summary collapse
-
.build(old, new) ⇒ Differ
private
Return new object.
Instance Method Summary collapse
-
#colorized_diff ⇒ String?
private
Return colorized source diff.
-
#diff ⇒ String?
private
Return source diff.
Class Method Details
.build(old, new) ⇒ Differ
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 new object
62 63 64 |
# File 'lib/mutant/differ.rb', line 62 def self.build(old, new) new(lines(old), lines(new)) end |
Instance Method Details
#colorized_diff ⇒ String?
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
45 46 47 48 49 50 |
# File 'lib/mutant/differ.rb', line 45 def colorized_diff return unless diff diff.lines.map do |line| self.class.colorize_line(line) end.join end |
#diff ⇒ String?
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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mutant/differ.rb', line 18 def diff case diffs.length when 0 nil when 1 Diff::LCS::Hunk.new(old, new, diffs.first, max_length, 0) .diff(:unified) << "\n" else $stderr.puts( 'Mutation resulted in more than one diff, should not happen! ' + 'PLS report a bug!' ) nil end end |