Class: PactBroker::UI::ViewDomain::MatrixLine

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Api::PactBrokerUrls, Messages
Defined in:
lib/pact_broker/ui/view_models/matrix_line.rb

Constant Summary

Constants included from Pacts::Metadata

Pacts::Metadata::MAPPINGS

Instance Method Summary collapse

Methods included from Messages

#message, #pluralize, #validation_message, #validation_message_at_index

Methods included from Api::PactBrokerUrls

#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, #integration_url, #label_url, #labels_url, #latest_pact_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, #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, #pact_versions_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, #webhook_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

Methods included from Pacts::Metadata

#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(line, options = {}) ⇒ MatrixLine

Returns a new instance of MatrixLine.



20
21
22
23
24
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 20

def initialize line, options = {}
  @line = line
  @options = options
  @overwritten = false # true if the pact was revised and this revision is no longer the latest
end

Instance Method Details

#<=>(other) ⇒ Object



157
158
159
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 157

def <=> other
  (orderable_fields <=> other.orderable_fields) * -1
end

#base_urlObject



216
217
218
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 216

def base_url
  @options[:base_url]
end

#consumer_nameObject



34
35
36
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 34

def consumer_name
  @line.consumer_name
end

#consumer_name_urlObject



38
39
40
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 38

def consumer_name_url
  hal_browser_url(pacticipant_url_from_params({ pacticipant_name: consumer_name }, base_url), base_url)
end

#consumer_version_branchesObject



105
106
107
108
109
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 105

def consumer_version_branches
  @line.consumer_version_branch_versions.collect do | branch_version |
    MatrixBranch.new(branch_version, consumer_name)
  end
end

#consumer_version_idObject



59
60
61
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 59

def consumer_version_id
  @line.consumer_version_id
end

#consumer_version_numberObject



67
68
69
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 67

def consumer_version_number
  @line.consumer_version_number
end

#consumer_version_number_urlObject



75
76
77
78
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 75

def consumer_version_number_url
  params = { pacticipant_name: consumer_name, version_number: consumer_version_number }
  hal_browser_url(version_url_from_params(params, base_url), base_url)
end

#consumer_version_orderObject



80
81
82
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 80

def consumer_version_order
  @line.consumer_version_order
end

#consumer_versions_in_environmentsObject



125
126
127
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 125

def consumer_versions_in_environments
  consumer_deployed_versions + consumer_released_versions
end

#display_consumer_version_numberObject



71
72
73
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 71

def display_consumer_version_number
  PactBroker::Versions::AbbreviateNumber.call(consumer_version_number)
end

#display_provider_version_numberObject



88
89
90
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 88

def display_provider_version_number
  PactBroker::Versions::AbbreviateNumber.call(provider_version_number)
end

#latest_consumer_version_tagsObject



111
112
113
114
115
116
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 111

def latest_consumer_version_tags
  @line.consumer_version_tags
    .select(&:latest?)
    .sort_by(&:created_at)
    .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) }
end

#latest_provider_version_tagsObject



139
140
141
142
143
144
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 139

def latest_provider_version_tags
  @line.provider_version_tags
    .select(&:latest?)
    .sort_by(&:created_at)
    .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) }
end

#numberObject

verification number, used in verification_url method



51
52
53
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 51

def number
  @line.verification_number
end

#orderable_fieldsObject



153
154
155
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 153

def orderable_fields
  [@line.last_action_date, @line.pact_created_at]
end

#other_consumer_version_tagsObject



118
119
120
121
122
123
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 118

def other_consumer_version_tags
  @line.consumer_version_tags
    .reject(&:latest?)
    .sort_by(&:created_at)
    .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) }
end

#other_provider_version_tagsObject



146
147
148
149
150
151
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 146

def other_provider_version_tags
  @line.provider_version_tags
    .reject(&:latest?)
    .sort_by(&:created_at)
    .collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) }
end

#overwritten=(overwritten) ⇒ Object



206
207
208
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 206

def overwritten= overwritten
  @overwritten = overwritten
end

#overwritten?Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 202

def overwritten?
  @overwritten
end

#pact_publication_dateObject



178
179
180
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 178

def pact_publication_date
  relative_date(@line.pact_created_at)
end

#pact_publication_date_urlObject



182
183
184
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 182

def pact_publication_date_url
  pact_url(base_url, @line)
end

#pact_published_orderObject



190
191
192
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 190

def pact_published_order
  @line.pact_created_at.to_time.to_i
end

#pact_revision_numberObject



55
56
57
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 55

def pact_revision_number
  @line.pact_revision_number
end

#pact_version_shaObject



42
43
44
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 42

def pact_version_sha
  @line.pact_version_sha
end

#pact_version_sha_messageObject



46
47
48
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 46

def pact_version_sha_message
  "The highlighted pact(s) have content that has a SHA of #{pact_version_sha}"
end

#pre_verified_messageObject



210
211
212
213
214
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 210

def pre_verified_message
  if @line.verification_executed_at && @line.pact_created_at > @line.verification_executed_at
    message("messages.matrix.pre_verified")
  end
end

#provider_nameObject



26
27
28
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 26

def provider_name
  @line.provider_name
end

#provider_name_urlObject



30
31
32
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 30

def provider_name_url
  hal_browser_url(pacticipant_url_from_params({ pacticipant_name: provider_name }, base_url), base_url)
end

#provider_version_branchesObject



133
134
135
136
137
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 133

def provider_version_branches
  @line.provider_version_branch_versions.collect do | branch_version |
    MatrixBranch.new(branch_version, provider_name)
  end
end

#provider_version_idObject



63
64
65
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 63

def provider_version_id
  @line.provider_version_id
end

#provider_version_numberObject



84
85
86
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 84

def provider_version_number
  @line.provider_version_number
end

#provider_version_number_urlObject



92
93
94
95
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 92

def provider_version_number_url
  params = { pacticipant_name: provider_name, version_number: provider_version_number }
  hal_browser_url(version_url_from_params(params, base_url), base_url)
end

#provider_version_orderObject



97
98
99
100
101
102
103
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 97

def provider_version_order
  if @line.verification_executed_at
    @line.verification_executed_at.to_time.to_i
  else
    0
  end
end

#provider_versions_in_environmentsObject



129
130
131
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 129

def provider_versions_in_environments
  provider_deployed_versions + provider_released_versions
end

#relative_date(date) ⇒ Object



186
187
188
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 186

def relative_date date
  DateHelper.distance_of_time_in_words(date, DateTime.now) + " ago"
end

#verification_statusObject



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 161

def verification_status
  if @line.verification_executed_at
    DateHelper.distance_of_time_in_words(@line.verification_executed_at, DateTime.now) + " ago"
  else
    ""
  end
  # case @line.success
  #   when true then "Verified"
  #   when false then "Failed"
  #   else ''
  # end
end

#verification_status_classObject



194
195
196
197
198
199
200
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 194

def verification_status_class
  case @line.success
    when true then "table-success"
    when false then "table-danger"
    else ""
  end
end

#verification_status_urlObject



174
175
176
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 174

def verification_status_url
  hal_browser_url(verification_url(self, base_url), base_url)
end