mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Refactor edit-command to take advantage of Pry::Method#source.
This commit is contained in:
parent
5679b6fa31
commit
4fc1c97489
1 changed files with 13 additions and 11 deletions
|
@ -94,24 +94,26 @@ class Pry
|
|||
end
|
||||
|
||||
def edit_temporarily
|
||||
source_code = @command.block.source
|
||||
source_code = Pry::Method(block).source
|
||||
modified_code = nil
|
||||
|
||||
temp_file :unlink => false do |f|
|
||||
temp_file do |f|
|
||||
f.write(source_code)
|
||||
f.flush
|
||||
|
||||
invoke_editor(f.path, 1)
|
||||
modified_code = File.read(f.path)
|
||||
|
||||
command_set = CommandSet.new do
|
||||
silence_warnings do
|
||||
eval(modified_code, binding, f.path, 1)
|
||||
end
|
||||
end
|
||||
|
||||
@pry.commands.delete(@command.name)
|
||||
@pry.commands.import(command_set)
|
||||
end
|
||||
|
||||
command_set = CommandSet.new do
|
||||
silence_warnings do
|
||||
pry = Pry.new :input => StringIO.new(modified_code)
|
||||
pry.rep(binding)
|
||||
end
|
||||
end
|
||||
|
||||
@pry.commands.delete(@command.name)
|
||||
@pry.commands.import(command_set)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue