[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

irb question

Joe Van Dyk

4/25/2005 5:21:00 PM

Hi,

I'd like to be able to run a ruby program that would initialize a few
objects, require a few libraries, and then dump me into an irb shell
(that has access to those objects). How would I do that?

Thanks,
Joe



5 Answers

Brian Schröder

4/25/2005 5:24:00 PM

0

On 25/04/05, Joe Van Dyk <joevandyk@gmail.com> wrote:
> Hi,
>
> I'd like to be able to run a ruby program that would initialize a few
> objects, require a few libraries, and then dump me into an irb shell
> (that has access to those objects). How would I do that?
>
> Thanks,
> Joe
>
>

have a look at breakpoint.rb.

http://dev-utils.ruby...

best regards,

Brian

--
http://ruby.brian-sch...

multilingual _non rails_ ruby based vocabulary trainer:
http://www.vocabu... | http://www.g... | http://www.vok...



Joe Van Dyk

4/25/2005 5:52:00 PM

0

On 4/25/05, Brian Schröder <ruby.brian@gmail.com> wrote:
> On 25/04/05, Joe Van Dyk <joevandyk@gmail.com> wrote:
> > Hi,
> >
> > I'd like to be able to run a ruby program that would initialize a few
> > objects, require a few libraries, and then dump me into an irb shell
> > (that has access to those objects). How would I do that?
> >
> > Thanks,
> > Joe
> >
> >
>
> have a look at breakpoint.rb.
>
> http://dev-utils.ruby...
>


% cat t.rb
require 'dev-utils/debug'

% ruby t.rb
/home/mz652c/mine-linux/lib/ruby/site_ruby/1.8/dev-utils/debug/irb.rb:8:in
`require': No such file to load -- extensions/binding (LoadError)
from /home/mz652c/mine-linux/lib/ruby/site_ruby/1.8/dev-utils/debug/irb.rb:8
from /home/mz652c/mine-linux/lib/ruby/site_ruby/1.8/dev-utils/debug.rb:28:in
`require'
from /home/mz652c/mine-linux/lib/ruby/site_ruby/1.8/dev-utils/debug.rb:28
from t.rb:2:in `require'
from t.rb:2


Ideas?



Joe Van Dyk

4/25/2005 5:54:00 PM

0

On 4/25/05, Joe Van Dyk <joevandyk@gmail.com> wrote:
> On 4/25/05, Brian Schröder <ruby.brian@gmail.com> wrote:
> > On 25/04/05, Joe Van Dyk <joevandyk@gmail.com> wrote:
> > > Hi,
> > >
> > > I'd like to be able to run a ruby program that would initialize a few
> > > objects, require a few libraries, and then dump me into an irb shell
> > > (that has access to those objects). How would I do that?
> > >
> > > Thanks,
> > > Joe
> > >
> > >
> >
> > have a look at breakpoint.rb.
> >
> > http://dev-utils.ruby...
> >
>
> % cat t.rb
> require 'dev-utils/debug'
>
> % ruby t.rb
> /home/mz652c/mine-linux/lib/ruby/site_ruby/1.8/dev-utils/debug/irb.rb:8:in
> `require': No such file to load -- extensions/binding (LoadError)
> from /home/mz652c/mine-linux/lib/ruby/site_ruby/1.8/dev-utils/debug/irb.rb:8
> from /home/mz652c/mine-linux/lib/ruby/site_ruby/1.8/dev-utils/debug.rb:28:in
> `require'
> from /home/mz652c/mine-linux/lib/ruby/site_ruby/1.8/dev-utils/debug.rb:28
> from t.rb:2:in `require'
> from t.rb:2
>
> Ideas?

Nevermind... need the extension library. :-)



Robert Klemme

4/25/2005 7:02:00 PM

0


"Joe Van Dyk" <joevandyk@gmail.com> schrieb im Newsbeitrag
news:c715e64050425102137d986e0@mail.gmail.com...
> Hi,
>
> I'd like to be able to run a ruby program that would initialize a few
> objects, require a few libraries, and then dump me into an irb shell
> (that has access to those objects). How would I do that?

If it's not a problem to use global variables you can do this:

$ irb -r i.rb
irb(main):001:0> $foo
=> "bar"
irb(main):002:0> exit

Robert@Babelfish2 /c/TEMP
$ cat i.rb

$foo = "bar"

Robert@Babelfish2 /c/TEMP
$

You can also invoke IRB from a program:

Robert@Babelfish2 /c/TEMP
$ ruby i2.rb
irb(main):001:0> $foo
=> "bar"
irb(main):002:0> exit

Robert@Babelfish2 /c/TEMP
$ cat i2.rb

require 'irb'

$foo = "bar"
IRB.start



Kind regards

robert

Assaph Mehr

4/25/2005 10:40:00 PM

0


> > > have a look at breakpoint.rb.
> Nevermind... need the extension library. :-)

Actually that's an old version. See the (new) official home at:
http://ruby-breakpoint.rub...