Class: DDSL::SchemaParser
- Inherits:
-
Object
- Object
- DDSL::SchemaParser
- Defined in:
- lib/ddsl/schema_parser.rb
Defined Under Namespace
Classes: InvalidError
Constant Summary collapse
- SCHEMA_MAP =
{ 'builds' => SchemaBuild, 'runs' => SchemaRun }.freeze
Instance Method Summary collapse
-
#parse!(data) ⇒ Hash
Parse given potentially compatible data schema.
Instance Method Details
#parse!(data) ⇒ Hash
Parse given potentially compatible data schema. Parser will merge template values if used.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ddsl/schema_parser.rb', line 25 def parse!(data) errors = SchemaDDSL.new(data).validate # Validate initial schema without potential templates applied raise InvalidError, 'Invalid schema' if errors&.count&.positive? # Apply potentially defined templates to the data applied_data = DDSL::TemplateMerger.new(data).apply # Re evaluate schema in case template corrupted the data %w[builds runs].each { |x| validate_schema_key!(applied_data, x) } applied_data end |