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
TODO: make aliases configurable.
- #output_formats ⇒ Object
- #register(processor) ⇒ Object
- #root_tags ⇒ Object
- #supported_backends ⇒ Object
Constructor Details
#initialize ⇒ Registry
TODO: make aliases configurable
15 16 17 18 19 |
# File 'lib/metanorma/registry/registry.rb', line 15 def initialize @processors = {} @aliases = { csd: :cc, m3d: :m3aawg, mpfd: :mpfa, csand: :csa, icc: :iso } 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
21 22 23 |
# File 'lib/metanorma/registry/registry.rb', line 21 def alias(flavour) @aliases[flavour] end |
#find_processor(short) ⇒ Object
36 37 38 |
# File 'lib/metanorma/registry/registry.rb', line 36 def find_processor(short) @processors[short.to_sym] end |
#output_formats ⇒ Object
44 45 46 47 48 49 |
# File 'lib/metanorma/registry/registry.rb', line 44 def output_formats @processors.inject({}) do |acc, (k, v)| acc[k] = v.output_formats acc end end |
#register(processor) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/metanorma/registry/registry.rb', line 25 def register(processor) processor < ::Metanorma::Processor or raise Error p = processor.new # p.short[-1] is the canonical name short = Array(p.short) @processors[short[-1]] = p short.each { |s| @aliases[s] = short[-1] } Array(p.short) Util.log("[metanorma] processor \"#{Array(p.short)[0]}\" registered", :info) end |
#root_tags ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/metanorma/registry/registry.rb', line 51 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
40 41 42 |
# File 'lib/metanorma/registry/registry.rb', line 40 def supported_backends @processors.keys end |