class PactBroker::Pacts::VerifiablePact

Attributes

non_pending_provider_tags[R]
pending[R]
pending_provider_tags[R]
provider_branch[R]
selectors[R]
wip[R]

Public Class Methods

create_for_wip_for_provider_branch(pact, selectors, provider_branch) click to toggle source

rubocop: enable Metrics/ParameterLists

# File lib/pact_broker/pacts/verifiable_pact.rb, line 22
def self.create_for_wip_for_provider_branch(pact, selectors, provider_branch)
  new(pact, selectors, true, [], [], provider_branch, true)
end
create_for_wip_for_provider_tags(pact, selectors, pending_provider_tags) click to toggle source
# File lib/pact_broker/pacts/verifiable_pact.rb, line 26
def self.create_for_wip_for_provider_tags(pact, selectors, pending_provider_tags)
  new(pact, selectors, true, pending_provider_tags, [], nil, true)
end
deduplicate(verifiable_pacts) click to toggle source
# File lib/pact_broker/pacts/verifiable_pact.rb, line 30
def self.deduplicate(verifiable_pacts)
  verifiable_pacts
    .group_by { | verifiable_pact | verifiable_pact.pact_version_sha }
    .values
    .collect { | verifiable_pact | verifiable_pact.reduce(&:+) }
end
new(pact, selectors, pending = nil, pending_provider_tags = [], non_pending_provider_tags = [], provider_branch = nil, wip = false) click to toggle source

rubocop: disable Metrics/ParameterLists TODO refactor this constructor

Calls superclass method
# File lib/pact_broker/pacts/verifiable_pact.rb, line 11
def initialize(pact, selectors, pending = nil, pending_provider_tags = [], non_pending_provider_tags = [], provider_branch = nil, wip = false)
  super(pact)
  @pending = pending
  @selectors = selectors
  @pending_provider_tags = pending_provider_tags
  @non_pending_provider_tags = non_pending_provider_tags
  @provider_branch = provider_branch
  @wip = wip
end

Public Instance Methods

+(other) click to toggle source
# File lib/pact_broker/pacts/verifiable_pact.rb, line 45
def + other
  if pact_version_sha != other.pact_version_sha
    raise PactBroker::Error.new("Can't merge two verifiable pacts with different pact content")
  end

  if provider_branch != other.provider_branch
    raise PactBroker::Error.new("Can't merge two verifiable pacts with different provider_branch")
  end

  latest_pact = [self, other].sort_by(&:consumer_version_order).last.__getobj__()

  VerifiablePact.new(
    latest_pact,
    selectors + other.selectors,
    pending || other.pending,
    pending_provider_tags + other.pending_provider_tags,
    non_pending_provider_tags + other.non_pending_provider_tags,
    provider_branch,
    wip || other.wip
  )
end
<=>(other) click to toggle source
# File lib/pact_broker/pacts/verifiable_pact.rb, line 67
def <=> other
  if self.consumer_name != other.consumer_name
    return self.consumer_name <=> other.consumer_name
  else
    return self.consumer_version.order <=> other.consumer_version.order
  end
end
consumer_version_order() click to toggle source
# File lib/pact_broker/pacts/verifiable_pact.rb, line 75
def consumer_version_order
  __getobj__().consumer_version.order
end
pending?() click to toggle source
# File lib/pact_broker/pacts/verifiable_pact.rb, line 37
def pending?
  pending
end
wip?() click to toggle source
# File lib/pact_broker/pacts/verifiable_pact.rb, line 41
def wip?
  wip
end