Class: Byebug::SaveCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/save.rb

Overview

Save current settings to use them in another debug session.

Instance Attribute Summary

Attributes inherited from Command

#processor

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#arguments, columnize, #context, #frame, help, #initialize, match, to_s

Methods included from Helpers::StringHelper

#camelize, #deindent, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/byebug/commands/save.rb', line 17

def self.description
  <<-DESCRIPTION
    save[ FILE]

    #{short_description}

    Byebug state is saved as a script file. This includes breakpoints,
    catchpoints, display expressions and some settings. If no filename is
    given, byebug will fabricate one.

    Use the "source" command in another debug session to restore the saved
    file.
  DESCRIPTION
end

.regexpObject



13
14
15
# File 'lib/byebug/commands/save.rb', line 13

def self.regexp
  /^\s* sa(?:ve)? (?:\s+(\S+))? \s*$/x
end

.short_descriptionObject



32
33
34
# File 'lib/byebug/commands/save.rb', line 32

def self.short_description
  "Saves current byebug session to a file"
end

Instance Method Details

#executeObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/byebug/commands/save.rb', line 36

def execute
  file = File.open(@match[1] || Setting[:savefile], "w")

  save_breakpoints(file)
  save_catchpoints(file)
  save_displays(file)
  save_settings(file)

  print pr("save.messages.done", path: file.path)
  file.close
end