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

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

Instance Method Summary collapse

Methods included from Messages

#message, #potential_duplicate_pacticipant_message, #validation_message

Methods included from Api::PactBrokerUrls

#badge_url_for_latest_pact, #build_webhook_metadata, #consumer_webhooks_url, #dashboard_url_for_integration, #decode_webhook_metadata, #encode_webhook_metadata, #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_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_versions_url, #pacticipant_url, #pacticipant_url_from_params, #pacticipants_url, #previous_distinct_diff_url, #previous_distinct_pact_version_url, #provider_webhooks_url, #tag_url, #tags_url, #templated_diff_url, #templated_label_url_for_pacticipant, #templated_tag_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 Pacts::Metadata

#build_metadata_for_latest_pact, #build_metadata_for_webhook_triggered_by_pact_publication

Constructor Details

#initialize(line, options = {}) ⇒ MatrixLine

Returns a new instance of MatrixLine.



15
16
17
18
19
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 15

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



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

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

#base_urlObject



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

def base_url
  @options[:base_url]
end

#consumer_nameObject



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

def consumer_name
  @line.consumer_name
end

#consumer_name_urlObject



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

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

#consumer_version_idObject



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

def consumer_version_id
  @line.consumer_version_id
end

#consumer_version_numberObject



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

def consumer_version_number
  @line.consumer_version_number
end

#consumer_version_number_urlObject



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

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



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

def consumer_version_order
  @line.consumer_version_order
end

#display_consumer_version_numberObject



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

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

#display_provider_version_numberObject



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

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

#latest_consumer_version_tagsObject



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

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

#latest_provider_version_tagsObject



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

def latest_provider_version_tags
  @line.provider_version_tags
    .select(&:latest)
    .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



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

def number
  @line.verification_number
end

#orderable_fieldsObject



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

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

#other_consumer_version_tagsObject



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

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

#other_provider_version_tagsObject



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

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

#overwritten=(overwritten) ⇒ Object



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

def overwritten= overwritten
  @overwritten = overwritten
end

#overwritten?Boolean

Returns:

  • (Boolean)


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

def overwritten?
  @overwritten
end

#pact_publication_dateObject



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

def pact_publication_date
  relative_date(@line.pact_created_at)
end

#pact_publication_date_urlObject



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

def pact_publication_date_url
  pact_url(base_url, @line)
end

#pact_published_orderObject



161
162
163
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 161

def pact_published_order
  @line.pact_created_at.to_time.to_i
end

#pact_revision_numberObject



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

def pact_revision_number
  @line.pact_revision_number
end

#pact_version_shaObject



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

def pact_version_sha
  @line.pact_version_sha
end

#pact_version_sha_messageObject



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

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

#pre_verified_messageObject



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

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



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

def provider_name
  @line.provider_name
end

#provider_name_urlObject



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

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

#provider_version_idObject



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

def provider_version_id
  @line.provider_version_id
end

#provider_version_numberObject



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

def provider_version_number
  @line.provider_version_number
end

#provider_version_number_urlObject



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

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



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

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

#relative_date(date) ⇒ Object



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

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

#verification_statusObject



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 132

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



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

def verification_status_class
  case @line.success
    when true then 'success'
    when false then 'danger'
    else ''
  end
end

#verification_status_urlObject



145
146
147
# File 'lib/pact_broker/ui/view_models/matrix_line.rb', line 145

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