Support %cat checking $LOAD_PATH directories.

This commit is contained in:
Shannon Skipper 2013-11-11 22:54:31 -08:00
parent f72ff1ab88
commit 46c5e800ce
2 changed files with 8 additions and 0 deletions

View File

@ -124,6 +124,9 @@ class Pry
abs_path = [File.expand_path(filename, Dir.pwd),
File.expand_path(filename, Pry::INITIAL_PWD)
].detect { |path| File.readable?(path) }
abs_path ||= $LOAD_PATH.map do |path|
File.expand_path(File.basename(filename), path)
end.detect { |path| File.readable?(path) if path }
abs_path or raise MethodSource::SourceNotFoundError,
"Cannot open #{filename.inspect} for reading."
end

View File

@ -46,6 +46,11 @@ describe Pry::Code do
Pry::Code.from_file(File.basename(__FILE__)).code_type.should == :ruby
end
end
should 'find files that are relative to a directory in the $LOAD_PATH' do
$LOAD_PATH << 'spec'
Pry::Code.from_file(File.basename(__FILE__)).code_type.should == :ruby
end
end
describe '.from_method' do