1
0
Fork 0
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:
Rob Gleeson 2012-01-10 04:06:30 +00:00
parent 5679b6fa31
commit 4fc1c97489

View file

@ -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