hydra 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/hydra.gemspec +1 -1
- data/lib/hydra/pipe.rb +4 -1
- data/test/test_pipe.rb +14 -6
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/hydra.gemspec
CHANGED
data/lib/hydra/pipe.rb
CHANGED
@@ -34,12 +34,15 @@ module Hydra #:nodoc:
|
|
34
34
|
# Read a line from a pipe. It will have a trailing newline.
|
35
35
|
def gets
|
36
36
|
force_identification
|
37
|
-
@reader.gets
|
37
|
+
@reader.gets.chomp
|
38
38
|
end
|
39
39
|
|
40
40
|
# Write a line to a pipe. It must have a trailing newline.
|
41
41
|
def write(str)
|
42
42
|
force_identification
|
43
|
+
unless str =~ /\n$/
|
44
|
+
str += "\n"
|
45
|
+
end
|
43
46
|
begin
|
44
47
|
@writer.write(str)
|
45
48
|
return str
|
data/test/test_pipe.rb
CHANGED
@@ -8,15 +8,15 @@ class TestPipe < Test::Unit::TestCase
|
|
8
8
|
should "be able to write messages" do
|
9
9
|
Process.fork do
|
10
10
|
@pipe.identify_as_child
|
11
|
-
assert_equal "Test Message
|
12
|
-
@pipe.write "Message Received
|
13
|
-
@pipe.write "Second Message
|
11
|
+
assert_equal "Test Message", @pipe.gets
|
12
|
+
@pipe.write "Message Received"
|
13
|
+
@pipe.write "Second Message"
|
14
14
|
@pipe.close
|
15
15
|
end
|
16
16
|
@pipe.identify_as_parent
|
17
|
-
@pipe.write "Test Message
|
18
|
-
assert_equal "Message Received
|
19
|
-
assert_equal "Second Message
|
17
|
+
@pipe.write "Test Message"
|
18
|
+
assert_equal "Message Received", @pipe.gets
|
19
|
+
assert_equal "Second Message", @pipe.gets
|
20
20
|
assert_raise Hydra::PipeError::Broken do
|
21
21
|
@pipe.write "anybody home?"
|
22
22
|
end
|
@@ -32,5 +32,13 @@ class TestPipe < Test::Unit::TestCase
|
|
32
32
|
@pipe.gets
|
33
33
|
end
|
34
34
|
end
|
35
|
+
should "handle newlines" do
|
36
|
+
Process.fork do
|
37
|
+
@pipe.identify_as_child
|
38
|
+
@pipe.write "Message\n"
|
39
|
+
end
|
40
|
+
@pipe.identify_as_parent
|
41
|
+
assert_equal "Message", @pipe.gets
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|