a simple patch for the ri utility

R

Ryan Davis

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.
 
L

lists

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

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

Leslie Viljoen

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
 
D

Daniel Choi

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

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

Daniel Choi

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.
 
D

Daniel Choi

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:

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
 
E

Eric Hodel

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.
 
D

Daniel Choi

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
 
D

Daniel Choi

Dana said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,666
Latest member
selsetu

Latest Threads

Top