2019-01-01 20:40:33 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Releases
|
|
|
|
class Source
|
|
|
|
include ActiveModel::Model
|
2019-01-02 05:56:03 -05:00
|
|
|
|
2019-01-01 20:40:33 -05:00
|
|
|
attr_accessor :project, :tag_name, :format
|
|
|
|
|
|
|
|
class << self
|
|
|
|
def all(project, tag_name)
|
2019-10-31 11:06:41 -04:00
|
|
|
Gitlab::Workhorse::ARCHIVE_FORMATS.map do |format|
|
2019-01-01 20:40:33 -05:00
|
|
|
Releases::Source.new(project: project,
|
|
|
|
tag_name: tag_name,
|
|
|
|
format: format)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def url
|
|
|
|
Gitlab::Routing
|
|
|
|
.url_helpers
|
|
|
|
.project_archive_url(project,
|
2019-01-02 01:01:15 -05:00
|
|
|
id: File.join(tag_name, archive_prefix),
|
2019-01-01 20:40:33 -05:00
|
|
|
format: format)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-01-02 01:01:15 -05:00
|
|
|
def archive_prefix
|
2019-01-01 20:40:33 -05:00
|
|
|
"#{project.path}-#{tag_name.tr('/', '-')}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|