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 CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/hydra.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hydra}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nick Gauthier"]
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\n", @pipe.gets
12
- @pipe.write "Message Received\n"
13
- @pipe.write "Second Message\n"
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\n"
18
- assert_equal "Message Received\n", @pipe.gets
19
- assert_equal "Second Message\n", @pipe.gets
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Gauthier