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
-
.create(consumer, provider, latest_pact, latest, latest_verification, webhooks = [], triggered_webhooks = [], tags = [], latest_verification_latest_tags = []) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Add logic for ignoring case.
- #==(other) ⇒ Object
- #any_webhooks? ⇒ Boolean
- #compare_name_asc(name1, name2) ⇒ Object
- #compare_number_desc(number1, number2) ⇒ Object
- #connected?(other) ⇒ Boolean
- #consumer_name ⇒ Object
- #consumer_version ⇒ Object
- #consumer_version_number ⇒ Object
- #consumer_version_order ⇒ Object
-
#eq?(other) ⇒ Boolean
rubocop:enable Metrics/ParameterLists.
- #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
rubocop:disable Metrics/ParameterLists.
- #last_activity_date ⇒ Object
- #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
- #pseudo_branch_verification_status ⇒ 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
- #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
rubocop:disable Metrics/ParameterLists
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pact_broker/domain/index_item.rb', line 22 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.
7 8 9 |
# File 'lib/pact_broker/domain/index_item.rb', line 7 def consumer @consumer end |
#latest_pact ⇒ Object (readonly)
Returns the value of attribute latest_pact.
7 8 9 |
# File 'lib/pact_broker/domain/index_item.rb', line 7 def latest_pact @latest_pact end |
#latest_verification ⇒ Object (readonly)
Returns the value of attribute latest_verification.
7 8 9 |
# File 'lib/pact_broker/domain/index_item.rb', line 7 def latest_verification @latest_verification end |
#latest_verification_latest_tags ⇒ Object (readonly)
Returns the value of attribute latest_verification_latest_tags.
7 8 9 |
# File 'lib/pact_broker/domain/index_item.rb', line 7 def @latest_verification_latest_tags end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
7 8 9 |
# File 'lib/pact_broker/domain/index_item.rb', line 7 def provider @provider end |
#triggered_webhooks ⇒ Object (readonly)
Returns the value of attribute triggered_webhooks.
7 8 9 |
# File 'lib/pact_broker/domain/index_item.rb', line 7 def triggered_webhooks @triggered_webhooks end |
#webhooks ⇒ Object (readonly)
Returns the value of attribute webhooks.
7 8 9 |
# File 'lib/pact_broker/domain/index_item.rb', line 7 def webhooks @webhooks end |
Class Method Details
.create(consumer, provider, latest_pact, latest, latest_verification, webhooks = [], triggered_webhooks = [], tags = [], latest_verification_latest_tags = []) ⇒ Object
rubocop:disable Metrics/ParameterLists
16 17 18 |
# File 'lib/pact_broker/domain/index_item.rb', line 16 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
Add logic for ignoring case
136 137 138 139 140 |
# File 'lib/pact_broker/domain/index_item.rb', line 136 def <=> other comp = consumer_name <=> other.consumer_name return comp unless comp == 0 provider_name <=> other.provider_name end |
#==(other) ⇒ Object
43 44 45 |
# File 'lib/pact_broker/domain/index_item.rb', line 43 def == other eq?(other) end |
#any_webhooks? ⇒ Boolean
85 86 87 |
# File 'lib/pact_broker/domain/index_item.rb', line 85 def any_webhooks? @webhooks.any? end |
#compare_name_asc(name1, name2) ⇒ Object
147 148 149 |
# File 'lib/pact_broker/domain/index_item.rb', line 147 def compare_name_asc name1, name2 name1&.downcase <=> name2&.downcase end |
#compare_number_desc(number1, number2) ⇒ Object
151 152 153 154 155 156 157 158 159 |
# File 'lib/pact_broker/domain/index_item.rb', line 151 def compare_number_desc number1, number2 if number1 && number2 number2 <=> number1 elsif number1 1 else -1 end end |
#connected?(other) ⇒ Boolean
121 122 123 |
# File 'lib/pact_broker/domain/index_item.rb', line 121 def connected? other include?(other.consumer) || include?(other.provider) end |
#consumer_name ⇒ Object
47 48 49 |
# File 'lib/pact_broker/domain/index_item.rb', line 47 def consumer_name consumer.name end |
#consumer_version ⇒ Object
67 68 69 |
# File 'lib/pact_broker/domain/index_item.rb', line 67 def consumer_version @latest_pact.consumer_version end |
#consumer_version_number ⇒ Object
59 60 61 |
# File 'lib/pact_broker/domain/index_item.rb', line 59 def consumer_version_number @latest_pact.consumer_version_number end |
#consumer_version_order ⇒ Object
63 64 65 |
# File 'lib/pact_broker/domain/index_item.rb', line 63 def consumer_version_order consumer_version.order end |
#eq?(other) ⇒ Boolean
rubocop:enable Metrics/ParameterLists
35 36 37 38 39 40 41 |
# File 'lib/pact_broker/domain/index_item.rb', line 35 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
101 102 103 |
# File 'lib/pact_broker/domain/index_item.rb', line 101 def ever_verified? !!latest_verification end |
#include?(pacticipant) ⇒ Boolean
125 126 127 |
# File 'lib/pact_broker/domain/index_item.rb', line 125 def include? pacticipant pacticipant.id == consumer.id || pacticipant.id == provider.id end |
#last_activity_date ⇒ Object
169 170 171 |
# File 'lib/pact_broker/domain/index_item.rb', line 169 def last_activity_date @last_activity_date ||= [latest_pact.created_at, latest_verification ? latest_verification.execution_date : nil].compact.max end |
#last_webhook_execution_date ⇒ Object
93 94 95 |
# File 'lib/pact_broker/domain/index_item.rb', line 93 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
55 56 57 |
# File 'lib/pact_broker/domain/index_item.rb', line 55 def latest? @latest end |
#latest_verification_provider_version_number ⇒ Object
113 114 115 |
# File 'lib/pact_broker/domain/index_item.rb', line 113 def latest_verification_provider_version_number latest_verification.provider_version.number end |
#latest_verification_successful? ⇒ Boolean
105 106 107 |
# File 'lib/pact_broker/domain/index_item.rb', line 105 def latest_verification_successful? latest_verification.success end |
#pact_changed_since_last_verification? ⇒ Boolean
109 110 111 |
# File 'lib/pact_broker/domain/index_item.rb', line 109 def pact_changed_since_last_verification? latest_verification.pact_version_sha != latest_pact.pact_version_sha end |
#pacticipants ⇒ Object
117 118 119 |
# File 'lib/pact_broker/domain/index_item.rb', line 117 def pacticipants [consumer, provider] end |
#provider_name ⇒ Object
51 52 53 |
# File 'lib/pact_broker/domain/index_item.rb', line 51 def provider_name provider.name end |
#provider_version ⇒ Object
71 72 73 |
# File 'lib/pact_broker/domain/index_item.rb', line 71 def provider_version @latest_verification ? @latest_verification.provider_version : nil end |
#provider_version_number ⇒ Object
75 76 77 |
# File 'lib/pact_broker/domain/index_item.rb', line 75 def provider_version_number @latest_verification ? @latest_verification.provider_version_number : nil end |
#pseudo_branch_verification_status ⇒ Object
97 98 99 |
# File 'lib/pact_broker/domain/index_item.rb', line 97 def pseudo_branch_verification_status @pseudo_branch_verification_status ||= PactBroker::Verifications::PseudoBranchStatus.new(@latest_pact, @latest_verification).to_sym end |
#tag_names ⇒ Object
these are the consumer tag names for which this pact publication is the latest with that tag
81 82 83 |
# File 'lib/pact_broker/domain/index_item.rb', line 81 def tag_names @tags end |
#to_a ⇒ Object
165 166 167 |
# File 'lib/pact_broker/domain/index_item.rb', line 165 def to_a [consumer, provider] end |
#to_s ⇒ Object
161 162 163 |
# File 'lib/pact_broker/domain/index_item.rb', line 161 def to_s "Pact between #{consumer_name} #{consumer_version_number} and #{provider_name} #{provider_version_number}" end |
#webhook_status ⇒ Object
89 90 91 |
# File 'lib/pact_broker/domain/index_item.rb', line 89 def webhook_status @webhook_status ||= PactBroker::Webhooks::Status.new(@latest_pact, @webhooks, @triggered_webhooks).to_sym end |