Class: PactBroker::Domain::IndexItem
- Inherits:
-
Object
- Object
- PactBroker::Domain::IndexItem
- Defined in:
- lib/pact_broker/domain/index_item.rb
Instance Attribute Summary collapse
-
#consumer ⇒ Object
readonly
Returns the value of attribute consumer.
-
#latest_pact ⇒ Object
readonly
Returns the value of attribute latest_pact.
-
#latest_verification ⇒ Object
readonly
Returns the value of attribute latest_verification.
-
#latest_verification_latest_tags ⇒ Object
readonly
Returns the value of attribute latest_verification_latest_tags.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#triggered_webhooks ⇒ Object
readonly
Returns the value of attribute triggered_webhooks.
-
#webhooks ⇒ Object
readonly
Returns the value of attribute webhooks.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #any_webhooks? ⇒ Boolean
- #connected?(other) ⇒ Boolean
- #consumer_name ⇒ Object
- #consumer_version ⇒ Object
- #consumer_version_number ⇒ Object
- #eq?(other) ⇒ Boolean
- #ever_verified? ⇒ Boolean
- #include?(pacticipant) ⇒ Boolean
-
#initialize(consumer, provider, latest_pact = nil, latest = true, latest_verification = nil, webhooks = [], triggered_webhooks = [], tags = [], latest_verification_latest_tags = []) ⇒ IndexItem
constructor
A new instance of IndexItem.
- #last_webhook_execution_date ⇒ Object
- #latest? ⇒ Boolean
- #latest_verification_provider_version_number ⇒ Object
- #latest_verification_successful? ⇒ Boolean
- #pact_changed_since_last_verification? ⇒ Boolean
- #pacticipants ⇒ Object
- #provider_name ⇒ Object
- #provider_version ⇒ Object
- #provider_version_number ⇒ Object
-
#tag_names ⇒ Object
these are the consumer tag names for which this pact publication is the latest with that tag.
- #to_a ⇒ Object
- #to_s ⇒ Object
- #verification_status ⇒ Object
- #webhook_status ⇒ Object
Constructor Details
#initialize(consumer, provider, latest_pact = nil, latest = true, latest_verification = nil, webhooks = [], triggered_webhooks = [], tags = [], latest_verification_latest_tags = []) ⇒ IndexItem
Returns a new instance of IndexItem.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pact_broker/domain/index_item.rb', line 10 def initialize consumer, provider, latest_pact = nil, latest = true, latest_verification = nil, webhooks = [], triggered_webhooks = [], = [], = [] @consumer = consumer @provider = provider @latest_pact = latest_pact @latest = latest @latest_verification = latest_verification @webhooks = webhooks @triggered_webhooks = triggered_webhooks @tags = @latest_verification_latest_tags = end |
Instance Attribute Details
#consumer ⇒ Object (readonly)
Returns the value of attribute consumer.
8 9 10 |
# File 'lib/pact_broker/domain/index_item.rb', line 8 def consumer @consumer end |
#latest_pact ⇒ Object (readonly)
Returns the value of attribute latest_pact.
8 9 10 |
# File 'lib/pact_broker/domain/index_item.rb', line 8 def latest_pact @latest_pact end |
#latest_verification ⇒ Object (readonly)
Returns the value of attribute latest_verification.
8 9 10 |
# File 'lib/pact_broker/domain/index_item.rb', line 8 def latest_verification @latest_verification end |
#latest_verification_latest_tags ⇒ Object (readonly)
Returns the value of attribute latest_verification_latest_tags.
8 9 10 |
# File 'lib/pact_broker/domain/index_item.rb', line 8 def @latest_verification_latest_tags end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
8 9 10 |
# File 'lib/pact_broker/domain/index_item.rb', line 8 def provider @provider end |
#triggered_webhooks ⇒ Object (readonly)
Returns the value of attribute triggered_webhooks.
8 9 10 |
# File 'lib/pact_broker/domain/index_item.rb', line 8 def triggered_webhooks @triggered_webhooks end |
#webhooks ⇒ Object (readonly)
Returns the value of attribute webhooks.
8 9 10 |
# File 'lib/pact_broker/domain/index_item.rb', line 8 def webhooks @webhooks end |
Class Method Details
.create(consumer, provider, latest_pact, latest, latest_verification, webhooks = [], triggered_webhooks = [], tags = [], latest_verification_latest_tags = []) ⇒ Object
22 23 24 |
# File 'lib/pact_broker/domain/index_item.rb', line 22 def self.create consumer, provider, latest_pact, latest, latest_verification, webhooks = [], triggered_webhooks = [], = [], = [] new consumer, provider, latest_pact, latest, latest_verification, webhooks, triggered_webhooks, , end |
Instance Method Details
#<=>(other) ⇒ Object
124 125 126 127 128 |
# File 'lib/pact_broker/domain/index_item.rb', line 124 def <=> other comp = consumer_name <=> other.consumer_name return comp unless comp == 0 provider_name <=> other.provider_name end |
#==(other) ⇒ Object
34 35 36 |
# File 'lib/pact_broker/domain/index_item.rb', line 34 def == other eq?(other) end |
#any_webhooks? ⇒ Boolean
76 77 78 |
# File 'lib/pact_broker/domain/index_item.rb', line 76 def any_webhooks? @webhooks.any? end |
#connected?(other) ⇒ Boolean
116 117 118 |
# File 'lib/pact_broker/domain/index_item.rb', line 116 def connected? other include?(other.consumer) || include?(other.provider) end |
#consumer_name ⇒ Object
38 39 40 |
# File 'lib/pact_broker/domain/index_item.rb', line 38 def consumer_name consumer.name end |
#consumer_version ⇒ Object
58 59 60 |
# File 'lib/pact_broker/domain/index_item.rb', line 58 def consumer_version @latest_pact.consumer_version end |
#consumer_version_number ⇒ Object
54 55 56 |
# File 'lib/pact_broker/domain/index_item.rb', line 54 def consumer_version_number @latest_pact.consumer_version_number end |
#eq?(other) ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/pact_broker/domain/index_item.rb', line 26 def eq? other IndexItem === other && other.consumer == consumer && other.provider == provider && other.latest_pact == latest_pact && other.latest? == latest? && other.latest_verification == latest_verification && other.webhooks == webhooks end |
#ever_verified? ⇒ Boolean
92 93 94 |
# File 'lib/pact_broker/domain/index_item.rb', line 92 def ever_verified? !!latest_verification end |
#include?(pacticipant) ⇒ Boolean
120 121 122 |
# File 'lib/pact_broker/domain/index_item.rb', line 120 def include? pacticipant pacticipant.id == consumer.id || pacticipant.id == provider.id end |
#last_webhook_execution_date ⇒ Object
84 85 86 |
# File 'lib/pact_broker/domain/index_item.rb', line 84 def last_webhook_execution_date @last_webhook_execution_date ||= @triggered_webhooks.any? ? @triggered_webhooks.sort{|a, b| a.created_at <=> b.created_at }.last.created_at : nil end |
#latest? ⇒ Boolean
50 51 52 |
# File 'lib/pact_broker/domain/index_item.rb', line 50 def latest? @latest end |
#latest_verification_provider_version_number ⇒ Object
108 109 110 |
# File 'lib/pact_broker/domain/index_item.rb', line 108 def latest_verification_provider_version_number latest_verification.provider_version.number end |
#latest_verification_successful? ⇒ Boolean
100 101 102 |
# File 'lib/pact_broker/domain/index_item.rb', line 100 def latest_verification_successful? latest_verification.success end |
#pact_changed_since_last_verification? ⇒ Boolean
104 105 106 |
# File 'lib/pact_broker/domain/index_item.rb', line 104 def pact_changed_since_last_verification? latest_verification.pact_version_sha != latest_pact.pact_version_sha end |
#pacticipants ⇒ Object
112 113 114 |
# File 'lib/pact_broker/domain/index_item.rb', line 112 def pacticipants [consumer, provider] end |
#provider_name ⇒ Object
42 43 44 |
# File 'lib/pact_broker/domain/index_item.rb', line 42 def provider_name provider.name end |
#provider_version ⇒ Object
62 63 64 |
# File 'lib/pact_broker/domain/index_item.rb', line 62 def provider_version @latest_verification ? @latest_verification.provider_version : nil end |
#provider_version_number ⇒ Object
66 67 68 |
# File 'lib/pact_broker/domain/index_item.rb', line 66 def provider_version_number @latest_verification ? @latest_verification.provider_version_number : nil end |
#tag_names ⇒ Object
these are the consumer tag names for which this pact publication is the latest with that tag
72 73 74 |
# File 'lib/pact_broker/domain/index_item.rb', line 72 def tag_names @tags end |
#to_a ⇒ Object
134 135 136 |
# File 'lib/pact_broker/domain/index_item.rb', line 134 def to_a [consumer, provider] end |
#to_s ⇒ Object
130 131 132 |
# File 'lib/pact_broker/domain/index_item.rb', line 130 def to_s "Pact between #{consumer_name} #{consumer_version_number} and #{provider_name} #{provider_version_number}" end |
#verification_status ⇒ Object
88 89 90 |
# File 'lib/pact_broker/domain/index_item.rb', line 88 def verification_status @verification_status ||= PactBroker::Verifications::Status.new(@latest_pact, @latest_verification).to_sym end |
#webhook_status ⇒ Object
80 81 82 |
# File 'lib/pact_broker/domain/index_item.rb', line 80 def webhook_status @webhook_status ||= PactBroker::Webhooks::Status.new(@latest_pact, @webhooks, @triggered_webhooks).to_sym end |