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

Discussion in 'Ruby' started by Ilmari Heikkinen, Dec 22, 2004.

  1. 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
     
    Ilmari Heikkinen, Dec 22, 2004
    #1
    1. Advertising

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


    --
    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
     
    Piergiuliano Bossi, Dec 22, 2004
    #2
    1. Advertising

  3. 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 ;)
     
    gabriele renzi, Dec 22, 2004
    #3
  4. Ilmari Heikkinen

    Guest

    Re: Help 0.1: access ri from irb (using the ri library)

    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-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
     
    , Dec 22, 2004
    #4
  5. 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
     
    Piergiuliano Bossi, Dec 23, 2004
    #5
  6. 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! :)
     
    Ilmari Heikkinen, Dec 23, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin DeMello
    Replies:
    21
    Views:
    344
    Martin DeMello
    Mar 7, 2005
  2. Cs. Henk

    [ANN] Irb enhancements

    Cs. Henk, Mar 9, 2005, in forum: Ruby
    Replies:
    13
    Views:
    186
    Cs. Henk
    Mar 11, 2005
  3. Sam Stephenson
    Replies:
    1
    Views:
    228
    Andrew Walrond
    Jun 18, 2005
  4. Replies:
    1
    Views:
    161
    Florian GroƟ
    Oct 26, 2005
  5. anne001
    Replies:
    1
    Views:
    277
    anne001
    Jun 27, 2006
Loading...

Share This Page