Class: Metanorma::Registry
- Inherits:
-
Object
- Object
- Metanorma::Registry
- Includes:
- Singleton
- Defined in:
- lib/metanorma/registry/registry.rb
Instance Attribute Summary collapse
-
#processors ⇒ Object
readonly
Returns the value of attribute processors.
Instance Method Summary collapse
- #alias(flavour) ⇒ Object
- #find_processor(short) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #output_formats ⇒ Object
- #register(processor) ⇒ Object
- #root_tags ⇒ Object
- #supported_backends ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
14 15 16 17 |
# File 'lib/metanorma/registry/registry.rb', line 14 def initialize @processors = {} @aliases = { csd: :cc, m3d: :m3aawg, mpfd: :mpfa, csand: :csa } end |
Instance Attribute Details
#processors ⇒ Object (readonly)
Returns the value of attribute processors.
12 13 14 |
# File 'lib/metanorma/registry/registry.rb', line 12 def processors @processors end |
Instance Method Details
#alias(flavour) ⇒ Object
19 20 21 |
# File 'lib/metanorma/registry/registry.rb', line 19 def alias(flavour) @aliases[flavour] end |
#find_processor(short) ⇒ Object
38 39 40 |
# File 'lib/metanorma/registry/registry.rb', line 38 def find_processor(short) @processors[short.to_sym] end |
#output_formats ⇒ Object
46 47 48 49 50 51 |
# File 'lib/metanorma/registry/registry.rb', line 46 def output_formats @processors.inject({}) do |acc, (k, v)| acc[k] = v.output_formats acc end end |
#register(processor) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/metanorma/registry/registry.rb', line 23 def register(processor) raise Error unless processor < ::Metanorma::Processor p = processor.new # p.short[-1] is the canonical name short = Array(p.short) @processors[short[-1]] = p short.each do |s| @aliases[s] = short[-1] end Array(p.short) Util.log("[metanorma] processor \"#{Array(p.short)[0]}\" registered", :info) end |
#root_tags ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/metanorma/registry/registry.rb', line 53 def @processors.inject({}) do |acc, (k, v)| if v.asciidoctor_backend x = Asciidoctor.load nil, { backend: v.asciidoctor_backend } acc[k] = x.converter.xml_root_tag end acc end end |
#supported_backends ⇒ Object
42 43 44 |
# File 'lib/metanorma/registry/registry.rb', line 42 def supported_backends @processors.keys end |