Irb question

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.rubyforge.org/

best regards,

Brian

···

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

--
http://ruby.brian-schroeder.de/

multilingual _non rails_ ruby based vocabulary trainer:
http://www.vocabulaire.org/ | http://www.gloser.org/ | http://www.vokabeln.net/

"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

% 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?

···

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.rubyforge.org/

Nevermind... need the extension library. :slight_smile:

···

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.rubyforge.org/
>

% 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?

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

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