Don't explode if the file we're in doesn't exist.

This happens particularly in testing where you want to delete files
after each test, but the REPL state isn't reset correctly.
This commit is contained in:
Conrad Irwin 2011-09-10 12:52:05 -07:00
parent 9c8eb6139b
commit 76d1c4ff70
1 changed files with 4 additions and 0 deletions

View File

@ -147,6 +147,10 @@ class Pry
set_file_and_dir_locals(file) set_file_and_dir_locals(file)
output.puts "\n#{text.bold('From:')} #{file} @ line #{line_num} in #{klass}##{meth_name}:\n\n" output.puts "\n#{text.bold('From:')} #{file} @ line #{line_num} in #{klass}##{meth_name}:\n\n"
unless File.readable?(file)
output.puts "Cannot open #{file.inspect} for reading."
next
end
# This method inspired by http://rubygems.org/gems/ir_b # This method inspired by http://rubygems.org/gems/ir_b
File.open(file).each_with_index do |line, index| File.open(file).each_with_index do |line, index|