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

I

Ilmari Heikkinen

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-talk/91614 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/code/help.rb

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
 
P

Piergiuliano Bossi

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 said:
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-talk/91614 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/code/help.rb

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
 
G

gabriele renzi

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 ;)
 
R

ralobao

Ilmari said:
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-talk/91614 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/code/help.rb

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
 
P

Piergiuliano Bossi

gabriele said:
Piergiuliano Bossi ha scritto:


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
 
I

Ilmari Heikkinen

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! :)
 

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

Similar Threads

[ANN] IHelp 0.3.0 5
[ANN] IHelp 0.2.0 10

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top