2016-06-03 14:54:33 -04:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
2016-06-06 02:20:55 -04:00
|
|
|
class Loader
|
2016-06-03 14:54:33 -04:00
|
|
|
class FormatError < StandardError; end
|
|
|
|
|
|
|
|
def initialize(config)
|
|
|
|
@config = YAML.safe_load(config, [Symbol], [], true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid?
|
|
|
|
@config.is_a?(Hash)
|
|
|
|
end
|
|
|
|
|
2016-06-07 06:53:46 -04:00
|
|
|
def load!
|
2016-06-03 14:54:33 -04:00
|
|
|
unless valid?
|
|
|
|
raise FormatError, 'Invalid configuration format'
|
|
|
|
end
|
|
|
|
|
|
|
|
@config.deep_symbolize_keys
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|