Module: PryNav

Extended by:
PryNav
Included in:
PryNav
Defined in:
lib/pry-nav.rb,
lib/pry-nav/tracer.rb,
lib/pry-nav/version.rb,
lib/pry-nav/commands.rb

Defined Under Namespace

Classes: Tracer

Constant Summary collapse

TRACE_IGNORE_FILES =
Dir[File.join(File.dirname(__FILE__), '**', '*.rb')].map { |f| File.expand_path(f) }
VERSION =
'0.2.2'
Commands =
Pry::CommandSet.new do
  block_command 'step', 'Step execution into the next line or method.' do |steps|
    check_file_context
    breakout_navigation :step, steps
  end

  block_command 'next', 'Execute the next line within the same stack frame.' do |lines|
    check_file_context
    breakout_navigation :next, lines
  end

  block_command 'continue', 'Continue program execution and end the Pry session.' do
    check_file_context
    run 'exit-all'
  end

  helpers do
    def breakout_navigation(action, times)
      _pry_.binding_stack.clear     # Clear the binding stack.
      throw :breakout_nav, {        # Break out of the REPL loop and
        :action => action,          #   signal the tracer.
        :times =>  times
      }
    end

    # Ensures that a command is executed in a local file context.
    def check_file_context
      unless PryNav.check_file_context(target)
        raise Pry::CommandError, 'Cannot find local context. Did you use `binding.pry`?'
      end
    end
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_remote_serverObject

Reference to currently running pry-remote server. Used by the tracer.



22
23
24
# File 'lib/pry-nav.rb', line 22

def current_remote_server
  @current_remote_server
end

Instance Method Details

#check_file_context(target) ⇒ Object

Checks that a binding is in a local file context. Extracted from github.com/pry/pry/blob/master/lib/pry/default_commands/context.rb



16
17
18
19
# File 'lib/pry-nav.rb', line 16

def check_file_context(target)
  file = target.eval('__FILE__')
  file == Pry.eval_path || (file !~ /(\(.*\))|<.*>/ && file != '' && file != '-e')
end