Class: Byebug::EditCommand
Overview
Edit a file from byebug’s prompt.
Instance Attribute Summary
Attributes inherited from Command
#processor
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
#arguments, columnize, #context, #frame, help, #initialize, match, to_s
#camelize, #prettify
Class Method Details
.description ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/byebug/commands/edit.rb', line 15
def self.description
<<-EOD
edit[ file:lineno]
#{short_description}
With no argumnt, edits file containing most re line listed. Editing
targets can also be specified to start editing at a specific line in a
specific file
EOD
end
|
.regexp ⇒ Object
11
12
13
|
# File 'lib/byebug/commands/edit.rb', line 11
def self.regexp
/^\s* ed(?:it)? (?:\s+(\S+))? \s*$/x
end
|
.short_description ⇒ Object
27
28
29
|
# File 'lib/byebug/commands/edit.rb', line 27
def self.short_description
'Edits source files'
end
|
Instance Method Details
#execute ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/byebug/commands/edit.rb', line 31
def execute
file, line = location(@match[1])
return edit_error('not_exist', file) unless File.exist?(file)
return edit_error('not_readable', file) unless File.readable?(file)
cmd = line ? "#{editor} +#{line} #{file}" : "#{editor} #{file}"
system(cmd)
end
|