Class: Test::Unit::Diff::ReadableDiffer
- Defined in:
- lib/test/unit/diff.rb
Instance Method Summary collapse
Methods inherited from Differ
Constructor Details
This class inherits a constructor from Test::Unit::Diff::Differ
Instance Method Details
#diff(options = {}) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/test/unit/diff.rb', line 270 def diff(={}) result = [] matcher = SequenceMatcher.new(@from, @to) matcher.operations.each do |args| tag, from_start, from_end, to_start, to_end = args case tag when :replace result.concat(diff_lines(from_start, from_end, to_start, to_end)) when :delete result.concat(tag_deleted(@from[from_start...from_end])) when :insert result.concat(tag_inserted(@to[to_start...to_end])) when :equal result.concat(tag_equal(@from[from_start...from_end])) else raise "unknown tag: #{tag}" end end result end |