13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/rails_drips/definition_loader.rb', line 13
def self.load_string(yaml, source: nil)
raw = YAML.safe_load(yaml, permitted_classes: [], permitted_symbols: [], aliases: false)
definition = deep_stringify(raw)
normalize!(definition)
errors = DefinitionSchema.validate(definition)
raise DefinitionInvalid, errors.map { |error| source ? "#{source}: #{error}" : error } if errors.any?
definition
rescue Psych::Exception => error
raise DefinitionInvalid, [source ? "#{source}: #{error.message}" : error.message]
end
|