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, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



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

def self.description
  <<-EOD
    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.
  EOD
end

.regexpObject



11
12
13
# File 'lib/byebug/commands/save.rb', line 11

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

.short_descriptionObject



30
31
32
# File 'lib/byebug/commands/save.rb', line 30

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

Instance Method Details

#executeObject



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

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