Class: Unparser::Diff
- Inherits:
-
Object
- Object
- Unparser::Diff
- Includes:
- Adamantium
- Defined in:
- lib/unparser/diff.rb
Overview
Class to create diffs from source code
Constant Summary collapse
- ADDITION =
'+'
- DELETION =
'-'
- NEWLINE =
"\n"
Class Method Summary collapse
-
.build(old, new) ⇒ Diff
Build new object from source strings.
Instance Method Summary collapse
-
#colorized_diff ⇒ String?
Colorized unified source diff between old and new.
-
#diff ⇒ String?
Unified source diff between old and new.
Class Method Details
.build(old, new) ⇒ Diff
Build new object from source strings
46 47 48 |
# File 'lib/unparser/diff.rb', line 46 def self.build(old, new) new(lines(old), lines(new)) end |
Instance Method Details
#colorized_diff ⇒ String?
Colorized unified source diff between old and new
33 34 35 36 37 |
# File 'lib/unparser/diff.rb', line 33 def colorized_diff return unless diff diff.lines.map(&self.class.method(:colorize_line)).join end |
#diff ⇒ String?
Unified source diff between old and new
19 20 21 22 23 |
# File 'lib/unparser/diff.rb', line 19 def diff return if diffs.empty? minimized_hunk.diff(:unified) + NEWLINE end |