summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/loader.rb
blob: dbf6eb0edbe6625f60db0111822cf9b482919e05 (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
        class FormatError < StandardError; end

        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