Sha256: e234723ce663cad0e618ca6a25790ffc1b4720f1bf139e86ac80469fca93b4f1

Contents?: true

Size: 815 Bytes

Versions: 28

Compression:

Stored size: 815 Bytes

Contents

require "digest/sha1"
require "pact_broker/configuration"
require "pact_broker/pacts/sort_content"
require "pact_broker/pacts/parse"
require "pact_broker/pacts/content"

module PactBroker
  module Pacts
    class GenerateSha
      def self.call json_content, _options = {}
        content_for_sha = if PactBroker.configuration.base_equality_only_on_content_that_affects_verification_results
                            extract_verifiable_content_for_sha(json_content)
                          else
                            json_content
                          end
        Digest::SHA1.hexdigest(content_for_sha)
      end

      def self.extract_verifiable_content_for_sha json_content
        Content.from_json(json_content).sort.content_that_affects_verification_results.to_json
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
pact_broker-2.100.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.99.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.98.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.97.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.96.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.95.1 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.95.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.94.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.93.4 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.93.3 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.93.2 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.93.1 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.93.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.92.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.91.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.90.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.89.1 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.89.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.88.0 lib/pact_broker/pacts/generate_sha.rb
pact_broker-2.87.0 lib/pact_broker/pacts/generate_sha.rb