Sha256: 9ece4749603b262191a705ec0d4fac54623a79ea720e147761842c620fdf3a5b
Contents?: true
Size: 545 Bytes
Versions: 9
Compression:
Stored size: 545 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
9 entries across 9 versions & 1 rubygems