class PactBroker::Matrix::ResolvedSelector
Constants
- NULL_PACTICIPANT_ID
- NULL_VERSION_ID
A version ID of -1 will not match any rows, which is what we want to ensure that no matrix rows are returned for a version that does not exist.
Public Class Methods
for_non_existing_pacticipant(original_selector, type, ignore)
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 29 def self.for_non_existing_pacticipant(original_selector, type, ignore) ResolvedSelector.new( pacticipant_id: NULL_PACTICIPANT_ID, pacticipant_name: original_selector[:pacticipant_name], type: type, ignore: ignore, original_selector: original_selector ) end
for_pacticipant(pacticipant, original_selector, type, ignore)
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 19 def self.for_pacticipant(pacticipant, original_selector, type, ignore) ResolvedSelector.new( pacticipant_id: pacticipant.id, pacticipant_name: pacticipant.name, type: type, ignore: ignore, original_selector: original_selector ) end
for_pacticipant_and_non_existing_version(pacticipant, original_selector, type, ignore)
click to toggle source
rubocop: enable Metrics/ParameterLists
# File lib/pact_broker/matrix/resolved_selector.rb, line 58 def self.for_pacticipant_and_non_existing_version(pacticipant, original_selector, type, ignore) ResolvedSelector.new( pacticipant_id: pacticipant.id, pacticipant_name: pacticipant.name, pacticipant_version_id: NULL_VERSION_ID, pacticipant_version_number: original_selector[:pacticipant_version_number], latest: original_selector[:latest], tag: original_selector[:tag], branch: original_selector[:branch], environment_name: original_selector[:environment_name], type: type, ignore: ignore, original_selector: original_selector ) end
for_pacticipant_and_version(pacticipant, version, original_selector, type, ignore, one_of_many = false)
click to toggle source
rubocop: disable Metrics/ParameterLists
# File lib/pact_broker/matrix/resolved_selector.rb, line 40 def self.for_pacticipant_and_version(pacticipant, version, original_selector, type, ignore, one_of_many = false) ResolvedSelector.new( pacticipant_id: pacticipant.id, pacticipant_name: pacticipant.name, pacticipant_version_id: version.id, pacticipant_version_number: version.number, latest: original_selector[:latest], tag: original_selector[:tag], branch: original_selector[:branch], environment_name: original_selector[:environment_name], type: type, ignore: ignore, one_of_many: one_of_many, original_selector: original_selector ) end
new(params = {})
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 15 def initialize(params = {}) merge!(params) end
Public Instance Methods
branch()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 102 def branch self[:branch] end
consider?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 173 def consider? !ignore? end
description()
click to toggle source
rubocop: disable Metrics/CyclomaticComplexity
# File lib/pact_broker/matrix/resolved_selector.rb, line 178 def description if latest_tagged? && pacticipant_version_number "the latest version of #{pacticipant_name} with tag #{tag} (#{pacticipant_version_number})" elsif latest_tagged? "the latest version of #{pacticipant_name} with tag #{tag} (no such version exists)" elsif latest_from_branch? && pacticipant_version_number "the latest version of #{pacticipant_name} from branch #{branch} (#{pacticipant_version_number})" elsif latest_from_branch? "the latest version of #{pacticipant_name} from branch #{branch} (no such version exists)" elsif latest? && pacticipant_version_number "the latest version of #{pacticipant_name} (#{pacticipant_version_number})" elsif latest? "the latest version of #{pacticipant_name} (no such version exists)" elsif tag && pacticipant_version_number "a version of #{pacticipant_name} with tag #{tag} (#{pacticipant_version_number})" elsif tag "a version of #{pacticipant_name} with tag #{tag} (no such version exists)" elsif environment_name && pacticipant_version_number prefix = one_of_many? ? "one of the versions" : "the version" "#{prefix} of #{pacticipant_name} currently deployed to #{environment_name} (#{pacticipant_version_number})" elsif environment_name "the version of #{pacticipant_name} currently deployed to #{environment_name} (no such version exists)" elsif pacticipant_version_number && version_does_not_exist? "version #{pacticipant_version_number} of #{pacticipant_name} (no such version exists)" elsif pacticipant_version_number "version #{pacticipant_version_number} of #{pacticipant_name}" elsif pacticipant_does_not_exist? "any version of #{pacticipant_name} (no such pacticipant exists)" else "any version of #{pacticipant_name}" end end
environment_name()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 106 def environment_name self[:environment_name] end
ignore?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 169 def ignore? self[:ignore] end
inferred?()
click to toggle source
Was this selector inferred based on the user's query?
(ie. the integrations were calculated because only one selector was specified)
# File lib/pact_broker/matrix/resolved_selector.rb, line 161 def inferred? self[:type] == :inferred end
latest?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 94 def latest? self[:latest] end
latest_from_branch?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 126 def latest_from_branch? latest? && branch end
latest_tagged?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 122 def latest_tagged? latest? && tag end
latest_tagged_version_that_does_not_exist?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 142 def latest_tagged_version_that_does_not_exist? version_does_not_exist? && latest_tagged? end
most_specific_criterion()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 110 def most_specific_criterion if pacticipant_version_id { pacticipant_version_id: pacticipant_version_id } else { pacticipant_id: pacticipant_id } end end
one_of_many?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 165 def one_of_many? self[:one_of_many] end
only_pacticipant_name_specified?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 118 def only_pacticipant_name_specified? !!pacticipant_name && !branch && !tag && !latest? && !pacticipant_version_number end
pacticipant_does_not_exist?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 134 def pacticipant_does_not_exist? self[:pacticipant_id] == NULL_PACTICIPANT_ID end
pacticipant_id()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 78 def pacticipant_id self[:pacticipant_id] end
pacticipant_name()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 82 def pacticipant_name self[:pacticipant_name] end
pacticipant_or_version_does_not_exist?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 130 def pacticipant_or_version_does_not_exist? pacticipant_does_not_exist? || version_does_not_exist? end
pacticipant_version_id()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 86 def pacticipant_version_id self[:pacticipant_version_id] end
pacticipant_version_number()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 90 def pacticipant_version_number self[:pacticipant_version_number] end
pacticipant_version_specified_in_original_selector?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 74 def pacticipant_version_specified_in_original_selector? !!self.dig(:original_selector, :pacticipant_version_number) end
specified?()
click to toggle source
Did the user specify this selector in the user's query?
# File lib/pact_broker/matrix/resolved_selector.rb, line 155 def specified? self[:type] == :specified end
specified_version_that_does_not_exist?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 146 def specified_version_that_does_not_exist? specified? && version_does_not_exist? end
tag()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 98 def tag self[:tag] end
version_does_not_exist?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 138 def version_does_not_exist? !version_exists? end
version_exists?()
click to toggle source
# File lib/pact_broker/matrix/resolved_selector.rb, line 150 def version_exists? pacticipant_version_id != NULL_VERSION_ID end