Class: PactBroker::Matrix::RowIgnorer

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/matrix/row_ignorer.rb

Class Method Summary collapse

Class Method Details

.ignore_row?(resolved_ignore_selectors, row) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
# File 'lib/pact_broker/matrix/row_ignorer.rb', line 27

def ignore_row?(resolved_ignore_selectors, row)
  resolved_ignore_selectors.any? do | s |
    s.pacticipant_id == row.consumer_id  && (s.only_pacticipant_name_specified? || s.pacticipant_version_id == row.consumer_version_id) ||
      s.pacticipant_id == row.provider_id  && (s.only_pacticipant_name_specified? || s.pacticipant_version_id == row.provider_version_id)
  end
end

.split_rows_into_considered_and_ignored(rows, resolved_ignore_selectors) ⇒ Array<MatrixRow, EveryRow>

Splits the matrix rows into considered rows and ignored rows, based on the ignore selectors specified by the user in the can-i-deploy command (eg. –ignore SomeProviderThatIsNotReadyYet).

Parameters:

Returns:

  • (Array<MatrixRow, EveryRow>)

    considered_rows, [Array<MatrixRow, EveryRow>] ignored_rows



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pact_broker/matrix/row_ignorer.rb', line 11

def split_rows_into_considered_and_ignored(rows, resolved_ignore_selectors)
  if resolved_ignore_selectors.any?
    considered, ignored = [], []
    rows.each do | row |
      if ignore_row?(resolved_ignore_selectors, row)
        ignored << row
      else
        considered << row
      end
    end
    return considered, ignored
  else
    return rows, []
  end
end