[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

a simple patch for the ri utility

Daniel Choi

6/12/2008 6:35:00 PM

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

Thanks,

Dan
Cambridge, MA
Betahouse coworking space
12 Answers

Ryan Davis

6/12/2008 10:17:00 PM

0


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

6/13/2008 1:21:00 AM

0


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

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

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

6/13/2008 9:07:00 AM

0

On Thu, Jun 12, 2008 at 8:39 PM, Daniel Choi <dhchoi@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-enh...

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

6/13/2008 1:26:00 PM

0

On Jun 12, 6:16 pm, Ryan Davis <ryand-r...@zenspider.com> 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 Hodel.

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

Daniel Choi

6/13/2008 1:26:00 PM

0

On Jun 12, 9:21 pm, lists <li...@kalama.no-ip.org> wrote:
> On Jun 12, 2008, at 5:16 PM, Ryan Davis 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 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.


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

Daniel Choi

6/13/2008 1:30:00 PM

0

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

Daniel Choi

6/13/2008 4:53:00 PM

0

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

for details.

Cheers,

Dan

Leslie Viljoen

6/13/2008 7:43:00 PM

0

On Fri, Jun 13, 2008 at 6:54 PM, Daniel Choi <dhchoi@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-enh...
>

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

Les

Eric Hodel

6/13/2008 9:46:00 PM

0

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

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/pro... for the repository.



Daniel Choi

6/13/2008 11:20:00 PM

0


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