Sha256: 4e3a77880ae7071394dba283d6a33a71f6c3798d9226c7ac4b9fa49869485cf2

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

module PageEz
  module Visitors
    class DebugVisitor
      def initialize
        reset
      end

      def begin_block_evaluation
        @depth_visitor.begin_block_evaluation
      end

      def end_block_evaluation
        @depth_visitor.end_block_evaluation
      end

      def define_method(name)
        @depth_visitor.define_method(name)
        debug("* #{name}")
      end

      def inherit_from(subclass)
        @depth_visitor.inherit_from(subclass)
        debug("Declaring page object: #{subclass.name || "{anonymous page object}"}")
      end

      def track_method_added(name, construction_strategy)
        @depth_visitor.track_method_added(name, construction_strategy)
      end

      def track_method_undefined(name)
        @depth_visitor.track_method_undefined(name)
      end

      def track_method_renamed(from, to)
        @depth_visitor.track_method_renamed(from, to)
      end

      def track_method_delegated(name)
        @depth_visitor.track_method_delegated(name)
        debug("* #{name} (delegated)")
      end

      def process_macro(macro, name, construction_strategy)
        @depth_visitor.process_macro(macro, name, construction_strategy)
        debug("#{macro} :#{name}, \"#{construction_strategy.selector}\"")
      end

      def reset
        @depth_visitor = DepthVisitor.new
      end

      private

      def debug(message)
        PageEz.configuration.logger.debug("#{"  " * @depth_visitor.depth}#{message}")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page_ez-0.2.0 lib/page_ez/visitors/debug_visitor.rb
page_ez-0.1.0 lib/page_ez/visitors/debug_visitor.rb