Class: Mutant::Diff
- Inherits:
-
Object
- Object
- Mutant::Diff
- Includes:
- Adamantium::Flat
- Defined in:
- lib/mutant/diff.rb
Overview
Class to create diffs from source code
Constant Summary collapse
- ADDITION =
'+'.freeze
- DELETION =
'-'.freeze
- NEWLINE =
"\n".freeze
Class Method Summary collapse
-
.build(old, new) ⇒ Diff
private
Build new object from source strings.
Instance Method Summary collapse
-
#colorized_diff ⇒ String?
private
Colorized unified source diff between old and new.
-
#diff ⇒ String?
private
Unified source diff between old and new.
Class Method Details
.build(old, new) ⇒ Diff
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.
Build new object from source strings
51 52 53 |
# File 'lib/mutant/diff.rb', line 51 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.
Colorized unified source diff between old and new
37 38 39 40 |
# File 'lib/mutant/diff.rb', line 37 def colorized_diff return unless diff diff.lines.map(&self.class.method(:colorize_line)).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.
Unified source diff between old and new
19 20 21 22 23 24 25 |
# File 'lib/mutant/diff.rb', line 19 def diff return if diffs.empty? minimized_hunks.map do |hunk| hunk.diff(:unified) << NEWLINE end.join end |