BigW Consortium Gitlab

loader.rb 476 Bytes
Newer Older
1 2 3
module Gitlab
  module Ci
    class Config
4
      class Loader
5 6 7 8 9 10 11 12 13 14
        class FormatError < StandardError; end

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

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

15
        def load!
16 17 18 19 20 21 22 23 24 25
          unless valid?
            raise FormatError, 'Invalid configuration format'
          end

          @config.deep_symbolize_keys
        end
      end
    end
  end
end