Class: Debugger::SourceCommand

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

Overview

Implements debugger “source” command.

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



28
29
30
31
32
# File 'lib/ruby-debug/commands/source.rb', line 28

def help(cmd)
  %{
    source FILE\texecutes a file containing debugger commands
  }
end

.help_commandObject



24
25
26
# File 'lib/ruby-debug/commands/source.rb', line 24

def help_command
  'source'
end

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby-debug/commands/source.rb', line 10

def execute
  file = File.expand_path(@match[1]).strip
  unless File.exist?(file)
    errmsg pr("source.errors.not_found", file: file)
    return
  end
  if @state and @state.interface
    @state.interface.command_queue += File.open(file).readlines
  else
    Debugger.run_script(file, @state)
  end
end

#regexpObject



6
7
8
# File 'lib/ruby-debug/commands/source.rb', line 6

def regexp
  /^\s* so(?:urce)? \s+ (.+) $/x
end