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 Method Summary collapse

Methods inherited from Command

#help, #initialize, #match, subcommands, to_name

Methods included from Helpers::StringHelper

#camelize, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Instance Method Details

#descriptionObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/byebug/commands/save.rb', line 26

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

#executeObject



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

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

#regexpObject



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

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