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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/packages/rpm/metadatum.rb')
-rw-r--r--app/models/packages/rpm/metadatum.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/app/models/packages/rpm/metadatum.rb b/app/models/packages/rpm/metadatum.rb
new file mode 100644
index 00000000000..07361995a12
--- /dev/null
+++ b/app/models/packages/rpm/metadatum.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+module Packages
+ module Rpm
+ class Metadatum < ApplicationRecord
+ self.primary_key = :package_id
+
+ belongs_to :package, -> { where(package_type: :rpm) }, inverse_of: :rpm_metadatum
+
+ validates :package, presence: true
+
+ validates :epoch,
+ presence: true,
+ numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+
+ validates :release,
+ presence: true,
+ length: { maximum: 128 }
+
+ validates :summary,
+ presence: true,
+ length: { maximum: 1000 }
+
+ validates :description,
+ presence: true,
+ length: { maximum: 5000 }
+
+ validates :arch,
+ presence: true,
+ length: { maximum: 255 }
+
+ validates :license,
+ allow_nil: true,
+ length: { maximum: 1000 }
+
+ validates :url,
+ allow_nil: true,
+ length: { maximum: 1000 }
+
+ validate :rpm_package_type
+
+ private
+
+ def rpm_package_type
+ return if package&.rpm?
+
+ errors.add(:base, _('Package type must be RPM'))
+ end
+ end
+ end
+end