Sha256: e62f92267713d553c0e4b9403584808606a355274ede893981978516d1e5e889

Contents?: true

Size: 1.47 KB

Versions: 43

Compression:

Stored size: 1.47 KB

Contents

require "rd/rdvisitor"
require "rd/version"

require 'rabbit/rabbit'

module Rabbit
  module Parser
    class RD
      class Visitor < ::RD::RDVisitor
        include ::RD::MethodParse

        class << self
          def version
            self.class::VERSION
          end
        end

        def initialize
          init_extensions
          super
        end

        private
        def init_extensions
          @installed_extensions = {}
          self.class::EXTENSIONS.each do |name, klass|
            @installed_extensions[name] =  klass.new
          end
        end

        def apply_to_extension(ext_type, label, source, content)
          result = nil
          unless @installed_extensions.has_key?(ext_type)
            fatal_on_extension_not_available(label, ext_type)
          end
          args = [label, source, content, self]
          extension = @installed_extensions[ext_type]
          result = extension.apply(*args)
          default_method_name = "default_ext_#{ext_type}"
          if result.nil? and
              extension.respond_to?(default_method_name, true)
            result = extension.__send__(default_method_name, *args)
          end
          fatal_on_extension_not_available(label, ext_type) if result.nil?
          result
        end

        def fatal_on_extension_not_available(label, type)
          message = _("[BUG] [%s] %s extension isn't available.")
          logger.fatal(message % [label, ext_type])
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
rabbit-3.0.3 lib/rabbit/parser/rd/visitor.rb
rabbit-3.0.2 lib/rabbit/parser/rd/visitor.rb
rabbit-3.0.1 lib/rabbit/parser/rd/visitor.rb
rabbit-3.0.0 lib/rabbit/parser/rd/visitor.rb
rabbit-2.2.1 lib/rabbit/parser/rd/visitor.rb
rabbit-2.2.0 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.9 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.8 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.7 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.6 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.5 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.4 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.3 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.2 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.1 lib/rabbit/parser/rd/visitor.rb
rabbit-2.1.0 lib/rabbit/parser/rd/visitor.rb
rabbit-2.0.9 lib/rabbit/parser/rd/visitor.rb
rabbit-2.0.8 lib/rabbit/parser/rd/visitor.rb
rabbit-2.0.7 lib/rabbit/parser/rd/visitor.rb
rabbit-2.0.6 lib/rabbit/parser/rd/visitor.rb