Sha256: a72a5a90944709cc1028132340f0e1d7e7c03c9ede35aed52b23a258a5989a8a
Contents?: true
Size: 549 Bytes
Versions: 4
Compression:
Stored size: 549 Bytes
Contents
require "diff/lcs" module Zonesync class Diff < Struct.new(:from, :to) def self.call(from:, to:) new(from, to).call end def call changes = ::Diff::LCS.sdiff(from.diffable_records, to.diffable_records) changes.map do |change| case change.action when "-" [:remove, [change.old_element.to_h]] when "!" [:change, [change.old_element.to_h, change.new_element.to_h]] when "+" [:add, [change.new_element.to_h]] end end.compact end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
zonesync-0.7.0 | lib/zonesync/diff.rb |
zonesync-0.6.1 | lib/zonesync/diff.rb |
zonesync-0.6.0 | lib/zonesync/diff.rb |
zonesync-0.5.2 | lib/zonesync/diff.rb |