Welcome to mirror list, hosted at ThFree Co, Russian Federation.

metadatum.rb « maven « packages « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 471c4b3a39240c942cc52f288428d92ccc737d3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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

  scope :for_package_ids, -> (package_ids) { where(package_id: package_ids) }
  scope :with_path, ->(path) { where(path: path) }
  scope :order_created, -> { reorder('created_at ASC') }

  def self.pluck_app_name
    pluck(:app_name)
  end

  private

  def maven_package_type
    unless package&.maven?
      errors.add(:base, _('Package type must be Maven'))
    end
  end
end