6391406774
Related to !13108. Mostly this is just running the rake task and changing the task a bit to catch cases like the project already existing or so. The rake task moves archives to the vendor/project_template directory, which are checked in too.
47 lines
956 B
Ruby
47 lines
956 B
Ruby
module Gitlab
|
|
class ProjectTemplate
|
|
attr_reader :title, :name
|
|
|
|
def initialize(name, title)
|
|
@name, @title = name, title
|
|
end
|
|
|
|
alias_method :logo, :name
|
|
|
|
def file
|
|
archive_path.open
|
|
end
|
|
|
|
def archive_path
|
|
Rails.root.join("vendor/project_templates/#{name}.tar.gz")
|
|
end
|
|
|
|
def clone_url
|
|
"https://gitlab.com/gitlab-org/project-templates/#{name}.git"
|
|
end
|
|
|
|
def ==(other)
|
|
name == other.name && title == other.title
|
|
end
|
|
|
|
TEMPLATES_TABLE = [
|
|
ProjectTemplate.new('rails', 'Ruby on Rails'),
|
|
ProjectTemplate.new('spring', 'Spring'),
|
|
ProjectTemplate.new('express', 'NodeJS Express')
|
|
].freeze
|
|
|
|
class << self
|
|
def all
|
|
TEMPLATES_TABLE
|
|
end
|
|
|
|
def find(name)
|
|
all.find { |template| template.name == name.to_s }
|
|
end
|
|
|
|
def archive_directory
|
|
Rails.root.join("vendor_directory/project_templates")
|
|
end
|
|
end
|
|
end
|
|
end
|