From 2fa15b735b399350e3146386daea4b9419ca4b09 Mon Sep 17 00:00:00 2001 From: Nick Gauthier Date: Wed, 27 Jan 2010 15:47:50 -0500 Subject: [PATCH] mostly working. needs work on IO cleanup --- lib/hydra/message.rb | 5 +++++ lib/hydra/runner.rb | 2 +- test/test_runner.rb | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/hydra/message.rb b/lib/hydra/message.rb index a1c0d6d..c2cb9b3 100644 --- a/lib/hydra/message.rb +++ b/lib/hydra/message.rb @@ -1,5 +1,10 @@ module Hydra #:nodoc: class Message #:nodoc: + def initialize(opts = {}) + opts.each do |k,v| + self.send(k,v) + end + end def self.build(hash) hash.delete(:class).new(hash) end diff --git a/lib/hydra/runner.rb b/lib/hydra/runner.rb index c809162..83d521d 100644 --- a/lib/hydra/runner.rb +++ b/lib/hydra/runner.rb @@ -2,7 +2,7 @@ module Hydra #:nodoc: class Runner def initialize(io) @io = io - @io.write Hydra::Messages::RunnerRequestsFile.new.serialize + @io.write Hydra::Messages::RunnerRequestsFile.new end end end diff --git a/test/test_runner.rb b/test/test_runner.rb index 46c3c49..94799ec 100644 --- a/test/test_runner.rb +++ b/test/test_runner.rb @@ -11,8 +11,7 @@ class TestRunner < Test::Unit::TestCase @pipe.identify_as_parent end should "request a file on boot" do - @message = Hydra::Message.build(@pipe.gets) - assert @message.is_a?(Hydra::Messages::RunnerRequestsFile) + assert @pipe.gets.is_a?(Hydra::Messages::RunnerRequestsFile) end should "return a result message after processing a file" do