Class: PactBroker::Pacts::PactPublication
- Inherits:
-
Object
- Object
- PactBroker::Pacts::PactPublication
- Extended by:
- Forwardable
- Defined in:
- lib/pact_broker/pacts/pact_publication.rb
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #before_create ⇒ Object
- #consumer_version_tags ⇒ Object
- #head_pact_tags ⇒ Object
-
#head_tag_names ⇒ Object
The names of the tags for which this pact is the latest pact with that tag (ie. it is not necessarily the pact for the latest consumer version with the given tag).
- #latest_for_branch? ⇒ Boolean
- #latest_main_branch_verification ⇒ Object
- #latest_verification ⇒ Object
- #pact_version_sha ⇒ Object
- #to_domain ⇒ Object
- #to_domain_lightweight ⇒ Object
- #to_domain_with_content ⇒ Object
- #to_head_pact ⇒ Object
-
#to_version_domain ⇒ Object
Think we really could just use the version here.
- #to_version_domain_lightweight ⇒ Object
Class Method Details
.subtract(a, *b) ⇒ Object
86 87 88 89 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 86 def self.subtract(a, *b) b_ids = b.flat_map{ |pact_publications| pact_publications.collect(&:id) } a.reject{ |pact_publication| b_ids.include?(pact_publication.id) } end |
Instance Method Details
#<=>(other) ⇒ Object
195 196 197 198 199 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 195 def <=> other self_fields = [consumer.name.downcase, provider.name.downcase, consumer_version_order || 0] other_fields = [other.consumer.name.downcase, other.provider.name.downcase, other.consumer_version_order || 0] self_fields <=> other_fields end |
#before_create ⇒ Object
91 92 93 94 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 91 def before_create super self.revision_number ||= 1 end |
#consumer_version_tags ⇒ Object
108 109 110 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 108 def end |
#head_pact_tags ⇒ Object
96 97 98 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 96 def consumer_version..select{ |tag| head_tag_names.include?(tag.name) } end |
#head_tag_names ⇒ Object
The names of the tags for which this pact is the latest pact with that tag (ie. it is not necessarily the pact for the latest consumer version with the given tag)
102 103 104 105 106 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 102 def head_tag_names @head_tag_names ||= .select { |head_pact_publication| head_pact_publication.id == id } .collect { | head_pact_publication| head_pact_publication.values.fetch(:tag_name) } end |
#latest_for_branch? ⇒ Boolean
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 120 def latest_for_branch? if !defined?(@latest_for_branch) if consumer_version.branch_versions.empty? @latest_for_branch = nil else self_order = self.consumer_version.order @latest_for_branch = consumer_version.branch_versions.any? do | branch_version | branch_versions_join = { Sequel[:cv][:id] => Sequel[:branch_versions][:version_id], Sequel[:branch_versions][:branch_name] => branch_version.branch_name } PactPublication.where(consumer_id: consumer_id, provider_id: provider_id) .join_consumer_versions(:cv) do Sequel[:cv][:order] > self_order end .join(:branch_versions, branch_versions_join) .empty? end end end @latest_for_branch end |
#latest_main_branch_verification ⇒ Object
116 117 118 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 116 def latest_main_branch_verification pact_version.latest_main_branch_verification end |
#latest_verification ⇒ Object
112 113 114 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 112 def latest_verification pact_version.latest_verification end |
#pact_version_sha ⇒ Object
191 192 193 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 191 def pact_version_sha pact_version.sha end |
#to_domain ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 143 def to_domain PactBroker::Domain::Pact.new( id: id, provider: provider, consumer: consumer, consumer_version_number: consumer_version.number, consumer_version: to_version_domain, revision_number: revision_number, json_content: pact_version.content, pact_version_sha: pact_version.sha, latest_verification: pact_version.latest_verification, created_at: created_at, head_tag_names: [], db_model: self ) end |
#to_domain_lightweight ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 160 def to_domain_lightweight PactBroker::Domain::Pact.new( id: id, provider: provider, consumer: consumer, consumer_version_number: consumer_version.number, consumer_version: to_version_domain_lightweight, revision_number: revision_number, pact_version_sha: pact_version.sha, created_at: created_at, db_model: self ) end |
#to_domain_with_content ⇒ Object
183 184 185 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 183 def to_domain_with_content to_domain end |
#to_head_pact ⇒ Object
187 188 189 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 187 def to_head_pact HeadPact.new(to_domain, consumer_version.number, values[:tag_name]) end |
#to_version_domain ⇒ Object
Think we really could just use the version here.
175 176 177 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 175 def to_version_domain consumer_version end |
#to_version_domain_lightweight ⇒ Object
179 180 181 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 179 def to_version_domain_lightweight consumer_version end |