From: Robert Klemme Date: 2009-03-02T21:48:50+09:00 Subject: Re: Using YAML for inter-process communication - anything built-in ? On 02.03.2009 13:14, Thibaut Barrère wrote: > Hi, > > I'm just wondering - I implemented something (http://github.com/thbar/ > petite-lettre/tree/master) I believe probably already exists, can > anyone tell me if it does ? > > I'm using YAML to communicate using stdin/stdout between a Ruby MRI > process and a JRuby process (I will soon use it to communicate between > IronRuby and JRuby). > > The parent process launches the child using: > > PetiteLettre.call("ruby child_program.rb", { :command > => :start_sale, :isbn => "1234567", :price => 12.4 }) > > and the child responds with: > > PetiteLettre.receive do |message| > response = {} > if message[:command] == :start_sale > # do something here > raise "Price is too low" if message[:price] < 15.0 > response[:status] = "OK" > response[:transaction_id] = "1235" > else > raise "Unknown command '#{message[:command]}'" > end > response > end > > If something already exists in Ruby to do that this way, I'd like to > know about it. > > Any idea ? I am not sure about portability of Marshal across Ruby implementations. In case it is given you could achieve similar results using DRb. Kind regards robert