Module: Lutaml::Model::Schema::RngCompiler
- Extended by:
- RngCompiler
- Included in:
- RngCompiler
- Defined in:
- lib/lutaml/model/schema/rng_compiler.rb,
lib/lutaml/model/schema/rng_compiler/rng_helpers.rb,
lib/lutaml/model/schema/rng_compiler/element_visitor.rb,
lib/lutaml/model/schema/rng_compiler/member_collector.rb,
lib/lutaml/model/schema/rng_compiler/define_classifier.rb,
lib/lutaml/model/schema/rng_compiler/value_type_resolver.rb
Overview
Compiles a parsed RNG grammar into Lutaml::Model::Serializable Ruby source. Mirrors XmlCompiler in API, options, and output format.
Requires the rng gem (https://github.com/lutaml/rng) at runtime --
that gem provides the Rng::Grammar parsing model. lutaml-model itself
has no dependency on it. Registration of Schema.from_relaxng is done
in lib/lutaml/xml.rb (alongside Schema.from_xml and Schema.to_relaxng).
Entry point: Lutaml::Model::Schema::RngCompiler.to_models(rng, options)
Defined Under Namespace
Modules: RngHelpers Classes: DefineClassifier, ElementVisitor, MemberCollector, ValueTypeResolver
Constant Summary collapse
- DATA_TYPE_MAP =
Map RNG values to Lutaml::Model attribute type symbols. Mirrors Lutaml::Xml::Schema::RelaxngSchema.get_relaxng_type so RNG-generate + compile-back is a round-trip.
{ "string" => :string, "integer" => :integer, "int" => :integer, "long" => :integer, "boolean" => :boolean, "float" => :float, "double" => :float, "decimal" => :decimal, "date" => :date, "dateTime" => :date_time, "time" => :time, }.freeze
- DEFAULT_DATA_TYPE =
:string
Instance Method Summary collapse
Instance Method Details
#compile(rng, options = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/lutaml/model/schema/rng_compiler.rb', line 54 def compile(rng, = {}) require_rng_parser! opts = () grammar = parse_grammar(rng, opts) classes, namespaces = compile_grammar(grammar) entries = classes.map { |name, spec| CompiledOutput::Entry.new(name, spec, :model) } + namespaces.map { |name, spec| CompiledOutput::Entry.new(name, spec, :namespace) } CompiledOutput.new( entries: entries, module_namespace: opts[:module_namespace], register_id: opts[:register_id], ) end |
#to_models(rng, options = {}) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/lutaml/model/schema/rng_compiler.rb', line 45 def to_models(rng, = {}) require_rng_parser! opts = () output = compile(rng, opts) dispatch_output(output, (opts)) end |