Files
gitlabhq/lib/gitlab/ci/config/parser.rb
T
Grzegorz Bizon d2b708ac43 Extract CI config YAML parser to a separate class
With this approach it would be easier to add different sources of
configuration, that we do not necessairly have to be in YAML format.
2016-06-03 21:10:50 +02:00

26 lines
476 B
Ruby

module Gitlab
module Ci
class Config
class Parser
class FormatError < StandardError; end
def initialize(config)
@config = YAML.safe_load(config, [Symbol], [], true)
end
def valid?
@config.is_a?(Hash)
end
def parse
unless valid?
raise FormatError, 'Invalid configuration format'
end
@config.deep_symbolize_keys
end
end
end
end
end