Sha256: bc3b1545bf515e39bfd53d6853ac019e1d06d78cbfa22893a0dab65b6ce47299

Contents?: true

Size: 860 Bytes

Versions: 89

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

module Hashdiff
  # @private
  # Used to compare arrays using the lcs algorithm
  class LcsCompareArrays
    class << self
      def call(obj1, obj2, opts = {})
        result = []

        changeset = Hashdiff.diff_array_lcs(obj1, obj2, opts) do |lcs|
          # use a's index for similarity
          lcs.each do |pair|
            prefix = Hashdiff.prefix_append_array_index(opts[:prefix], pair[0], opts)

            result.concat(Hashdiff.diff(obj1[pair[0]], obj2[pair[1]], opts.merge(prefix: prefix)))
          end
        end

        changeset.each do |change|
          next if change[0] != '-' && change[0] != '+'

          change_key = Hashdiff.prefix_append_array_index(opts[:prefix], change[1], opts)

          result << [change[0], change_key, change[2]]
        end

        result
      end
    end
  end
end

Version data entries

89 entries across 87 versions & 8 rubygems

Version Path
hashdiff-1.1.2 lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.1.1/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.1.1/lib/hashdiff/lcs_compare_arrays.rb
hashdiff-1.1.1 lib/hashdiff/lcs_compare_arrays.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/hashdiff-1.1.0/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.1.0/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.1.0/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.1.0/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.1.0/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.1.0/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.1.0/lib/hashdiff/lcs_compare_arrays.rb
hashdiff-1.1.0 lib/hashdiff/lcs_compare_arrays.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb