Class: Suma::SchemaCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/suma/schema_compiler.rb

Overview

Orchestrates the compilation of a single EXPRESS schema into HTML/XML via Metanorma.

SchemaCompiler owns all file I/O and the Metanorma::Compile invocation for one schema; the rendered AsciiDoc body is supplied by a SchemaTemplate that the caller injects. This split means templates can be tested as pure functions and the compiler can be tested with a real adoc fixture, without either depending on the other.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema:, output_path:, template:) ⇒ SchemaCompiler

Returns a new instance of SchemaCompiler.



18
19
20
21
22
23
# File 'lib/suma/schema_compiler.rb', line 18

def initialize(schema:, output_path:, template:)
  @schema = schema
  @id = schema.id
  @output_path = output_path
  @template = template
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/suma/schema_compiler.rb', line 16

def id
  @id
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



16
17
18
# File 'lib/suma/schema_compiler.rb', line 16

def output_path
  @output_path
end

#schemaObject (readonly)

Returns the value of attribute schema.



16
17
18
# File 'lib/suma/schema_compiler.rb', line 16

def schema
  @schema
end

#templateObject (readonly)

Returns the value of attribute template.



16
17
18
# File 'lib/suma/schema_compiler.rb', line 16

def template
  @template
end

Instance Method Details

#compileObject



25
26
27
28
29
30
# File 'lib/suma/schema_compiler.rb', line 25

def compile
  save_config
  save_adoc
  invoke_metanorma
  self
end

#extensionsObject



36
37
38
# File 'lib/suma/schema_compiler.rb', line 36

def extensions
  template.extensions
end

#output_xml_pathObject



32
33
34
# File 'lib/suma/schema_compiler.rb', line 32

def output_xml_path
  filename_adoc("xml")
end