Class: PactBroker::Domain::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/domain/version.rb

Instance Method Summary collapse

Instance Method Details

#after_createObject

Isn’t called on upsert when the record is updated with Sqlite Is called with Postgres/MySQL Haven’t had time to dig into why



276
277
278
279
280
# File 'lib/pact_broker/domain/version.rb', line 276

def after_create
  super
  OrderVersions.(self) unless self.order
  refresh
end

#before_destroyObject



282
283
284
285
286
287
# File 'lib/pact_broker/domain/version.rb', line 282

def before_destroy
  PactBroker::Deployments::DeployedVersion.where(version: self).destroy
  PactBroker::Deployments::ReleasedVersion.where(version: self).destroy
  PactBroker::Domain::Tag.where(version: self).destroy
  super
end

#branchObject

Raises:

  • (NotImplementedError)


330
331
332
# File 'lib/pact_broker/domain/version.rb', line 330

def branch
  raise NotImplementedError
end

#branch=(branch) ⇒ Object

Raises:

  • (NotImplementedError)


334
335
336
# File 'lib/pact_broker/domain/version.rb', line 334

def branch= branch
  raise NotImplementedError
end

#branch_namesObject



322
323
324
# File 'lib/pact_broker/domain/version.rb', line 322

def branch_names
  branch_versions.collect(&:branch_name)
end

#branch_version_for_branch(branch) ⇒ Object



314
315
316
# File 'lib/pact_broker/domain/version.rb', line 314

def branch_version_for_branch(branch)
  branch_versions.find { | branch_version | branch_version.branch_id == branch.id }
end

#branch_version_for_branch_name(branch_name) ⇒ Object



318
319
320
# File 'lib/pact_broker/domain/version.rb', line 318

def branch_version_for_branch_name(branch_name)
  branch_versions.find { | branch_version | branch_version.branch_name == branch_name }
end

#head_tagsObject



297
298
299
# File 'lib/pact_broker/domain/version.rb', line 297

def head_tags
  tags.select(&:latest_for_pacticipant?)
end

#latest_for_branch?Boolean

Returns:

  • (Boolean)


306
307
308
# File 'lib/pact_broker/domain/version.rb', line 306

def latest_for_branch?
  branch_heads.any?
end

#latest_for_pacticipant?Boolean

Returns:

  • (Boolean)


310
311
312
# File 'lib/pact_broker/domain/version.rb', line 310

def latest_for_pacticipant?
  latest_version_for_pacticipant == self
end

#latest_pact_publicationObject

What about provider??? This makes no sense



302
303
304
# File 'lib/pact_broker/domain/version.rb', line 302

def latest_pact_publication
  pact_publications.last
end

#tag_namesObject



326
327
328
# File 'lib/pact_broker/domain/version.rb', line 326

def tag_names
  tags.collect(&:name)
end

#to_sObject



289
290
291
# File 'lib/pact_broker/domain/version.rb', line 289

def to_s
  "Version: number=#{number}, pacticipant=#{pacticipant_id}"
end

#version_and_updated_dateObject



293
294
295
# File 'lib/pact_broker/domain/version.rb', line 293

def version_and_updated_date
  "Version #{number} - #{updated_at.to_time.localtime.strftime("%d/%m/%Y")}"
end