Class: Debugger::SaveCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/commands/script.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, inherited, #initialize, load_commands, #match, method_missing, options

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



52
53
54
55
56
# File 'lib/ruby-debug/commands/script.rb', line 52

def help(cmd)
  %{
    save FILE\tsaves current breakpoints and catchpoint as a script file
  }
end

.help_commandObject



48
49
50
# File 'lib/ruby-debug/commands/script.rb', line 48

def help_command
  'save'
end

Instance Method Details

#executeObject



37
38
39
40
41
42
43
44
45
# File 'lib/ruby-debug/commands/script.rb', line 37

def execute
  open(@match[1], 'w') do |file|
    Debugger.breakpoints.each do |b|
      file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}"
    end
    file.puts "catch #{Debugger.catchpoint}" if Debugger.catchpoint
  end
  print "Saved to '#{@match[1]}'\n"
end

#regexpObject



33
34
35
# File 'lib/ruby-debug/commands/script.rb', line 33

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