Class: Byebug::CommandProcessor
- Inherits:
-
Object
- Object
- Byebug::CommandProcessor
- Extended by:
- Forwardable
- Includes:
- Helpers::EvalHelper
- Defined in:
- lib/byebug/processors/command_processor.rb
Overview
Processes commands in regular mode.
You can override this class to create your own command processor that, for example, whitelists only certain commands to be executed.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#prev_line ⇒ Object
Returns the value of attribute prev_line.
Instance Method Summary collapse
- #at_breakpoint(brkpt) ⇒ Object
- #at_catchpoint(exception) ⇒ Object
- #at_end ⇒ Object
- #at_line ⇒ Object
- #at_return(return_value) ⇒ Object
- #at_tracing ⇒ Object
-
#command_list ⇒ Object
Available commands.
-
#initialize(context) ⇒ CommandProcessor
constructor
A new instance of CommandProcessor.
- #interface ⇒ Object
- #printer ⇒ Object
-
#proceed! ⇒ Object
Let the execution continue.
-
#process_commands ⇒ Object
Handle byebug commands.
Methods included from Helpers::EvalHelper
#error_eval, #silent_eval, #single_thread_eval, #thread_safe_eval, #warning_eval
Constructor Details
#initialize(context) ⇒ CommandProcessor
Returns a new instance of CommandProcessor.
21 22 23 24 25 26 |
# File 'lib/byebug/processors/command_processor.rb', line 21 def initialize(context) @context = context @proceed = false @prev_line = nil end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
19 20 21 |
# File 'lib/byebug/processors/command_processor.rb', line 19 def context @context end |
#prev_line ⇒ Object
Returns the value of attribute prev_line.
18 19 20 |
# File 'lib/byebug/processors/command_processor.rb', line 18 def prev_line @prev_line end |
Instance Method Details
#at_breakpoint(brkpt) ⇒ Object
65 66 67 68 69 |
# File 'lib/byebug/processors/command_processor.rb', line 65 def at_breakpoint(brkpt) number = Byebug.breakpoints.index(brkpt) + 1 puts "Stopped by breakpoint #{number} at #{frame.file}:#{frame.line}" end |
#at_catchpoint(exception) ⇒ Object
71 72 73 |
# File 'lib/byebug/processors/command_processor.rb', line 71 def at_catchpoint(exception) puts "Catchpoint at #{context.location}: `#{exception}'" end |
#at_end ⇒ Object
81 82 83 |
# File 'lib/byebug/processors/command_processor.rb', line 81 def at_end process_commands end |
#at_line ⇒ Object
55 56 57 |
# File 'lib/byebug/processors/command_processor.rb', line 55 def at_line process_commands end |
#at_return(return_value) ⇒ Object
75 76 77 78 79 |
# File 'lib/byebug/processors/command_processor.rb', line 75 def at_return(return_value) puts "Return value is: #{safe_inspect(return_value)}" process_commands end |
#at_tracing ⇒ Object
59 60 61 62 63 |
# File 'lib/byebug/processors/command_processor.rb', line 59 def at_tracing puts "Tracing: #{context.full_location}" run_auto_cmds(2) end |
#command_list ⇒ Object
Available commands
51 52 53 |
# File 'lib/byebug/processors/command_processor.rb', line 51 def command_list @command_list ||= CommandList.new(commands) end |
#interface ⇒ Object
28 29 30 |
# File 'lib/byebug/processors/command_processor.rb', line 28 def interface @interface ||= Context.interface end |
#printer ⇒ Object
32 33 34 |
# File 'lib/byebug/processors/command_processor.rb', line 32 def printer @printer ||= Printers::Plain.new end |
#proceed! ⇒ Object
Let the execution continue
88 89 90 |
# File 'lib/byebug/processors/command_processor.rb', line 88 def proceed! @proceed = true end |
#process_commands ⇒ Object
Handle byebug commands.
95 96 97 98 99 100 101 |
# File 'lib/byebug/processors/command_processor.rb', line 95 def process_commands before_repl repl ensure after_repl end |