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.
Direct Known Subclasses
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_end ⇒ Object
Called when the debugger wants to stop right before the end of a class definition.
-
#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
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/byebug/processors/pry_processor.rb', line 88 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_end ⇒ Object
Called when the debugger wants to stop right before the end of a class definition
79 80 81 |
# File 'lib/byebug/processors/pry_processor.rb', line 79 def at_end resume_pry 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 |