I’m just wondering - I implemented something (thbar (Thibaut Barrère) · GitHub
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).
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.
If something already exists in Ruby to do that this way, I’d like to
know about it.
I came across a YAML-RPC once upon a time; you could try looking for it.
I’d avoid YAML as much as possible, as it’s horribly broken; certainly
useless for mere humans writing YAML anyway.
irb(main):001:0> require “yaml”
=> true
irb(main):002:0> YAML.load(“foo:bar\nbaz:”)
=> “foo:bar baz:”
irb(main):003:0> YAML.load(“foo:bar\nbaz:\n”)
=> {“foo:bar baz”=>nil}
irb(main):004:0> YAML.load(“foo:bar\nbaz:bap\n”)
=> “foo:bar baz:bap”
irb(main):005:0> YAML.load(“foo: bar\nbaz:bap\n”)
ArgumentError: syntax error on line 2, col -1: ' from /usr/local/lib/ruby/1.8/yaml.rb:133:inload’
from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load’
from (irb):5
irb(main):006:0> YAML.load(“foo: bar\nbaz: bap\n”)
=> {“baz”=>“bap”, “foo”=>“bar”}
There are also examples which have been posted to this list showing
objects serialised to YAML and immediately back again, ending up with
different content.
But I sympathise if you want to do something DRb-like, but between two
different Ruby implementations. XMLRPC/JSON won’t give you full Ruby
object serialisation, and SOAP is too horrible to contemplate.
yeah I’m only simple YAML, and it seems to work for me for what I’m
doing. I’ll definitely try to have a C# or Java client consume these
and see what happens.
yeah I’m only simple YAML, and it seems to work for me for what I’m
doing. I’ll definitely try to have a C# or Java client consume these
and see what happens.
Thanks for FastYAML too, interesting.
One other thought: if it’s simple, look at JSON. It’s easy to extend to
serialise arbitrary Ruby objects.
YAML can do things like handling multiple references to the same object,
but it sounds like you don’t need that level of sophistication.