Welcome to mirror list, hosted at ThFree Co, Russian Federation.

template_finder.rb « finders « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ea0251bffb693eeee904fea4a6149862a37b82ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class TemplateFinder
  VENDORED_TEMPLATES = {
    dockerfiles: ::Gitlab::Template::DockerfileTemplate,
    gitignores: ::Gitlab::Template::GitignoreTemplate,
    gitlab_ci_ymls: ::Gitlab::Template::GitlabCiYmlTemplate
  }.freeze

  class << self
    def build(type, params = {})
      if type == :licenses
        LicenseTemplateFinder.new(params)
      else
        new(type, params)
      end
    end
  end

  attr_reader :type, :params

  attr_reader :vendored_templates
  private :vendored_templates

  def initialize(type, params = {})
    @type = type
    @params = params

    @vendored_templates = VENDORED_TEMPLATES.fetch(type)
  end

  def execute
    if params[:name]
      vendored_templates.find(params[:name])
    else
      vendored_templates.all
    end
  end
end