[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

[ANN] Help 0.1: access ri from irb (using the ri library

Ilmari Heikkinen

12/22/2004 6:14:00 AM

Bit the bullet and finished this little straggler.
If you find bugs, let me know (refactorings also welcome.)
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-... is
similar but bound by ri's
default behaviour. Which this one overrides by doing lookups in
ancestors and
instance/class methods. Maybe ri should work like this one does (or
vice versa)?


-Ilmari
========

Download:
http://fhtr.org/co...

Requirements:
Ri in working order. Works in 1.8.2 at least.

========

# Ri bindings for interactive use from within Ruby.
# Does a bit of second-guessing (Instance method? Class method? Try both
# unless explicitly defined.)
# Goal is getting obj.methods.find_all{|m| not obj.help_yaml(m)} empty.
#
# require 'help'
#
# a = "string"
# a.help
# a.help :reverse
# a.help :map
# String.help
# String.help :new
# String.help :reverse
# String.help :map
# String.instance_help :reverse
# String.instance_help :new # => No help found.
# a.help :new
# help "String#reverse"
# help "String.reverse"
# a.method(:reverse).help # gets help for Method
#
#
# 10 points and a duck drawing for the person who makes the Ri database
# word/regexp/fuzzy/synonym-searchable and integrates this with that.
# Maybe something like this:
# search_help("file open|close")
# => ['IO.open', 'IO.close']
# NOTE: There is NO search_help. Yet. Write it. ]^|
#
#
# License: Ruby's
# Author: Ilmari Heikkinen <kig misfiring net>
# Date: 2004-12-22



5 Answers

Piergiuliano Bossi

12/22/2004 4:43:00 PM

0

Newbee question: where should I put help.rb?

I have put it in C:\Apps\ruby18\lib\ruby\1.8 (where C:\Apps\ruby18 is
ruby home) and it works, but I wonder what other people do, especially
considering future upgrade.

Btw, nice job! :-)

Ciao, Giuliano

Ilmari Heikkinen wrote:
> Bit the bullet and finished this little straggler.
> If you find bugs, let me know (refactorings also welcome.)
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-... is
> similar but bound by ri's
> default behaviour. Which this one overrides by doing lookups in
> ancestors and
> instance/class methods. Maybe ri should work like this one does (or vice
> versa)?
>
>
> -Ilmari
> ========
>
> Download:
> http://fhtr.org/co...
>
> Requirements:
> Ri in working order. Works in 1.8.2 at least.
>
> ========
>
> # Ri bindings for interactive use from within Ruby.
> # Does a bit of second-guessing (Instance method? Class method? Try both
> # unless explicitly defined.)
> # Goal is getting obj.methods.find_all{|m| not obj.help_yaml(m)} empty.
> #
> # require 'help'
> #
> # a = "string"
> # a.help
> # a.help :reverse
> # a.help :map
> # String.help
> # String.help :new
> # String.help :reverse
> # String.help :map
> # String.instance_help :reverse
> # String.instance_help :new # => No help found.
> # a.help :new
> # help "String#reverse"
> # help "String.reverse"
> # a.method(:reverse).help # gets help for Method
> #
> #
> # 10 points and a duck drawing for the person who makes the Ri database
> # word/regexp/fuzzy/synonym-searchable and integrates this with that.
> # Maybe something like this:
> # search_help("file open|close")
> # => ['IO.open', 'IO.close']
> # NOTE: There is NO search_help. Yet. Write it. ]^|
> #
> #
> # License: Ruby's
> # Author: Ilmari Heikkinen <kig misfiring net>
> # Date: 2004-12-22
>
>
>

--
If you want to send me an email address should be 'p', then a dot,
followed by 'bossi' at 'quinary', another dot and 'com' at last

gabriele renzi

12/22/2004 8:48:00 PM

0

Piergiuliano Bossi ha scritto:
> Newbee question: where should I put help.rb?
>
> I have put it in C:\Apps\ruby18\lib\ruby\1.8 (where C:\Apps\ruby18 is
> ruby home) and it works, but I wonder what other people do, especially
> considering future upgrade.
>
> Btw, nice job! :-)
>
> Ciao, Giuliano
>

I'd say lib/site_ruby/1.8/ would be better, lib/1.8/ should contain just
the stuff bundled with ruby. And don't forget to add "require 'help'" to
your .irbrc ;)

ralobao

12/22/2004 9:30:00 PM

0


Ilmari Heikkinen wrote:
> Bit the bullet and finished this little straggler.
> If you find bugs, let me know (refactorings also welcome.)
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-... is
> similar but bound by ri's
> default behaviour. Which this one overrides by doing lookups in
> ancestors and
> instance/class methods. Maybe ri should work like this one does (or
> vice versa)?
>
>
> -Ilmari
> ========
>
> Download:
> http://fhtr.org/co...
>
> Requirements:
> Ri in working order. Works in 1.8.2 at least.
>
> ========
>
> # Ri bindings for interactive use from within Ruby.
> # Does a bit of second-guessing (Instance method? Class method? Try
both
> # unless explicitly defined.)
> # Goal is getting obj.methods.find_all{|m| not obj.help_yaml(m)}
empty.
> #
> # require 'help'
> #
> # a = "string"
> # a.help
> # a.help :reverse
> # a.help :map
> # String.help
> # String.help :new
> # String.help :reverse
> # String.help :map
> # String.instance_help :reverse
> # String.instance_help :new # => No help found.
> # a.help :new
> # help "String#reverse"
> # help "String.reverse"
> # a.method(:reverse).help # gets help for Method
> #
> #
> # 10 points and a duck drawing for the person who makes the Ri
database
> # word/regexp/fuzzy/synonym-searchable and integrates this with that.
> # Maybe something like this:
> # search_help("file open|close")
> # => ['IO.open', 'IO.close']
> # NOTE: There is NO search_help. Yet. Write it. ]^|
> #
> #
> # License: Ruby's
> # Author: Ilmari Heikkinen <kig misfiring net>
> # Date: 2004-12-22

Piergiuliano Bossi

12/23/2004 10:00:00 AM

0

gabriele renzi wrote:
> Piergiuliano Bossi ha scritto:
>
>> Newbee question: where should I put help.rb?
>>
>> I have put it in C:\Apps\ruby18\lib\ruby\1.8 (where C:\Apps\ruby18 is
>> ruby home) and it works, but I wonder what other people do, especially
>> considering future upgrade.
>>
>> Btw, nice job! :-)
>>
>> Ciao, Giuliano
>>
>
> I'd say lib/site_ruby/1.8/ would be better, lib/1.8/ should contain just
> the stuff bundled with ruby.

Oh yes.

> And don't forget to add "require 'help'" to
> your .irbrc ;)

And it's much faster this way, thx a lot.

Ciao, Giuliano

--
If you want to send me an email address should be 'p', then a dot,
followed by 'bossi' at 'quinary', another dot and 'com' at last

Ilmari Heikkinen

12/23/2004 12:05:00 PM

0


On 22.12.2004, at 18:47, Piergiuliano Bossi wrote:

> Newbee question: where should I put help.rb?

Somewhere in your $LOAD_PATH, one of the site_ruby -ones there would be
the standard place. My fault, sorry about the lack of installer.

If you want to load it automatically in irb, add require 'help' in
irbrc (don't know what it is in windows, sorry :I), and if that seems
to make irb startup take too long, one hack is to change it to
Thread.new{ require 'help' } (just beware that using #help fails when
the lib is still loading)


> I have put it in C:\Apps\ruby18\lib\ruby\1.8 (where C:\Apps\ruby18 is
> ruby home) and it works, but I wonder what other people do, especially
> considering future upgrade.

What I do is keep a code/-dir with all the little tidbits of code, and
have it in my RUBYLIB env variable (again, don't know about windows.)

> Btw, nice job! :-)

Thanks! :-)