debian-mirror-gitlab/lib/gitlab/project_template.rb

48 lines
1.4 KiB
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
module Gitlab
class ProjectTemplate
2018-03-17 18:26:18 +05:30
attr_reader :title, :name, :description, :preview
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
def initialize(name, title, description, preview)
@name, @title, @description, @preview = name, title, description, preview
2017-09-10 17:25:29 +05:30
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 = [
2018-10-15 14:42:47 +05:30
ProjectTemplate.new('rails', 'Ruby on Rails', 'Includes an MVC structure, Gemfile, Rakefile, along with many others, to help you get started.', 'https://gitlab.com/gitlab-org/project-templates/rails'),
ProjectTemplate.new('spring', 'Spring', 'Includes an MVC structure, mvnw and pom.xml to help you get started.', 'https://gitlab.com/gitlab-org/project-templates/spring'),
ProjectTemplate.new('express', 'NodeJS Express', 'Includes an MVC structure to help you get started.', 'https://gitlab.com/gitlab-org/project-templates/express')
2017-09-10 17:25:29 +05:30
].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