Class: Archimate::Diff::Conflicts
- Inherits:
-
Object
- Object
- Archimate::Diff::Conflicts
- Extended by:
- Forwardable
- Includes:
- Logging
- Defined in:
- lib/archimate/diff/conflicts.rb,
lib/archimate/diff/conflicts/base_conflict.rb,
lib/archimate/diff/conflicts/path_conflict.rb,
lib/archimate/diff/conflicts/deleted_items_referenced_conflict.rb,
lib/archimate/diff/conflicts/deleted_items_child_updated_conflict.rb
Defined Under Namespace
Classes: BaseConflict, DeletedItemsChildUpdatedConflict, DeletedItemsReferencedConflict, PathConflict
Instance Attribute Summary collapse
-
#base_local_diffs ⇒ Object
readonly
Returns the value of attribute base_local_diffs.
-
#base_remote_diffs ⇒ Object
readonly
Returns the value of attribute base_remote_diffs.
Instance Method Summary collapse
- #conflicting_diffs ⇒ Object
- #conflicts ⇒ Object
-
#initialize(base_local_diffs, base_remote_diffs) ⇒ Conflicts
constructor
A new instance of Conflicts.
-
#resolve ⇒ Object
TODO: refactor this method elsewhere resolve iterates through the set of conflicting diffs asking the user (if running interactively) and return the set of diffs that can be applied.
- #to_s ⇒ Object
- #unconflicted_diffs ⇒ Object
Constructor Details
#initialize(base_local_diffs, base_remote_diffs) ⇒ Conflicts
Returns a new instance of Conflicts.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/archimate/diff/conflicts.rb', line 26 def initialize(base_local_diffs, base_remote_diffs) @base_local_diffs = base_local_diffs @base_remote_diffs = base_remote_diffs @conflict_finders = [PathConflict, DeletedItemsChildUpdatedConflict, DeletedItemsReferencedConflict] @conflicts = nil @conflicting_diffs = nil @unconflicted_diffs = nil # TODO: consider making this an argument @conflict_resolver = Cli::ConflictResolver.new end |
Instance Attribute Details
#base_local_diffs ⇒ Object (readonly)
Returns the value of attribute base_local_diffs.
15 16 17 |
# File 'lib/archimate/diff/conflicts.rb', line 15 def base_local_diffs @base_local_diffs end |
#base_remote_diffs ⇒ Object (readonly)
Returns the value of attribute base_remote_diffs.
16 17 18 |
# File 'lib/archimate/diff/conflicts.rb', line 16 def base_remote_diffs @base_remote_diffs end |
Instance Method Details
#conflicting_diffs ⇒ Object
65 66 67 |
# File 'lib/archimate/diff/conflicts.rb', line 65 def conflicting_diffs @conflicting_diffs ||= conflicts.map(&:diffs).flatten end |
#conflicts ⇒ Object
61 62 63 |
# File 'lib/archimate/diff/conflicts.rb', line 61 def conflicts @conflicts ||= find_conflicts end |
#resolve ⇒ Object
TODO: refactor this method elsewhere resolve iterates through the set of conflicting diffs asking the user (if running interactively) and return the set of diffs that can be applied.
To keep diffs reasonably human readable in logs, the local diffs should be applied first followed by the remote diffs.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/archimate/diff/conflicts.rb', line 43 def resolve debug do " Filtering out \#{conflicts.size} conflicts from \#{base_local_diffs.size + base_remote_diffs.size} diffs\n Remaining diffs \#{unconflicted_diffs.size}\n MSG\n end\n\n conflicts.each_with_object(unconflicted_diffs) do |conflict, diffs|\n # TODO: this will result in diffs being out of order from their\n # original order. diffs should be flagged as conflicted and\n # this method should instead remove the conflicted flag.\n diffs.concat(@conflict_resolver.resolve(conflict))\n # TODO: if the conflict is resolved, it should be removed from the\n # @conflicts array.\n end\nend\n" |
#to_s ⇒ Object
74 75 76 |
# File 'lib/archimate/diff/conflicts.rb', line 74 def to_s "Conflicts:\n\n#{conflicts.map(&:to_s).join("\n\n")}\n" end |
#unconflicted_diffs ⇒ Object
69 70 71 72 |
# File 'lib/archimate/diff/conflicts.rb', line 69 def unconflicted_diffs @unconflicted_diffs ||= (base_local_diffs + base_remote_diffs) - conflicting_diffs end |