From: Robert Klemme Date: 2009-03-25T03:26:57+09:00 Subject: Re: : HOWTO start irb on a different object On 24.03.2009 17:25, Jeremy Henty wrote: > On 2009-03-24, Brian Candler wrote: >> Jeremy Henty wrote: >>> I wanted to have irb start its session on an object other than the >>> toplevel. >> This is what I have been using: >> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/244139 > > Yes, that's what I found too. AFAICT that solution copies the irb > method that doesn't quite do what you want and modifies the copy so > that it does do what you want. I prefer my solution for being shorter > and simpler. OTOH my solution monkey-patches the original irb method, > which is a point against it. > >> I'm not interested in setting up a different default object in >> .irbrb, but rather being able to bolt irb onto an application object >> as an interactive CLI for testing/debugging. > > That's what I want too! With my solution I can put an .irbrc in my > application directory that makes irb start up in the context of an > application object. Which is useful. But wouldn't you have to start irb then with either HOME=. irb or with other options in order to make it read the local .irbrc? If you do that then it's not as simple as typing "irb" and in that case you can as well place a script in the local directory which does the proper init. (Well, you could have a line like "load '.irbrc' if test ?r, '.irbrc'" in ~/.irbrc but that somehow feels a bit too automatic to me.) Btw, if you can make IRB read a "local" .irbrc already, then you can as well place code in there like application = whatever_initialization() irb application exit At the moment I cannot see the benefit of your proposal. Kind regards robert -- remember.guy do |as, often| as.you_can - without end