Class: Moku6::Differ

Inherits:
Object
  • Object
show all
Defined in:
lib/moku6/differ.rb

Overview

Detects breaking changes between two catalogs (design sections 13 / 16). Breaking changes (error): action removed, required field added, field type changed.

Instance Method Summary collapse

Constructor Details

#initialize(old_catalog, new_catalog) ⇒ Differ

: (Catalog old_catalog, Catalog new_catalog) -> void



12
13
14
15
# File 'lib/moku6/differ.rb', line 12

def initialize(old_catalog, new_catalog)
  @old = old_catalog
  @new = new_catalog
end

Instance Method Details

#runObject

: () -> Result



18
19
20
21
22
23
24
25
26
27
# File 'lib/moku6/differ.rb', line 18

def run
  offenses = removed_actions
  @new.events.each do |new_event|
    old_event = @old.find(new_event.action)
    next unless old_event

    offenses.concat(field_changes(old_event, new_event))
  end
  Result.new(offenses)
end