Class: CodeComparison

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_diff/code_comparison.rb

Instance Method Summary collapse

Constructor Details

#initialize(old_signatures, new_signatures) ⇒ CodeComparison

Returns a new instance of CodeComparison.



27
28
29
30
# File 'lib/ruby_diff/code_comparison.rb', line 27

def initialize(old_signatures, new_signatures)
  @old = old_signatures
  @new = new_signatures
end

Instance Method Details

#changesObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ruby_diff/code_comparison.rb', line 32

def changes
  changes = []
  seen = Set.new
  @old.each do |sig, code_object|
    seen << sig
    if other_code_object = @new[sig]
      if code_object != other_code_object
        changes << changed(sig, code_object, sig, other_code_object)
      end
    else
      changes << removal(sig, code_object)
    end
  end
  
  @new.each do |sig, code_object|
    if !seen.include?(sig)
      changes << addition(sig, code_object)
    end
  end
  
  changes
end