1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Show method docs for Foo() and class docs for Foo

This commit is contained in:
Danielle Sucher 2013-09-06 14:58:12 -07:00
parent a67bf8b3b8
commit 858f7d3b88
2 changed files with 10 additions and 4 deletions

View file

@ -119,10 +119,10 @@ class Pry
return nil if str.to_s.empty? return nil if str.to_s.empty?
obj = case str obj = case str
when /::(?:\S+)\Z/ when /\S+\(\)\z/
Pry::WrappedModule.from_str(str,target) || Pry::Method.from_str(str, target) Pry::Method.from_str(str.sub(/\(\)\z/, ''),target) || Pry::WrappedModule.from_str(str, target)
else else
Pry::Method.from_str(str,target) || Pry::WrappedModule.from_str(str, target) Pry::WrappedModule.from_str(str,target) || Pry::Method.from_str(str, target)
end end
lookup_super(obj, super_level) lookup_super(obj, super_level)

View file

@ -244,8 +244,14 @@ describe Pry::CodeObject do
Object.remove_method(:ClassyWassy) Object.remove_method(:ClassyWassy)
end end
it 'should look up methods before classes (at top-level)' do it 'should look up classes before methods (at top-level)' do
m = Pry::CodeObject.lookup("ClassyWassy", @p) m = Pry::CodeObject.lookup("ClassyWassy", @p)
m.is_a?(Pry::WrappedModule).should == true
m.source.should =~ /piggy/
end
it 'should look up methods before classes when ending in () (at top-level)' do
m = Pry::CodeObject.lookup("ClassyWassy()", @p)
m.is_a?(Pry::Method).should == true m.is_a?(Pry::Method).should == true
m.source.should =~ /ducky/ m.source.should =~ /ducky/
end end