debian-mirror-gitlab/app/models/packages/maven/metadatum.rb

37 lines
888 B
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
class Packages::Maven::Metadatum < ApplicationRecord
belongs_to :package, -> { where(package_type: :maven) }
validates :package, presence: true
validates :path,
presence: true,
format: { with: Gitlab::Regex.maven_path_regex }
validates :app_group,
presence: true,
format: { with: Gitlab::Regex.maven_app_group_regex }
validates :app_name,
presence: true,
format: { with: Gitlab::Regex.maven_app_name_regex }
validate :maven_package_type
2021-04-17 20:07:23 +05:30
scope :for_package_ids, -> (package_ids) { where(package_id: package_ids) }
2021-04-29 21:17:54 +05:30
scope :with_path, ->(path) { where(path: path) }
2021-04-17 20:07:23 +05:30
scope :order_created, -> { reorder('created_at ASC') }
def self.pluck_app_name
pluck(:app_name)
end
2020-07-28 23:09:34 +05:30
private
def maven_package_type
unless package&.maven?
errors.add(:base, _('Package type must be Maven'))
end
end
end