Class: PactBroker::Api::Resources::PactContentDiff

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/pact_broker/api/resources/pact_content_diff.rb

Instance Method Summary collapse

Instance Method Details

#allowed_methodsObject



13
14
15
# File 'lib/pact_broker/api/resources/pact_content_diff.rb', line 13

def allowed_methods
  ["GET", "OPTIONS"]
end

#comparison_pact_paramsObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pact_broker/api/resources/pact_content_diff.rb', line 34

def comparison_pact_params
  if identifier_from_path[:comparison_consumer_version_number] || identifier_from_path[:comparison_pact_version_sha]
    comparison_identifier_from_path = identifier_from_path.merge(
        consumer_version_number: identifier_from_path[:comparison_consumer_version_number],
        pact_version_sha: identifier_from_path[:comparison_pact_version_sha],
        base_url: base_url)
    PactBroker::Pacts::PactParams.from_path_info(comparison_identifier_from_path)
  else
    nil
  end
end

#content_types_providedObject



9
10
11
# File 'lib/pact_broker/api/resources/pact_content_diff.rb', line 9

def content_types_provided
  [["text/plain", :to_text]]
end

#pactObject



26
27
28
# File 'lib/pact_broker/api/resources/pact_content_diff.rb', line 26

def pact
  @pact ||= pact_service.find_pact(pact_params)
end

#pact_paramsObject



30
31
32
# File 'lib/pact_broker/api/resources/pact_content_diff.rb', line 30

def pact_params
  @pact_params ||= PactBroker::Pacts::PactParams.from_path_info identifier_from_path
end

#resource_exists?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pact_broker/api/resources/pact_content_diff.rb', line 17

def resource_exists?
  consumer && provider
end

#to_textObject



21
22
23
24
# File 'lib/pact_broker/api/resources/pact_content_diff.rb', line 21

def to_text
  output = PactBroker::Pacts::Diff.new.process pact_params.merge(base_url: base_url), comparison_pact_params, raw: false
  response.body = output
end