lib/eco/data/locations/node_diff/nodes_diff.rb in eco-helpers-3.0.4 vs lib/eco/data/locations/node_diff/nodes_diff.rb in eco-helpers-3.0.5

- old
+ new

@@ -26,10 +26,11 @@ def diffs @diffs ||= super.select do |dff| # discard entries that are to be inserted and archived at the same time next false if dff.insert? && dff.archive?(validate: false) + dff.unarchive? || dff.id_name? || dff.insert? || dff.move? || dff.archive? end end @@ -65,36 +66,46 @@ end def diffs_summary # rubocop:disable Metrics/AbcSize comp = "(#{source_2.count} input nodes VS #{source_1.count} live nodes)" return "There were no differences identified #{comp}" if diffs.empty? + msg = [] + msg << "Identified #{diffs.count} differences #{comp}:" msg << when_present(insert) do |count| " • #{count} nodes to insert" end + msg << when_present(update) do |count| " • #{count} nodes to update" end + msg << when_present(unarchive) do |count| " • #{count} nodes to unarchive (includes ancestors of target nodes)" end + msg << when_present(id) do |count| " • #{count} nodes to change id\n" end + msg << when_present(name) do |count| " • #{count} nodes to change name" end + msg << when_present(classifications) do |count| " • #{count} nodes to change classifications" end + msg << when_present(move) do |count| " • #{count} nodes to move" end + msg << when_present(archive) do |count| " • #{count} nodes to archive" end + msg.compact.join("\n") end alias_method :unarchive_src, :unarchive @@ -106,11 +117,13 @@ private def when_present(list, default = nil) raise ArgumentError, "Expecting block but not given" unless block_given? + count = list.count return yield(count) if count&.positive? + default end def mark_implicit_unarchive! @implicit_unarchive = source_results.select do |result|