Class: PactBroker::Pacts::VerifiablePact
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- PactBroker::Pacts::VerifiablePact
- Defined in:
- lib/pact_broker/pacts/verifiable_pact.rb
Instance Attribute Summary collapse
-
#non_pending_provider_tags ⇒ Object
readonly
Returns the value of attribute non_pending_provider_tags.
-
#pending ⇒ Object
readonly
Returns the value of attribute pending.
-
#pending_provider_tags ⇒ Object
readonly
Returns the value of attribute pending_provider_tags.
-
#provider_branch ⇒ Object
readonly
Returns the value of attribute provider_branch.
-
#selectors ⇒ Object
readonly
Returns the value of attribute selectors.
-
#wip ⇒ Object
readonly
Returns the value of attribute wip.
Class Method Summary collapse
-
.create_for_wip_for_provider_branch(pact, selectors, provider_branch) ⇒ Object
rubocop: enable Metrics/ParameterLists.
- .create_for_wip_for_provider_tags(pact, selectors, pending_provider_tags) ⇒ Object
- .deduplicate(verifiable_pacts) ⇒ Object
Instance Method Summary collapse
- #+(other) ⇒ Object
- #<=>(other) ⇒ Object
- #consumer_version_order ⇒ Object
-
#initialize(pact, selectors, pending = nil, pending_provider_tags = [], non_pending_provider_tags = [], provider_branch = nil, wip = false) ⇒ VerifiablePact
constructor
rubocop: disable Metrics/ParameterLists TODO refactor this constructor.
- #pending? ⇒ Boolean
- #wip? ⇒ Boolean
Constructor Details
#initialize(pact, selectors, pending = nil, pending_provider_tags = [], non_pending_provider_tags = [], provider_branch = nil, wip = false) ⇒ VerifiablePact
rubocop: disable Metrics/ParameterLists TODO refactor this constructor
11 12 13 14 15 16 17 18 19 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 11 def initialize(pact, selectors, pending = nil, = [], = [], provider_branch = nil, wip = false) super(pact) @pending = pending @selectors = selectors @pending_provider_tags = @non_pending_provider_tags = @provider_branch = provider_branch @wip = wip end |
Instance Attribute Details
#non_pending_provider_tags ⇒ Object (readonly)
Returns the value of attribute non_pending_provider_tags.
7 8 9 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 7 def @non_pending_provider_tags end |
#pending ⇒ Object (readonly)
Returns the value of attribute pending.
7 8 9 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 7 def pending @pending end |
#pending_provider_tags ⇒ Object (readonly)
Returns the value of attribute pending_provider_tags.
7 8 9 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 7 def @pending_provider_tags end |
#provider_branch ⇒ Object (readonly)
Returns the value of attribute provider_branch.
7 8 9 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 7 def provider_branch @provider_branch end |
#selectors ⇒ Object (readonly)
Returns the value of attribute selectors.
7 8 9 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 7 def selectors @selectors end |
#wip ⇒ Object (readonly)
Returns the value of attribute wip.
7 8 9 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 7 def wip @wip end |
Class Method Details
.create_for_wip_for_provider_branch(pact, selectors, provider_branch) ⇒ Object
rubocop: enable Metrics/ParameterLists
22 23 24 |
# 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) ⇒ Object
26 27 28 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 26 def self.(pact, selectors, ) new(pact, selectors, true, , [], nil, true) end |
.deduplicate(verifiable_pacts) ⇒ Object
30 31 32 33 34 35 |
# 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 |
Instance Method Details
#+(other) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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, + other., + other., provider_branch, wip || other.wip ) end |
#<=>(other) ⇒ Object
67 68 69 70 71 72 73 |
# 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 ⇒ Object
75 76 77 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 75 def consumer_version_order __getobj__().consumer_version.order end |
#pending? ⇒ Boolean
37 38 39 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 37 def pending? pending end |
#wip? ⇒ Boolean
41 42 43 |
# File 'lib/pact_broker/pacts/verifiable_pact.rb', line 41 def wip? wip end |