class PactBroker::Versions::Service
Public Class Methods
create_or_overwrite(pacticipant_name, version_number, version)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 25 def self.create_or_overwrite(pacticipant_name, version_number, version) pacticipant = pacticipant_repository.find_by_name_or_create(pacticipant_name) version = version_repository.create_or_overwrite(pacticipant, version_number, version) version end
create_or_update(pacticipant_name, version_number, version)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 31 def self.create_or_update(pacticipant_name, version_number, version) pacticipant = pacticipant_repository.find_by_name_or_create(pacticipant_name) version = version_repository.create_or_update(pacticipant, version_number, version) version end
delete(version)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 41 def self.delete version tag_repository.delete_by_version_id version.id webhook_repository.delete_triggered_webhooks_by_version_id version.id pact_repository.delete_by_version_id version.id verification_repository.delete_by_provider_version_id version.id version_repository.delete_by_id version.id end
find_by_pacticipant_name_and_latest_tag(pacticipant_name, tag)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 21 def self.find_by_pacticipant_name_and_latest_tag(pacticipant_name, tag) version_repository.find_by_pacticipant_name_and_latest_tag(pacticipant_name, tag) end
find_by_pacticipant_name_and_number(params)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 17 def self.find_by_pacticipant_name_and_number params version_repository.find_by_pacticipant_name_and_number params.fetch(:pacticipant_name), params.fetch(:pacticipant_version_number) end
find_latest_by_pacticpant_name(params)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 13 def self.find_latest_by_pacticpant_name params version_repository.find_latest_by_pacticpant_name params.fetch(:pacticipant_name) end
find_latest_version_from_main_branch(pacticipant)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 37 def self.find_latest_version_from_main_branch(pacticipant) version_repository.find_latest_version_from_main_branch(pacticipant) end
maybe_set_version_branch_from_tag(version, tag_name)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 49 def self.maybe_set_version_branch_from_tag(version, tag_name) if use_tag_as_branch?(version) && version.branch_versions.empty? logger.info "Adding #{version.pacticipant.name} version #{version.number} to branch '#{tag_name}' (from first tag, because use_first_tag_as_branch=true)" branch_version_repository.add_branch(version, tag_name, auto_created: true) end end
Private Class Methods
now()
click to toggle source
# File lib/pact_broker/versions/service.rb, line 63 def self.now Time.now.utc.to_datetime end
use_tag_as_branch?(version)
click to toggle source
# File lib/pact_broker/versions/service.rb, line 56 def self.use_tag_as_branch?(version) version.tags.count == 0 && PactBroker.configuration.use_first_tag_as_branch && ((now - version.created_at.to_datetime) * 24 * 60 * 60) <= PactBroker.configuration.use_first_tag_as_branch_time_limit end