Class: Byebug::Edit
Constant Summary
Constants inherited
from Command
Command::DEF_OPTIONS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map
Class Method Details
.description ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/byebug/commands/edit.rb', line 37
def description
%{
edit[ file:lineno]\tEdit specified file.
With no argument, edits file containing most recent line listed.
Editing targets can also be specified to start editing at a specific
line in a specific file.
}
end
|
.names ⇒ Object
33
34
35
|
# File 'lib/byebug/commands/edit.rb', line 33
def names
%w(edit)
end
|
Instance Method Details
#execute ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/byebug/commands/edit.rb', line 10
def execute
if not @match[1]
unless @state.context
errmsg "We are not in a state that has an associated file.\n"
return
end
file = @state.file
line_number = @state.line
elsif @pos_match = /([^:]+)[:]([0-9]+)/.match(@match[1])
file, line_number = @pos_match.captures
else
errmsg "Invalid file/line number specification: #{@match[1]}\n"
return
end
editor = ENV['EDITOR'] || 'ex'
if File.readable?(file)
system("#{editor} +#{line_number} #{file}")
else
errmsg "File \"#{file}\" is not readable.\n"
end
end
|
#regexp ⇒ Object
6
7
8
|
# File 'lib/byebug/commands/edit.rb', line 6
def regexp
/^\s* ed(?:it)? (?:\s+(.*))?$/ix
end
|