Class: PactBroker::Matrix::DeploymentStatusSummary

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Logging
Defined in:
lib/pact_broker/matrix/deployment_status_summary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #log_error, #log_with_tag, #measure_info

Constructor Details

#initialize(query_results) ⇒ DeploymentStatusSummary

Returns a new instance of DeploymentStatusSummary.



14
15
16
17
18
# File 'lib/pact_broker/matrix/deployment_status_summary.rb', line 14

def initialize(query_results)
  @query_results = query_results
  @all_rows = query_results.rows
  @dummy_selectors = create_dummy_selectors
end

Instance Attribute Details

#all_rowsObject (readonly)

Returns the value of attribute all_rows.



11
12
13
# File 'lib/pact_broker/matrix/deployment_status_summary.rb', line 11

def all_rows
  @all_rows
end

#query_resultsObject (readonly)

Returns the value of attribute query_results.



11
12
13
# File 'lib/pact_broker/matrix/deployment_status_summary.rb', line 11

def query_results
  @query_results
end

Instance Method Details

#countsObject



20
21
22
23
24
25
26
27
# File 'lib/pact_broker/matrix/deployment_status_summary.rb', line 20

def counts
  {
    success: considered_rows.count(&:success),
    failed: considered_rows.count { |row| row.success == false },
    unknown: required_integrations_without_a_row.count + considered_rows.count { |row| row.success.nil? },
    ignored: resolved_ignore_selectors.any? ? ignored_rows.count : nil
  }.compact
end

#deployable?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
# File 'lib/pact_broker/matrix/deployment_status_summary.rb', line 29

def deployable?
  return false if considered_specified_selectors_that_do_not_exist.any?
  return nil if considered_rows.any?{ |row| row.success.nil? }
  return nil if required_integrations_without_a_row.any?
  considered_rows.all?(&:success) # true if considered_rows is empty
end

#reasonsObject



36
37
38
# File 'lib/pact_broker/matrix/deployment_status_summary.rb', line 36

def reasons
  error_messages.any? ? warning_messages + error_messages  : warning_messages + success_messages
end