Class: PactBroker::UI::ViewDomain::IndexItem
- Inherits:
-
Object
- Object
- PactBroker::UI::ViewDomain::IndexItem
show all
- Extended by:
- Forwardable
- Includes:
- Api::PactBrokerUrls
- Defined in:
- lib/pact_broker/ui/view_models/index_item.rb
Constant Summary
Pacts::Metadata::MAPPINGS
Instance Method Summary
collapse
#append_query_if_present, #badge_url_for_latest_pact, #branch_url, #branch_version_url, #branch_versions_url, #consumer_webhooks_url, #currently_deployed_versions_for_environment_url, #currently_supported_versions_for_environment_url, #dashboard_url_for_integration, #decode_pact_metadata, #deployed_version_url, #deployed_versions_for_version_and_environment_url, #encode_metadata, #environment_url, #environments_url, #group_url, #hal_browser_url, #label_url, #labels_url, #latest_pacts_url, #latest_tagged_pact_url, #latest_untagged_pact_url, #latest_verification_for_pact_url, #latest_verifications_for_consumer_version_url, #latest_version_for_branch_url, #latest_version_url, #matrix_badge_url_for_selectors, #matrix_for_pact_url, #matrix_for_pacticipant_version_url, #matrix_url, #matrix_url_from_params, #new_verification_url, #pact_triggered_webhooks_url, #pact_url_from_params, #pact_version_url, #pact_version_url_with_metadata, #pact_version_url_with_webhook_metadata, #pact_version_with_consumer_version_metadata_url, #pact_versions_for_branch_url, #pacticipant_branches_url, #pacticipant_url, #pacticipant_url_from_params, #pacticipants_url, #pacticipants_with_label_url, #previous_distinct_diff_url, #previous_distinct_pact_version_url, #provider_webhooks_url, #record_undeployment_url, #released_version_url, #released_versions_for_version_and_environment_url, #tag_url, #tagged_pact_versions_url, #tags_url, #templated_branch_version_url_for_pacticipant, #templated_can_i_deploy_badge_url, #templated_can_i_deploy_branch_to_environment_badge_url, #templated_can_i_deploy_url, #templated_diff_url, #templated_label_url_for_pacticipant, #templated_tag_url_for_pacticipant, #templated_version_url_for_pacticipant, #triggered_webhook_logs_url, #url_encode, #verification_publication_url, #verification_triggered_webhooks_url, #verification_url, #verification_url_from_params, #version_url, #version_url_from_params, #versions_url, #webhook_execution_url, #webhooks_for_consumer_and_provider_url, #webhooks_for_pact_url, #webhooks_status_url, #webhooks_url
Methods included from Logging
included, #log_error, #log_with_tag, #measure_info
#build_metadata_for_consumer_version_number, #build_metadata_for_latest_pact, #build_metadata_for_pact_for_verification, #build_metadata_for_webhook_triggered_by_pact_publication, #parse_hash, #parse_metadata, #parse_object
Constructor Details
#initialize(relationship, options = {}) ⇒ IndexItem
Returns a new instance of IndexItem.
30
31
32
33
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 30
def initialize relationship, options = {}
@relationship = relationship
@options = options
end
|
Instance Method Details
#<=>(other) ⇒ Object
229
230
231
232
233
234
235
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 229
def <=> other
comp = consumer_name.downcase <=> other.consumer_name.downcase
return comp unless comp == 0
comp = provider_name.downcase <=> other.provider_name.downcase
return comp unless comp == 0
other.consumer_version_order <=> consumer_version_order
end
|
#any_webhooks? ⇒ Boolean
115
116
117
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 115
def any_webhooks?
@relationship.any_webhooks?
end
|
#base_url ⇒ Object
250
251
252
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 250
def base_url
@options[:base_url]
end
|
#consumer_group_url ⇒ Object
91
92
93
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 91
def consumer_group_url
Helpers::URLHelper.group_url(consumer_name, base_url)
end
|
#consumer_name ⇒ Object
35
36
37
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 35
def consumer_name
@relationship.consumer_name
end
|
#consumer_version_branch_heads ⇒ Object
71
72
73
74
75
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 71
def consumer_version_branch_heads
@relationship.consumer_version_branch_heads.collect do | branch_head |
IndexItemBranchHead.new(branch_head, consumer_name)
end
end
|
#consumer_version_latest_tag_names ⇒ Object
77
78
79
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 77
def consumer_version_latest_tag_names
@relationship.tag_names
end
|
#consumer_version_number ⇒ Object
43
44
45
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 43
def consumer_version_number
@relationship.consumer_version_number
end
|
#consumer_version_order ⇒ Object
51
52
53
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 51
def consumer_version_order
@relationship.consumer_version_order
end
|
#dashboard_url ⇒ Object
103
104
105
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 103
def dashboard_url
Helpers::URLHelper.dashboard_url(consumer_name, provider_name, base_url)
end
|
#display_consumer_version_number ⇒ Object
#display_latest_label? ⇒ Boolean
63
64
65
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 63
def display_latest_label?
consumer_version_latest_tag_names.empty? && @relationship.tag_names.empty?
end
|
#display_provider_version_number ⇒ Object
#failed_and_pact_pending? ⇒ Boolean
197
198
199
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 197
def failed_and_pact_pending?
latest_verification&.failed_and_pact_pending?
end
|
#integration_url ⇒ Object
#last_verified_date ⇒ Object
169
170
171
172
173
174
175
176
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 169
def last_verified_date
if @relationship.ever_verified?
date = latest_verification.execution_date
PactBroker::DateHelper.distance_of_time_in_words(date, DateTime.now) + " ago"
else
""
end
end
|
#latest? ⇒ Boolean
67
68
69
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 67
def latest?
@relationship.latest?
end
|
#latest_pact_url ⇒ Object
99
100
101
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 99
def latest_pact_url
"#{pactigration_base_url(base_url, @relationship)}/latest"
end
|
#pact_branches ⇒ Object
263
264
265
266
267
268
269
270
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 263
def pact_branches
consumer_version_branches.map do | branch_name |
{
name: branch_name,
deletionUrl: PactBroker::Api::PactBrokerUrls.pact_versions_for_branch_url(consumer_name, provider_name, branch_name, base_url)
}
end.to_json
end
|
#pact_matrix_url ⇒ Object
254
255
256
257
258
259
260
261
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 254
def pact_tags
@relationship.tag_names.map do |tag|
{
name: tag,
deletionUrl: PactBroker::Api::PactBrokerUrls.tagged_pact_versions_url(consumer_name, provider_name, tag, base_url)
}
end.to_json
end
|
#pact_versions_url ⇒ Object
#provider_group_url ⇒ Object
95
96
97
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 95
def provider_group_url
Helpers::URLHelper.group_url(provider_name, base_url)
end
|
#provider_name ⇒ Object
39
40
41
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 39
def provider_name
@relationship.provider_name
end
|
#provider_version_branch_heads ⇒ Object
85
86
87
88
89
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 85
def provider_version_branch_heads
@relationship.provider_version_branch_heads.collect do | branch_head |
IndexItemProviderBranchHead.new(branch_head, provider_name)
end
end
|
#provider_version_latest_tag_names ⇒ Object
81
82
83
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 81
def provider_version_latest_tag_names
@relationship.latest_verification_latest_tags.collect(&:name)
end
|
#provider_version_number ⇒ Object
55
56
57
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 55
def provider_version_number
@relationship.provider_version_number
end
|
#pseudo_branch_verification_status ⇒ Object
187
188
189
190
191
192
193
194
195
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 187
def pseudo_branch_verification_status
case @relationship.pseudo_branch_verification_status
when :success then "success"
when :stale then "warning"
when :failed then "danger"
when :failed_pending then "danger"
else ""
end
end
|
#publication_date_of_latest_pact ⇒ Object
178
179
180
181
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 178
def publication_date_of_latest_pact
date = @relationship.latest_pact.created_at
PactBroker::DateHelper.distance_of_time_in_words(date, DateTime.now) + " ago"
end
|
#publication_date_of_latest_pact_order ⇒ Object
183
184
185
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 183
def publication_date_of_latest_pact_order
@relationship.latest_pact.created_at.to_time.to_i
end
|
#short_version_number(version_number) ⇒ Object
237
238
239
240
241
242
243
244
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 237
def short_version_number version_number
return "" if version_number.nil?
if version_number.size > 12
version_number[0..12] + "..."
else
version_number
end
end
|
246
247
248
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 246
def
!view_by_environment? && (@relationship.tag_names.any? || consumer_version_branches.any?)
end
|
#show_settings? ⇒ Boolean
151
152
153
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 151
def show_settings?
@relationship.latest?
end
|
#show_webhook_status? ⇒ Boolean
147
148
149
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 147
def show_webhook_status?
@relationship.latest?
end
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 205
def verification_tooltip
case @relationship.pseudo_branch_verification_status
when :success
"Successfully verified by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)})"
when :stale
desc = if @relationship.consumer_version_branches.any?
"from branch #{@relationship.consumer_version_branches.first} "
elsif @relationship.tag_names.any?
"with tag #{@relationship.tag_names.first} "
else
""
end
"Pact #{desc}has changed since last successful verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)})"
when :failed_pending
"Verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)}) failed, but did not fail the build as the pact content was in pending state for that provider branch"
when :failed
"Verification by #{provider_name} (#{short_version_number(@relationship.latest_verification_provider_version_number)}) failed"
else
nil
end
end
|
#view_by_environment? ⇒ Boolean
272
273
274
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 272
def view_by_environment?
@options[:view] == "environment"
end
|
#warning? ⇒ Boolean
201
202
203
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 201
def warning?
pseudo_branch_verification_status == "warning"
end
|
#webhook_label ⇒ Object
127
128
129
130
131
132
133
134
135
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 127
def webhook_label
return "" unless show_webhook_status?
case @relationship.webhook_status
when :none then "Create"
when :success, :failure then webhook_last_execution_date
when :retrying then "Retrying"
when :not_run then "Not run"
end
end
|
#webhook_last_execution_date ⇒ Object
155
156
157
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 155
def webhook_last_execution_date
PactBroker::DateHelper.distance_of_time_in_words(@relationship.last_webhook_execution_date, DateTime.now) + " ago"
end
|
#webhook_status ⇒ Object
137
138
139
140
141
142
143
144
145
|
# File 'lib/pact_broker/ui/view_models/index_item.rb', line 137
def webhook_status
return "" unless show_webhook_status?
case @relationship.webhook_status
when :success then "success"
when :failure then "danger"
when :retrying then "warning"
else ""
end
end
|