summaryrefslogtreecommitdiff
path: root/lib/gitlab/template/finders/base_template_finder.rb
blob: a5105439b126e3b6e44ceb36b44d49661147e322 (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
module Gitlab
  module Template
    module Finders
      class BaseTemplateFinder
        def initialize(base_dir)
          @base_dir = base_dir
        end

        def list_files_for
          raise NotImplementedError
        end

        def read
          raise NotImplementedError
        end

        def find
          raise NotImplementedError
        end

        def category_directory(category)
          return @base_dir unless category.present?

          File.join(@base_dir, @categories[category])
        end

        class << self
          def filter_regex(extension)
            /#{Regexp.escape(extension)}\z/
          end
        end
      end
    end
  end
end