2017-07-26 08:21:53 -04:00
|
|
|
module Gitlab
|
|
|
|
class ProjectTemplate
|
|
|
|
attr_reader :title, :name
|
|
|
|
|
|
|
|
def initialize(name, title)
|
|
|
|
@name, @title = name, title
|
|
|
|
end
|
|
|
|
|
2017-08-01 08:23:04 -04:00
|
|
|
alias_method :logo, :name
|
2017-07-26 08:21:53 -04:00
|
|
|
|
|
|
|
def file
|
2017-08-01 06:38:10 -04:00
|
|
|
archive_path.open
|
2017-07-26 08:21:53 -04:00
|
|
|
end
|
|
|
|
|
2017-08-01 06:38:10 -04:00
|
|
|
def archive_path
|
2017-07-26 08:21:53 -04:00
|
|
|
Rails.root.join("vendor/project_templates/#{name}.tar.gz")
|
|
|
|
end
|
|
|
|
|
2017-08-01 06:38:10 -04:00
|
|
|
def clone_url
|
|
|
|
"https://gitlab.com/gitlab-org/project-templates/#{name}.git"
|
|
|
|
end
|
|
|
|
|
2017-07-26 08:21:53 -04:00
|
|
|
def ==(other)
|
|
|
|
name == other.name && title == other.title
|
|
|
|
end
|
|
|
|
|
2017-08-01 08:34:11 -04:00
|
|
|
TEMPLATES_TABLE = [
|
2017-08-09 06:16:43 -04:00
|
|
|
ProjectTemplate.new('rails', 'Ruby on Rails'),
|
|
|
|
ProjectTemplate.new('spring', 'Spring'),
|
|
|
|
ProjectTemplate.new('express', 'NodeJS Express')
|
2017-07-26 08:21:53 -04:00
|
|
|
].freeze
|
|
|
|
|
|
|
|
class << self
|
|
|
|
def all
|
2017-08-01 08:34:11 -04:00
|
|
|
TEMPLATES_TABLE
|
2017-07-26 08:21:53 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def find(name)
|
|
|
|
all.find { |template| template.name == name.to_s }
|
|
|
|
end
|
2017-08-01 06:38:10 -04:00
|
|
|
|
|
|
|
def archive_directory
|
|
|
|
Rails.root.join("vendor_directory/project_templates")
|
|
|
|
end
|
2017-07-26 08:21:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|