Sha256: 86eb37d72cf37c07518fd0bd1c3510be6804500c568f16a45adc3cd3fa0c60d0

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

module ReverseAdoc
  module Converters
    def self.register(tag_name, converter)
      @@converters ||= {}
      @@converters[tag_name.to_sym] = converter
    end

    def self.unregister(tag_name)
      @@converters.delete(tag_name.to_sym)
    end

    def self.lookup(tag_name)
      @@converters[tag_name.to_sym] or default_converter(tag_name)
    end

    def self.default_converter(tag_name)
      case ReverseAdoc.config.unknown_tags.to_sym
      when :pass_through
        ReverseAdoc::Converters::PassThrough.new
      when :drop
        ReverseAdoc::Converters::Drop.new
      when :bypass
        ReverseAdoc::Converters::Bypass.new
      when :raise
        raise UnknownTagError, "unknown tag: #{tag_name}"
      else
        raise InvalidConfigurationError,
              "unknown value #{ReverseAdoc.config.unknown_tags.inspect} for ReverseAdoc.config.unknown_tags"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reverse_adoc-1.0.1 lib/reverse_adoc/converters.rb
reverse_adoc-1.0.0 lib/reverse_adoc/converters.rb