Class: Kumi::TextSchema
- Inherits:
-
Object
- Object
- Kumi::TextSchema
- Extended by:
- Schema
- Defined in:
- lib/kumi/text_schema.rb
Overview
Text-based schema that extends Kumi::Schema with text parsing capabilities
Class Method Summary collapse
-
.from_text(text, source_file: '<input>') ⇒ Object
Create a schema from text using the same pipeline as Ruby DSL.
-
.valid?(text, source_file: '<input>') ⇒ Boolean
Validate text schema.
-
.validate(text, source_file: '<input>') ⇒ Object
Get validation diagnostics.
Class Method Details
.from_text(text, source_file: '<input>') ⇒ Object
Create a schema from text using the same pipeline as Ruby DSL
12 13 14 15 16 17 18 19 |
# File 'lib/kumi/text_schema.rb', line 12 def self.from_text(text, source_file: '<input>') # Parse text to AST (same as RubyParser::Dsl.build_syntax_tree) @__kumi_syntax_tree__ = Kumi::TextParser.parse(text, source_file: source_file).freeze @__analyzer_result__ = Analyzer.analyze!(@__kumi_syntax_tree__).freeze @__compiled_schema__ = Compiler.compile(@__kumi_syntax_tree__, analyzer: @__analyzer_result__).freeze Inspector.new(@__kumi_syntax_tree__, @__analyzer_result__, @__compiled_schema__) end |
.valid?(text, source_file: '<input>') ⇒ Boolean
Validate text schema
22 23 24 |
# File 'lib/kumi/text_schema.rb', line 22 def self.valid?(text, source_file: '<input>') Kumi::TextParser.valid?(text, source_file: source_file) end |
.validate(text, source_file: '<input>') ⇒ Object
Get validation diagnostics
27 28 29 |
# File 'lib/kumi/text_schema.rb', line 27 def self.validate(text, source_file: '<input>') Kumi::TextParser.validate(text, source_file: source_file) end |