irb question

J

Joe Van Dyk

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
 
J

Joe Van Dyk

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

Joe Van Dyk

% 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. :)
 
R

Robert Klemme

Joe Van Dyk said:
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
 

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

irb question 8
Driving irb from IO.popen 5
Question about my projects 3
Running -r in IRB 5
self in irb versus script 3
redirecting stderr in irb 2
irb in cygwin 1
documentation from inside irb 5

Members online

No members online now.

Forum statistics

Threads
474,171
Messages
2,570,935
Members
47,472
Latest member
KarissaBor

Latest Threads

Top