A simple patch for the ri utility

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

Thanks,

Dan
Cambridge, MA
Betahouse coworking space

This looks great! Thanks.

-Dana

On Jun 12, 2008, at 11:39 , Daniel C. wrote:

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.

Rad. Please file this patch on the ruby project on rubyforge,
categorize as development tools, and assign to Eric H…

On Jun 12, 2008, at 5:16 PM, Ryan D. wrote:

Yes, please do so that it can get incorporated upstream. Thanks for
putting this patch together; it’s solved a vexing problem for me.

On Jun 12, 6:16 pm, Ryan D. [email protected] wrote:

On Jun 12, 2008, at 11:39 ,DanielChoiwrote:

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.

Rad. Please file this patch on the ruby project on rubyforge,
categorize as development tools, and assign to Eric H…

Thanks, Ryan, I will file the patch today. - Dan

On Thu, Jun 12, 2008 at 8:39 PM, Daniel C. [email protected] 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

On Jun 13, 5:07 am, Leslie V. [email protected] wrote:

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

I get a bug when I try “ri enum”

Output follows:

==

dmerrick@raspberry Desktop $ ri enum
More than one method matched your request. Type the number
of the method you want, or press Return to cancel:

==

-Dana

On Jun 12, 9:21 pm, lists [email protected] wrote:

Rad. Please file this patch on the ruby project on rubyforge,
categorize as development tools, and assign to Eric H…

Yes, please do so that it can get incorporated upstream. Thanks for
putting this patch together; it’s solved a vexing problem for me.

I’m glad it’s useful. I’m filing the patch today.

Just an update. I expanded my ri patch to provide a way to browse all
the methods of a specified Ruby class in the same way.

Please see the bottom of

http://danielchoi.com/software/ri-enhanced.html

for details.

Cheers,

Dan

On Fri, Jun 13, 2008 at 6:54 PM, Daniel C. [email protected] wrote:

Just an update. I expanded my ri patch to provide a way to browse all
the methods of a specified Ruby class in the same way.

Please see the bottom of

http://danielchoi.com/software/ri-enhanced.html

Works great on my system (Ubuntu 8.04).
Thanks for the good work!

Les

On Jun 12, 2008, at 11:39 AM, Daniel C. 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 don’t see a patch there (created by diff), just a file.

RDoc 2 no longer uses those class names (and possibly not even that
code), so you would need to adapt your file to make it work.

See http://rubyforge.org/projects/rdoc for the repository.

OK thanks for tipping me off to rdoc 2.

I just changed the code to work against rdoc 2. And am submitting
patches in a few minutes.

Please let me know if I should write tests. This is my first time
submitting patches, so please feel free to tell me what to do.

Dan

I also resubmitted my patch for ri in RDoc 1 as a proper patch.

Dana M. wrote:

I get a bug when I try “ri enum”

Output follows:

==

dmerrick@raspberry Desktop $ ri enum
More than one method matched your request. Type the number
of the method you want, or press Return to cancel:

==

-Dana

I may have updated the patch since you tried this. Please try the new
patch and let me know if you get the same bug

Here’s the newer patch:

http://danielchoi.com/software/ri2.txt

Dan