debian-mirror-gitlab/lib/gitlab/config/loader/yaml.rb

28 lines
554 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
module Gitlab
2019-02-15 15:39:39 +05:30
module Config
module Loader
class Yaml
def initialize(config)
@config = YAML.safe_load(config, [Symbol], [], true)
2018-03-17 18:26:18 +05:30
rescue Psych::Exception => e
2019-02-15 15:39:39 +05:30
raise Loader::FormatError, e.message
end
def valid?
@config.is_a?(Hash)
end
def load!
unless valid?
2019-02-15 15:39:39 +05:30
raise Loader::FormatError, 'Invalid configuration format'
end
@config.deep_symbolize_keys
end
end
end
end
end