mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-16 16:16:43 +10:00
With this approach it would be easier to add different sources of configuration, that we do not necessairly have to be in YAML format.
26 lines
476 B
Ruby
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
|