Class: Byebug::SourceCommand

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

Overview

Implements byebug “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, #print_subcmds, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.help(cmd) ⇒ Object



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

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

.help_commandObject



24
25
26
# File 'lib/byebug/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/byebug/commands/source.rb', line 10

def execute
  file = File.expand_path(@match[1]).strip
  unless File.exist?(file)
    errmsg "Command file '#{file}' is not found\n"
    return
  end
  if @state and @state.interface
    @state.interface.command_queue += File.open(file).readlines
  else
    Byebug.run_script(file, @state)
  end
end

#regexpObject



6
7
8
# File 'lib/byebug/commands/source.rb', line 6

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