Class: Metanorma::Release::RelatonEnricher
- Inherits:
-
Object
- Object
- Metanorma::Release::RelatonEnricher
- Defined in:
- lib/metanorma/release/relaton_enricher.rb
Defined Under Namespace
Classes: EnrichResult
Class Attribute Summary collapse
-
.flavor_registry ⇒ Object
readonly
Returns the value of attribute flavor_registry.
Class Method Summary collapse
Instance Method Summary collapse
- #enrich(document_index, output_dir, bib_dir: 'relaton') ⇒ Object
-
#initialize(flavor: nil, registry_name: 'Document Registry') ⇒ RelatonEnricher
constructor
A new instance of RelatonEnricher.
Constructor Details
#initialize(flavor: nil, registry_name: 'Document Registry') ⇒ RelatonEnricher
Returns a new instance of RelatonEnricher.
75 76 77 78 |
# File 'lib/metanorma/release/relaton_enricher.rb', line 75 def initialize(flavor: nil, registry_name: 'Document Registry') @flavor = flavor @registry_name = registry_name end |
Class Attribute Details
.flavor_registry ⇒ Object (readonly)
Returns the value of attribute flavor_registry.
23 24 25 |
# File 'lib/metanorma/release/relaton_enricher.rb', line 23 def flavor_registry @flavor_registry end |
Class Method Details
.register_flavor(name, &loader) ⇒ Object
19 20 21 |
# File 'lib/metanorma/release/relaton_enricher.rb', line 19 def register_flavor(name, &loader) @flavor_registry[name.to_s] = loader end |
Instance Method Details
#enrich(document_index, output_dir, bib_dir: 'relaton') ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/metanorma/release/relaton_enricher.rb', line 80 def enrich(document_index, output_dir, bib_dir: 'relaton') return nil if document_index.empty? flavor = resolve_flavor(document_index) klass = resolve_class(flavor) documents = enrich_documents(document_index, output_dir, klass) return nil if documents.empty? dest = File.join(output_dir, bib_dir) write_index(documents, dest) EnrichResult.new(item_count: documents.length, output_dir: dest, documents: documents) rescue LoadError warn ' (relaton gem not available — bibliography skipped)' nil end |