Class: Gitlab::Config::Loader::Yaml
Constant Summary
collapse
- DataTooLargeError =
Class.new(Loader::FormatError)
- NotHashError =
Class.new(Loader::FormatError)
- MAX_YAML_SIZE =
1.megabyte
- MAX_YAML_DEPTH =
100
Instance Method Summary
collapse
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(config) ⇒ Yaml
Returns a new instance of Yaml.
15
16
17
18
19
|
# File 'lib/gitlab/config/loader/yaml.rb', line 15
def initialize(config)
@config = YAML.safe_load(config, [Symbol], [], true)
rescue Psych::Exception => e
raise Loader::FormatError, e.message
end
|
Instance Method Details
#load! ⇒ Object
32
33
34
|
# File 'lib/gitlab/config/loader/yaml.rb', line 32
def load!
@symbolized_config ||= load_raw!.deep_symbolize_keys
end
|
#load_raw! ⇒ Object
25
26
27
28
29
30
|
# File 'lib/gitlab/config/loader/yaml.rb', line 25
def load_raw!
raise DataTooLargeError, 'The parsed YAML is too big' if too_big?
raise NotHashError, 'Invalid configuration format' unless hash?
@config
end
|
#valid? ⇒ Boolean
21
22
23
|
# File 'lib/gitlab/config/loader/yaml.rb', line 21
def valid?
hash? && !too_big?
end
|