Class: PactBroker::Matrix::ResolvedSelector
- Inherits:
-
Hash
- Object
- Hash
- PactBroker::Matrix::ResolvedSelector
- Defined in:
- lib/pact_broker/matrix/resolved_selector.rb
Constant Summary collapse
- 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.
-1
Class Method Summary collapse
- .for_pacticipant(pacticipant, type) ⇒ Object
- .for_pacticipant_and_non_existing_version(pacticipant, original_selector, type) ⇒ Object
- .for_pacticipant_and_version(pacticipant, version, original_selector, type) ⇒ Object
Instance Method Summary collapse
- #description ⇒ Object
-
#inferred? ⇒ Boolean
Was this selector inferred based on the user’s query? (ie. the integrations were calculated because only one selector was specified).
-
#initialize(params = {}) ⇒ ResolvedSelector
constructor
A new instance of ResolvedSelector.
- #latest? ⇒ Boolean
- #latest_tagged? ⇒ Boolean
- #latest_tagged_version_that_does_not_exist? ⇒ Boolean
- #pacticipant_id ⇒ Object
- #pacticipant_name ⇒ Object
- #pacticipant_version_id ⇒ Object
- #pacticipant_version_number ⇒ Object
-
#specified? ⇒ Boolean
Did the user specify this selector in the user’s query?.
- #specified_version_that_does_not_exist? ⇒ Boolean
- #tag ⇒ Object
- #version_does_not_exist? ⇒ Boolean
- #version_exists? ⇒ Boolean
Constructor Details
#initialize(params = {}) ⇒ ResolvedSelector
Returns a new instance of ResolvedSelector.
14 15 16 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 14 def initialize(params = {}) merge!(params) end |
Class Method Details
.for_pacticipant(pacticipant, type) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 18 def self.for_pacticipant(pacticipant, type) ResolvedSelector.new( pacticipant_id: pacticipant.id, pacticipant_name: pacticipant.name, type: type ) end |
.for_pacticipant_and_non_existing_version(pacticipant, original_selector, type) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 38 def self.for_pacticipant_and_non_existing_version(pacticipant, original_selector, type) 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], type: type ) end |
.for_pacticipant_and_version(pacticipant, version, original_selector, type) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 26 def self.for_pacticipant_and_version(pacticipant, version, original_selector, type) 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], type: type ) end |
Instance Method Details
#description ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 105 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? && 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 pacticipant_version_number "version #{pacticipant_version_number} of #{pacticipant_name}" else "any version of #{pacticipant_name}" end end |
#inferred? ⇒ Boolean
Was this selector inferred based on the user’s query? (ie. the integrations were calculated because only one selector was specified)
101 102 103 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 101 def inferred? self[:type] == :inferred end |
#latest? ⇒ Boolean
66 67 68 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 66 def latest? self[:latest] end |
#latest_tagged? ⇒ Boolean
74 75 76 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 74 def latest_tagged? latest? && tag end |
#latest_tagged_version_that_does_not_exist? ⇒ Boolean
82 83 84 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 82 def latest_tagged_version_that_does_not_exist? version_does_not_exist? && latest_tagged? end |
#pacticipant_id ⇒ Object
50 51 52 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 50 def pacticipant_id self[:pacticipant_id] end |
#pacticipant_name ⇒ Object
54 55 56 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 54 def pacticipant_name self[:pacticipant_name] end |
#pacticipant_version_id ⇒ Object
58 59 60 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 58 def pacticipant_version_id self[:pacticipant_version_id] end |
#pacticipant_version_number ⇒ Object
62 63 64 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 62 def pacticipant_version_number self[:pacticipant_version_number] end |
#specified? ⇒ Boolean
Did the user specify this selector in the user’s query?
95 96 97 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 95 def specified? self[:type] == :specified end |
#specified_version_that_does_not_exist? ⇒ Boolean
86 87 88 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 86 def specified_version_that_does_not_exist? specified? && version_does_not_exist? end |
#tag ⇒ Object
70 71 72 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 70 def tag self[:tag] end |
#version_does_not_exist? ⇒ Boolean
78 79 80 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 78 def version_does_not_exist? !version_exists? end |
#version_exists? ⇒ Boolean
90 91 92 |
# File 'lib/pact_broker/matrix/resolved_selector.rb', line 90 def version_exists? pacticipant_version_id != NULL_VERSION_ID end |