[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Calling JRuby from Ruby.

EvilGeenius

8/16/2007 8:55:00 AM

Whats the best way of running a JRuby script from Ruby?

I know you can do this : `jruby script.rb`, but that won't allow passing
of parameters from ruby to jruby.

You could pass parameters by passing the Object.inspect string and then
doing an eval:


`jruby script/rb #{object.inspect}`
4 Answers

Robert Dober

8/16/2007 9:27:00 AM

0

On 8/16/07, Chris Richards <evilgeenius@gmail.com> wrote:
> Whats the best way of running a JRuby script from Ruby?
>
> I know you can do this : `jruby script.rb`, but that won't allow passing
> of parameters from ruby to jruby.
>
> You could pass parameters by passing the Object.inspect string and then
> doing an eval:
>
>
> `jruby script/rb #{object.inspect}`
> .
>
> I suppose you could serialize your objects/parameters and pass it though
> that way.
>
> Any decent ideas?
Hmm are Ruby and JRuby drb compatible? Maybe that would do the trick for you?
Would be great BTW.
> Thanks
> Chris
> --
> Posted via http://www.ruby-....
>
>
Cheers
Robert

--
[...] as simple as possible, but no simpler.
-- Attributed to Albert Einstein

Robert Dober

8/16/2007 8:32:00 PM

0

On 8/16/07, Robert Dober <robert.dober@gmail.com> wrote:

> Hmm are Ruby and JRuby drb compatible? Maybe that would do the trick for you?
> Would be great BTW.
I just downloaded JRuby 1.0, JRuby as Server or client, Ruby as client
or server, does not matter works out of the box, like charm.
Chris this really should do the trick for you, no?
Something like :
Ruby:
-------
require 'drb'
class MyParams
attr_reader :value
def initialize value
@val = value
end
end

DRb.start_service("druby://localhost:4646", MyParams.new(
theObjectYouWant2Pass ));

system "jruby... " ### this might be tricky, use either fork or Threading
sleep 42
DRb.stop_service
=============================================
And in JRuby

require 'drb'
DRb.start_service
incoming = DRbObject.new(nil, "druby://localhost:4646")
object = incoming.value
DRb.stop_service

do whatever you want with value...


HTH
Robert

--
I'm an atheist and that's it. I believe there's nothing we can know
except that we should be kind to each other and do what we can for
other people.
-- Katharine Hepburn

EvilGeenius

8/23/2007 4:33:00 PM

0

DRb is the answer and it does work like a charm!!
--
Posted via http://www.ruby-....

EvilGeenius

8/23/2007 4:33:00 PM

0

> DRb is the answer and it does work like a charm!!

So now i can have a jruby drb server purely dedicated to just creating
nice JFreeChart charts for me!
--
Posted via http://www.ruby-....