Module: PryDebugger

Extended by:
PryDebugger
Included in:
PryDebugger
Defined in:
lib/pry-debugger/base.rb,
lib/pry-debugger/version.rb,
lib/pry-debugger/commands.rb,
lib/pry-debugger/processor.rb

Defined Under Namespace

Classes: Processor

Constant Summary collapse

TRACE_IGNORE_FILES =
Dir[File.join(File.dirname(__FILE__), '..', '**', '*.rb')].map { |f| File.expand_path(f) }
VERSION =
'0.1.0'
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 PryDebugger.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 processor.


14
15
16
# File 'lib/pry-debugger/base.rb', line 14

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


8
9
10
11
# File 'lib/pry-debugger/base.rb', line 8

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