Class: PactBroker::Pacts::Diff

Inherits:
Object
  • Object
show all
Includes:
Repositories
Defined in:
lib/pact_broker/pacts/diff.rb

Defined Under Namespace

Classes: DiffDecorator

Instance Method Summary collapse

Methods included from Repositories

#branch_version_repository, #label_repository, #matrix_repository, #pact_repository, #pacticipant_repository, #tag_repository, #verification_repository, #version_repository, #webhook_repository

Instance Method Details

#process(params, comparison_pact_params = nil, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pact_broker/pacts/diff.rb', line 15

def process(params, comparison_pact_params = nil, options = {})
  pact = find_pact(params)
  comparison_pact = comparison_pact_params ? find_pact(comparison_pact_params) : pact_repository.find_previous_distinct_pact(pact)

  if comparison_pact
    next_pact = pact_repository.find_next_pact(comparison_pact) || pact
    DiffDecorator.new(pact, comparison_pact, next_pact, params[:base_url], { raw: options[:raw] }).to_text
  else
    no_previous_version_message pact
  end
end