Class: Suma::SchemaCollection
- Inherits:
-
Object
- Object
- Suma::SchemaCollection
- Defined in:
- lib/suma/schema_collection.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#docs ⇒ Object
Returns the value of attribute docs.
-
#manifest ⇒ Object
Returns the value of attribute manifest.
-
#output_path_docs ⇒ Object
Returns the value of attribute output_path_docs.
-
#output_path_schemas ⇒ Object
Returns the value of attribute output_path_schemas.
-
#schemas ⇒ Object
Returns the value of attribute schemas.
Instance Method Summary collapse
- #compile ⇒ Object
- #doc_from_schema_name(schema_name) ⇒ Object
- #finalize ⇒ Object
-
#initialize(config: nil, config_yaml: nil, output_path_docs: nil, output_path_schemas: nil, manifest: nil) ⇒ SchemaCollection
constructor
A new instance of SchemaCollection.
Constructor Details
#initialize(config: nil, config_yaml: nil, output_path_docs: nil, output_path_schemas: nil, manifest: nil) ⇒ SchemaCollection
Returns a new instance of SchemaCollection.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/suma/schema_collection.rb', line 10 def initialize(config: nil, config_yaml: nil, output_path_docs: nil, output_path_schemas: nil, manifest: nil) @schemas = {} @docs = {} @schema_name_to_docs = {} @output_path_docs = Pathname.new(output_path_docs || Dir.pwd). @output_path_schemas = Pathname.new( output_path_schemas || Dir.pwd, ). @config = config @config ||= config_yaml && Expressir::SchemaManifest.from_file(config_yaml) @manifest = manifest end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/suma/schema_collection.rb', line 7 def config @config end |
#docs ⇒ Object
Returns the value of attribute docs.
7 8 9 |
# File 'lib/suma/schema_collection.rb', line 7 def docs @docs end |
#manifest ⇒ Object
Returns the value of attribute manifest.
7 8 9 |
# File 'lib/suma/schema_collection.rb', line 7 def manifest @manifest end |
#output_path_docs ⇒ Object
Returns the value of attribute output_path_docs.
7 8 9 |
# File 'lib/suma/schema_collection.rb', line 7 def output_path_docs @output_path_docs end |
#output_path_schemas ⇒ Object
Returns the value of attribute output_path_schemas.
7 8 9 |
# File 'lib/suma/schema_collection.rb', line 7 def output_path_schemas @output_path_schemas end |
#schemas ⇒ Object
Returns the value of attribute schemas.
7 8 9 |
# File 'lib/suma/schema_collection.rb', line 7 def schemas @schemas end |
Instance Method Details
#compile ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/suma/schema_collection.rb', line 39 def compile finalize exporter = SchemaExporter.new( schemas: schemas.values, output_path: @output_path_schemas, options: { annotations: false }, ) exporter.export docs.each_pair do |_schema_id, compiler| compiler.compile end end |
#doc_from_schema_name(schema_name) ⇒ Object
24 25 26 |
# File 'lib/suma/schema_collection.rb', line 24 def doc_from_schema_name(schema_name) @schema_name_to_docs[schema_name] end |
#finalize ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/suma/schema_collection.rb', line 28 def finalize process_schemas(@config.schemas, SchemaTemplate::Plain) schemas_only_entries = ManifestTraverser.new(@manifest).find_schemas_only schemas_only_entries.each do |entry| next unless entry.schema_config process_schemas(entry.schema_config.schemas, SchemaTemplate::Document) end end |