On Jun 13, 5:07 am, Leslie Viljoen <leslievilj... / gmail.com> wrote:
> On Thu, Jun 12, 2008 at 8:39 PM,DanielChoi<dhc... / gmail.com> wrote:
> > Hi everyone
>
> > I wrote a simple patch for the ri Ruby documentation viewer that makes
> > to easier to look up ambiguous methods. Please check it out and send
> > or post me feedback.
>
> > Here's the link:
>
> >http://danielchoi.com/software/ri-enhanced.html
>
> I had that ambiguous lookup problem yesterday!
> This is great.
>
> Here's a patch for your patch that (hopefully always) shows the version
> of the gem which holds the method:
>
> entries.each_with_index do |m, i|
>   version = m.path_name.split(File::SEPARATOR)[7]
>   STDOUT.puts "%2d %s (%s)" % [i+1, m.full_name, version]
> end
>
> Now can you make it work with qri?
>
> Les

Thanks for the suggestion!

I tried your patch and it work right for me, I think because the Ruby
file paths are different on OS X than on your system.

I got the following output:

spartan:~ choi$ ri find
More than one method matched your request. Type the number
of the method you want, or press Return to cancel:

 1 Enumerable#find (usr)
 2 Find#find (usr)
 3 IRB::Locale#find (usr)
 4 Pathname#find (usr)
 5 Rinda::TupleBag#find (usr)
 6 XML::Document#find (usr)
 7 XML::Node#find (usr)
 8 XML::XPath::find (usr)
 9 ActiveRecord::Base::find (usr)
10 ActiveRecord::Base::find (ri)
11 ActiveRecord::Base::find (ri)
12 ActiveSupport::Callbacks::CallbackChain#find (ri)
13 Daemons::Monitor::find (usr)
14 Daemons::Monitor::find (usr)
15 Daemons::Monitor::find (ri)
16 Gem::GemPathSearcher#find (usr)
17 ActiveResource::Base::find (ri)
18 Spec::Story::StepGroup#find (ri)
19 Spec::Story::StepMother#find (ri)
20 EnumerablePass#find (ri)
21 PathList::Finder#find (ri)


So I changed your patch a little to this:

        entries.each_with_index do |m, i|
          # Assume that a gem version is always formatted like 2.0.2
          match_data = /-(\d+\.\d+\.\d+)/.match(m.path_name)
          version_string = match_data ? " (#{match_data[1]})" : nil
          STDOUT.puts "%2d %s%s" % [i+1, m.full_name, version_string]
        end

Now the output is right:

spartan:~ choi$ ri find
More than one method matched your request. Type the number
of the method you want, or press Return to cancel:

 1 Enumerable#find
 2 Find#find
 3 IRB::Locale#find
 4 Pathname#find
 5 Rinda::TupleBag#find
 6 XML::Document#find (0.3.8)
 7 XML::Node#find (0.3.8)
 8 XML::XPath::find (0.3.8)
 9 ActiveRecord::Base::find (1.15.6)
10 ActiveRecord::Base::find (2.0.2)
11 ActiveRecord::Base::find (2.1.0)
12 ActiveSupport::Callbacks::CallbackChain#find (2.1.0)
13 Daemons::Monitor::find (1.0.7)
14 Daemons::Monitor::find (1.0.9)
15 Daemons::Monitor::find (1.0.10)
16 Gem::GemPathSearcher#find (1.0.1)
17 ActiveResource::Base::find (2.0.2)
18 Spec::Story::StepGroup#find (1.1.4)
19 Spec::Story::StepMother#find (1.1.4)
20 EnumerablePass#find (2.4.1)
21 PathList::Finder#find (2.4.1)
>>

Please let me know if this works on your system too. I'm going to add
this to my patch and credit you. Thanks Les,

Dan