Class: PactBroker::Pacts::GenerateSha

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/pacts/generate_sha.rb

Class Method Summary collapse

Class Method Details

.call(json_content, _options = {}) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/pact_broker/pacts/generate_sha.rb', line 10

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

.extract_verifiable_content_for_sha(json_content) ⇒ Object



19
20
21
# File 'lib/pact_broker/pacts/generate_sha.rb', line 19

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