diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-07 22:24:14 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-08-07 22:24:14 +0300 |
commit | 4c8b666893aa9f5ab94b800489fd9e3240ad4f5e (patch) | |
tree | 4c499f649a9b3461963d9c084333259aad8a57be /lib/gitlab | |
parent | 4e2b630df716174ea9b07319a0fd5eda7b60cf8e (diff) | |
parent | ae5003a35ef47bbdafc51e3e9d0f27039f9d20a2 (diff) |
Merge branch 'zj-project-templates' into 'master'
Allow projects to be started from a template
Closes #32420
See merge request !13108
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/project_template.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/gitlab/project_template.rb b/lib/gitlab/project_template.rb new file mode 100644 index 00000000000..cf461adf697 --- /dev/null +++ b/lib/gitlab/project_template.rb @@ -0,0 +1,45 @@ +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') + ].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 |