2016-06-16 23:09:34 +05:30
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
|
|
|
class Loader
|
2017-08-17 22:00:37 +05:30
|
|
|
FormatError = Class.new(StandardError)
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
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
|