Class: Byebug::SaveCommand
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match
Class Method Details
.description ⇒ Object
72
73
74
75
76
77
78
79
|
# File 'lib/byebug/commands/save.rb', line 72
def description
%{save[ FILE]
Saves current byebug state to FILE as a script file. This includes
breakpoints, catchpoints, display expressions and some settings. If
no filename is given, we will fabricate one.
Use the "source" command in another debug session to restore them.}
end
|
.names ⇒ Object
68
69
70
|
# File 'lib/byebug/commands/save.rb', line 68
def names
%w(save)
end
|
Instance Method Details
#execute ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/byebug/commands/save.rb', line 50
def execute
if not @match[1]
file = open_save()
else
file = open(@match[1], 'w')
end
save_breakpoints(file)
save_catchpoints(file)
save_displays(file)
save_settings(file)
print "Saved to '#{file.path}'\n"
if @state and @state.interface
@state.interface.restart_file = file.path
end
file.close
end
|
#regexp ⇒ Object
46
47
48
|
# File 'lib/byebug/commands/save.rb', line 46
def regexp
/^\s* sa(?:ve)? (?:\s+(\S+))? \s*$/x
end
|
#save_breakpoints(file) ⇒ Object
19
20
21
22
23
|
# File 'lib/byebug/commands/save.rb', line 19
def save_breakpoints(file)
Byebug.breakpoints.each do |b|
file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}"
end
end
|
#save_catchpoints(file) ⇒ Object
25
26
27
28
29
|
# File 'lib/byebug/commands/save.rb', line 25
def save_catchpoints(file)
Byebug.catchpoints.keys.each do |c|
file.puts "catch #{c}"
end
end
|
#save_displays(file) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/byebug/commands/save.rb', line 31
def save_displays(file)
for d in @state.display
if d[0]
file.puts "display #{d[1]}"
end
end
end
|
#save_settings(file) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/byebug/commands/save.rb', line 39
def save_settings(file)
%w(autoeval autoirb autolist basename testing).each do |setting|
file.puts "set #{setting} #{Setting[setting.to_sym]}"
end
end
|