module Asciidoctor::Converter::Factory
def self.create backend, opts = {}
def self.create backend, opts = {} default.create backend, opts end
def self.default *args
def self.default *args Converter end
def self.new converters = nil, proxy_default: true
proxy_default - A Boolean keyword arg indicating whether to proxy the default registry (optional, default: true).
backend names and the values are converter classes or instances.
converters - An optional Hash of converters to use in place of ones in the default registry. The keys are
entries in the proxy registry are preferred over matching entries from the default registry.
arg is set (true by default), and optionally seed it with the specified converters map. If proxy_default is set,
Public: Create an instance of DefaultProxyFactory or CustomFactory, depending on whether the proxy_default keyword
def self.new converters = nil, proxy_default: true proxy_default ? (DefaultFactoryProxy.new converters) : (CustomFactory.new converters) end
def converters
def converters registry.merge end
def create backend, opts = {}
:delegate_backend - a backend String of the last converter in the {CompositeConverter} chain (optional).
:template_dirs - a String Array of directories used to instantiate a {TemplateConverter} (optional).
opts - a Hash of options to customize creation; also passed to the converter's constructor:
backend - the String backend name.
found, the built-in converter is returned or nil if no converter is found.
delegates to a {TemplateConverter} and, if found, the built-in converter. If the +:template_dirs+ key is not
+:template_dirs+ key is found in the Hash passed as the second argument, a {CompositeConverter} is created that
immediately. If a custom Converter is not found, an attempt is made to find a built-in converter. If the
If a custom Converter is found to convert the specified backend, it's instantiated (if necessary) and returned
the backend. This method accepts an optional Hash of options that are passed to the converter's constructor.
Public: Create a new Converter object that can be used to convert {AbstractNode}s to the format associated with
def create backend, opts = {} if (converter = self.for backend) converter = converter.new backend, opts if ::Class === converter if (template_dirs = opts[:template_dirs]) && BackendTraits === converter && converter.supports_templates? CompositeConverter.new backend, (TemplateConverter.new backend, template_dirs, opts), converter, backend_traits_source: converter else converter end elsif (template_dirs = opts[:template_dirs]) if (delegate_backend = opts[:delegate_backend]) && (converter = self.for delegate_backend) converter = converter.new delegate_backend, opts if ::Class === converter CompositeConverter.new backend, (TemplateConverter.new backend, template_dirs, opts), converter, backend_traits_source: converter else TemplateConverter.new backend, template_dirs, opts end end end
def for backend
backend - The String backend name.
Public: Lookup the custom converter registered with this factory to handle the specified backend.
def for backend registry[backend] end
def register converter, *backends
backends - One or more String backend names that this converter should be registered to handle.
converter - The Converter class to register.
backend is an asterisk (i.e., +*+), the converter will handle any backend for which a converter is not registered.
Public: Register a custom converter with this factory to handle conversion for the specified backends. If the
def register converter, *backends backends.each {|backend| backend == '*' ? (registry.default = converter) : (registry[backend] = converter) } end
def registry
def registry raise ::NotImplementedError, %(#{Factory} subclass #{self.class} must implement the ##{__method__} method) end