Class: PactBroker::Domain::Version

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

Constant Summary collapse

VERSION_COLUMNS =

do not include the branch column, as we now have a branches table

Sequel::Model.db.schema(:versions).collect(&:first) - [:branch]

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



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

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

#before_destroyObject



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

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)


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

def branch
  raise NotImplementedError
end

#branch=(branch) ⇒ Object

Raises:

  • (NotImplementedError)


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

def branch= branch
  raise NotImplementedError
end

#branch_namesObject



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

def branch_names
  branch_versions.collect(&:branch_name)
end

#branch_version_for_branch(branch) ⇒ Object



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

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



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

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

#head_tagsObject



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

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

#latest_for_branch?Boolean

Returns:

  • (Boolean)


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

def latest_for_branch?
  branch_heads.any?
end

#latest_for_pacticipant?Boolean

Returns:

  • (Boolean)


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

def latest_for_pacticipant?
  latest_version_for_pacticipant == self
end

#latest_pact_publicationObject

What about provider??? This makes no sense



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

def latest_pact_publication
  pact_publications.last
end

#tag_namesObject



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

def tag_names
  tags.collect(&:name)
end

#to_sObject



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

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

#version_and_updated_dateObject



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

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