mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Use temp_file instead of broken manual code
This commit is contained in:
parent
423fc48fa1
commit
e0aaef6d67
2 changed files with 8 additions and 16 deletions
|
@ -145,22 +145,19 @@ class Pry
|
|||
_pry_.input_array.reverse_each.find{ |x| x && x.strip != "" } # No present? in 1.8
|
||||
end || ""
|
||||
|
||||
file_name = temp_file do |f|
|
||||
f.puts(content)
|
||||
end
|
||||
line = content.lines.count
|
||||
|
||||
invoke_editor(file_name, line)
|
||||
|
||||
if !opts.n?
|
||||
silence_warnings do
|
||||
eval_string.replace(File.read(file_name))
|
||||
temp_file do |f|
|
||||
f.puts(content)
|
||||
f.flush
|
||||
invoke_editor(f.path, line)
|
||||
if !opts.n?
|
||||
silence_warnings do
|
||||
eval_string.replace(File.read(f.path))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# don't leak temporary files
|
||||
File.unlink(file_name)
|
||||
|
||||
# edit of remote code, eval'd at top-level
|
||||
else
|
||||
if opts.ex?
|
||||
|
|
|
@ -143,11 +143,6 @@ describe "Pry::DefaultCommands::Introspection" do
|
|||
@line.should == 2
|
||||
end
|
||||
|
||||
it "should delete the temporary file" do
|
||||
mock_pry("edit")
|
||||
File.exist?(@file).should == false
|
||||
end
|
||||
|
||||
it "should evaluate the expression" do
|
||||
Pry.config.editor = lambda {|file, line|
|
||||
File.open(file, 'w'){|f| f << "'FOO'\n" }
|
||||
|
|
Loading…
Add table
Reference in a new issue