Class: Byebug::IRBCommand
Overview
Implements byebug’s “irb” command.
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, #print_subcmds, register_setting_get, register_setting_set, register_setting_var, settings, settings_map
Class Method Details
.help(cmd) ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/byebug/commands/irb.rb', line 110
def help(cmd)
%{
irb [-d]\tstarts an Interactive Ruby (IRB) session.
If -d is added you can get access to byebug's state via the global variable
$byebug_state.
irb is extended with methods "cont", "n" and "step" which
run the corresponding byebug commands. In contrast to the real byebug
commands these commands don't allow command arguments.
}
end
|
.help_command ⇒ Object
106
107
108
|
# File 'lib/byebug/commands/irb.rb', line 106
def help_command
'irb'
end
|
Instance Method Details
#execute ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/byebug/commands/irb.rb', line 67
def execute
unless @state.interface.kind_of?(LocalInterface)
print "Command is available only in local mode.\n"
throw :debug_error
end
save_trap = trap("SIGINT") do
throw :IRB_EXIT, :cont if $byebug_in_irb
end
add_debugging = @match.is_a?(MatchData) && '-d' == @match[1]
$byebug_state = @state if add_debugging
$byebug_in_irb = true
cont = IRB.start_session(get_binding)
case cont
when :cont
@state.proceed
when :step
force = Command.settings[:force_stepping]
@state.context.step 1, force
@state.proceed
when :next
force = Command.settings[:force_stepping]
@state.context.step_over 1, @state.frame_pos, force
@state.proceed
else
file = @state.context.frame_file(0)
line = @state.context.frame_line(0)
CommandProcessor.print_location_and_text(file, line)
@state.previous_line = nil
end
ensure
$byebug_in_irb = nil
$byebug_state = nil if add_debugging
trap("SIGINT", save_trap) if save_trap
end
|
#regexp ⇒ Object
61
62
63
64
65
|
# File 'lib/byebug/commands/irb.rb', line 61
def regexp
/^\s* irb
(?:\s+(-d))?
\s*$/x
end
|