Class: Archimate::Diff::Conflicts::BaseConflict Abstract
- Inherits:
-
Object
- Object
- Archimate::Diff::Conflicts::BaseConflict
- Defined in:
- lib/archimate/diff/conflicts/base_conflict.rb
Overview
This class is abstract.
BaseConflict
Direct Known Subclasses
DeletedItemsChildUpdatedConflict, DeletedItemsReferencedConflict, PathConflict
Instance Method Summary collapse
- #conflicts ⇒ Object
- #diff_combinations ⇒ Object
-
#diff_iterations ⇒ Object
By default our conflict tests are not associative to we need to run [local, remote] and [remote, local] through the tests.
- #filter1 ⇒ Object
- #filter2 ⇒ Object
-
#initialize(base_local_diffs, base_remote_diffs) ⇒ BaseConflict
constructor
A new instance of BaseConflict.
Constructor Details
#initialize(base_local_diffs, base_remote_diffs) ⇒ BaseConflict
Returns a new instance of BaseConflict.
8 9 10 11 12 13 |
# File 'lib/archimate/diff/conflicts/base_conflict.rb', line 8 def initialize(base_local_diffs, base_remote_diffs) @base_local_diffs = base_local_diffs @base_remote_diffs = base_remote_diffs @associative = false @diff_iterations = nil end |
Instance Method Details
#conflicts ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/archimate/diff/conflicts/base_conflict.rb', line 23 def conflicts = ProgressIndicator.new(total: diff_iterations.size, title: "Analyzing Conflicts") diff_iterations.each_with_object([]) do |(md1, md2), conflicts| .increment conflicts.concat( md1.map { |diff1| [diff1, md2.select(&method(:diff_conflicts).curry[diff1])] } .reject { |_diff1, diff2| diff2.empty? } .map { |diff1, diff2_ary| Conflict.new(diff1, diff2_ary, describe) } ) end ensure .finish end |
#diff_combinations ⇒ Object
37 38 39 40 |
# File 'lib/archimate/diff/conflicts/base_conflict.rb', line 37 def diff_combinations combos = [@base_local_diffs, @base_remote_diffs] @associative ? [combos] : combos.permutation(2) end |
#diff_iterations ⇒ Object
By default our conflict tests are not associative to we need to run
- local, remote
-
and [remote, local] through the tests.
44 45 46 47 48 49 |
# File 'lib/archimate/diff/conflicts/base_conflict.rb', line 44 def diff_iterations @diff_iterations ||= diff_combinations.map do |local_diffs, remote_diffs| [local_diffs.select(&filter1), remote_diffs.select(&filter2)] end end |
#filter1 ⇒ Object
15 16 17 |
# File 'lib/archimate/diff/conflicts/base_conflict.rb', line 15 def filter1 ->(_diff) { true } end |
#filter2 ⇒ Object
19 20 21 |
# File 'lib/archimate/diff/conflicts/base_conflict.rb', line 19 def filter2 ->(_diff) { true } end |