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

loader.rb « config « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e7d9f6a77610009073694731d802f8560de28ab8 (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
module Gitlab
  module Ci
    class Config
      class Loader
        FormatError = Class.new(StandardError)

        def initialize(config)
          @config = YAML.safe_load(config, [Symbol], [], true)
        end

        def valid?
          @config.is_a?(Hash)
        end

        def load!
          unless valid?
            raise FormatError, 'Invalid configuration format'
          end

          @config.deep_symbolize_keys
        end
      end
    end
  end
end