Class: PactBroker::Matrix::AggregatedRow
- Inherits:
-
Object
- Object
- PactBroker::Matrix::AggregatedRow
- Extended by:
- Forwardable
- Defined in:
- lib/pact_broker/matrix/aggregated_row.rb
Instance Method Summary collapse
-
#consumer_head_tag_names ⇒ Object
The list of tag names for which this pact publication is the most recent with that tag There could, however, be a later consumer version that does’t have a pact (perhaps because it was deleted) that has the same tag.
-
#initialize(matrix_rows) ⇒ AggregatedRow
constructor
A new instance of AggregatedRow.
- #latest_verification_for_pact_version ⇒ Object
-
#latest_verification_for_pseudo_branch ⇒ Object
If this comes back nil, it won’t be “cached”, but it’s a reasonably quick query, so it’s probably ok.
- #overall_latest? ⇒ Boolean
Constructor Details
#initialize(matrix_rows) ⇒ AggregatedRow
Returns a new instance of AggregatedRow.
16 17 18 19 |
# File 'lib/pact_broker/matrix/aggregated_row.rb', line 16 def initialize matrix_rows @matrix_rows = matrix_rows @first_row = matrix_rows.first end |
Instance Method Details
#consumer_head_tag_names ⇒ Object
The list of tag names for which this pact publication is the most recent with that tag There could, however, be a later consumer version that does’t have a pact (perhaps because it was deleted) that has the same tag. TODO show a warning when the data is “corrupted” as above.
56 57 58 |
# File 'lib/pact_broker/matrix/aggregated_row.rb', line 56 def consumer_head_tag_names matrix_rows.collect(&:consumer_version_tag_name).compact end |
#latest_verification_for_pact_version ⇒ Object
46 47 48 49 50 |
# File 'lib/pact_broker/matrix/aggregated_row.rb', line 46 def latest_verification_for_pact_version @latest_verificaton_for_pact_version ||= begin matrix_rows.collect(&:verification).compact.sort_by(&:id).last end end |
#latest_verification_for_pseudo_branch ⇒ Object
If this comes back nil, it won’t be “cached”, but it’s a reasonably quick query, so it’s probably ok. The collection of pacts that belong to the same tag can be considered a pseudo branch. Find the latest verification for each pseudo branch and return the most recent. If this pact is the most recent overall, and there were no verifications found for any of the tags, then return the most recent verification
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pact_broker/matrix/aggregated_row.rb', line 32 def latest_verification_for_pseudo_branch @latest_verification ||= begin verification = matrix_rows.collect do | row| row.verification || latest_verification_for_consumer_version_tag(row) end.compact.sort_by(&:id).last if !verification && overall_latest? overall_latest_verification else verification end end end |
#overall_latest? ⇒ Boolean
21 22 23 |
# File 'lib/pact_broker/matrix/aggregated_row.rb', line 21 def overall_latest? !!matrix_rows.find{ | row| row.consumer_version_tag_name.nil? } end |