Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

a simple patch for the ri utility

3 views
Skip to first unread message

Daniel Choi

unread,
Jun 12, 2008, 2:35:13 PM6/12/08
to
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

Ryan Davis

unread,
Jun 12, 2008, 6:16:55 PM6/12/08
to

On Jun 12, 2008, at 11:39 , Daniel Choi 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 Hodel.


lists

unread,
Jun 12, 2008, 9:21:12 PM6/12/08
to

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

Leslie Viljoen

unread,
Jun 13, 2008, 5:07:24 AM6/13/08
to
On Thu, Jun 12, 2008 at 8:39 PM, Daniel Choi <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

Daniel Choi

unread,
Jun 13, 2008, 9:25:38 AM6/13/08
to

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

Daniel Choi

unread,
Jun 13, 2008, 9:26:12 AM6/13/08
to


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

Daniel Choi

unread,
Jun 13, 2008, 9:29:53 AM6/13/08
to
On Jun 13, 5:07 am, Leslie Viljoen <leslievilj...@gmail.com> wrote:

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

Daniel Choi

unread,
Jun 13, 2008, 12:53:25 PM6/13/08
to
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

Leslie Viljoen

unread,
Jun 13, 2008, 3:43:25 PM6/13/08
to
On Fri, Jun 13, 2008 at 6:54 PM, Daniel Choi <dhc...@gmail.com> 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

Eric Hodel

unread,
Jun 13, 2008, 5:46:22 PM6/13/08
to
On Jun 12, 2008, at 11:39 AM, Daniel Choi 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.

Daniel Choi

unread,
Jun 13, 2008, 7:20:03 PM6/13/08
to

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

Daniel Choi

unread,
Jun 13, 2008, 7:38:55 PM6/13/08
to
I also resubmitted my patch for ri in RDoc 1 as a proper patch.

Daniel Choi

unread,
Jun 14, 2008, 5:54:13 PM6/14/08
to
Dana Merrick 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

--
Posted via http://www.ruby-forum.com/.

0 new messages