Class: Byebug::PryProcessor
- Inherits:
-
CommandProcessor
- Object
- CommandProcessor
- Byebug::PryProcessor
- Extended by:
- Forwardable
- Defined in:
- lib/byebug/processors/pry_processor.rb
Overview
Extends raw byebug’s processor.
Instance Attribute Summary collapse
-
#pry ⇒ Object
Returns the value of attribute pry.
Class Method Summary collapse
Instance Method Summary collapse
-
#at_breakpoint(breakpoint) ⇒ Object
Called when a breakpoint is hit.
-
#at_line ⇒ Object
Called when the debugger wants to stop at a regular line.
-
#at_return(_return_value) ⇒ Object
Called when the debugger wants to stop right before a method return.
-
#perform(action, options = {}) ⇒ Object
Set up a number of navigational commands to be performed by Byebug.
-
#run(&_block) ⇒ Object
Wrap a Pry REPL to catch navigational commands and act on them.
Instance Attribute Details
#pry ⇒ Object
Returns the value of attribute pry.
10 11 12 |
# File 'lib/byebug/processors/pry_processor.rb', line 10 def pry @pry end |
Class Method Details
Instance Method Details
#at_breakpoint(breakpoint) ⇒ Object
Called when a breakpoint is hit. Note that ‘at_line“ is called inmediately after with the context’s ‘stop_reason == :breakpoint`, so we must not resume the pry instance here
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/byebug/processors/pry_processor.rb', line 80 def at_breakpoint(breakpoint) @pry ||= Pry.new output.puts bold("\n Breakpoint #{breakpoint.id}. ") + n_hits(breakpoint) expr = breakpoint.expr return unless expr output.puts bold("Condition: ") + expr end |
#at_line ⇒ Object
Called when the debugger wants to stop at a regular line
64 65 66 |
# File 'lib/byebug/processors/pry_processor.rb', line 64 def at_line resume_pry end |
#at_return(_return_value) ⇒ Object
Called when the debugger wants to stop right before a method return
71 72 73 |
# File 'lib/byebug/processors/pry_processor.rb', line 71 def at_return(_return_value) resume_pry end |
#perform(action, options = {}) ⇒ Object
Set up a number of navigational commands to be performed by Byebug.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/byebug/processors/pry_processor.rb', line 45 def perform(action, = {}) return unless %i[ backtrace down finish frame next step up ].include?(action) send("perform_#{action}", ) end |
#run(&_block) ⇒ Object
Wrap a Pry REPL to catch navigational commands and act on them.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/byebug/processors/pry_processor.rb', line 26 def run(&_block) return_value = nil command = catch(:breakout_nav) do # Throws from PryByebug::Commands return_value = allowing_other_threads { yield } {} # Nothing thrown == no navigational command end # Pry instance to resume after stepping @pry = command[:pry] perform(command[:action], command[:options]) return_value end |