posix-spawn 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,9 @@
1
1
  require 'posix/spawn'
2
2
 
3
+ class String
4
+ alias bytesize size
5
+ end unless ''.respond_to?(:bytesize)
6
+
3
7
  module POSIX
4
8
  module Spawn
5
9
  # POSIX::Spawn::Child includes logic for executing child processes and
@@ -142,6 +146,7 @@ module POSIX
142
146
  # exceeds the amount specified by the max argument.
143
147
  def read_and_write(input, stdin, stdout, stderr, timeout=nil, max=nil)
144
148
  input ||= ''
149
+ input.force_encoding('BINARY') if input.respond_to?(:force_encoding)
145
150
  max = nil if max && max <= 0
146
151
  out, err = '', ''
147
152
  offset = 0
@@ -162,11 +167,11 @@ module POSIX
162
167
  begin
163
168
  boom = nil
164
169
  size = fd.write_nonblock(input)
165
- input = input[size, input.size]
170
+ input = input[size, input.bytesize]
166
171
  rescue Errno::EPIPE => boom
167
172
  rescue Errno::EAGAIN, Errno::EINTR
168
173
  end
169
- if boom || input.size == 0
174
+ if boom || input.bytesize == 0
170
175
  stdin.close
171
176
  writers.delete(stdin)
172
177
  end
@@ -1,5 +1,5 @@
1
1
  module POSIX
2
2
  module Spawn
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ # coding: UTF-8
2
+
1
3
  require 'test/unit'
2
4
  require 'posix-spawn'
3
5
 
@@ -104,4 +106,11 @@ class ChildTest < Test::Unit::TestCase
104
106
  p = Child.new('false', :input => input)
105
107
  assert !p.success?
106
108
  end
109
+
110
+ def test_utf8_input
111
+ input = "hålø"
112
+ p = Child.new('cat', :input => input)
113
+ assert p.success?
114
+ assert_equal input, p.out
115
+ end
107
116
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix-spawn
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease:
5
- version: 0.3.0
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
6
11
  platform: ruby
7
12
  authors:
8
13
  - Ryan Tomayko
@@ -11,7 +16,7 @@ autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
18
 
14
- date: 2011-03-03 00:00:00 -08:00
19
+ date: 2011-03-05 00:00:00 -08:00
15
20
  default_executable:
16
21
  dependencies:
17
22
  - !ruby/object:Gem::Dependency
@@ -22,6 +27,11 @@ dependencies:
22
27
  requirements:
23
28
  - - "="
24
29
  - !ruby/object:Gem::Version
30
+ hash: 15
31
+ segments:
32
+ - 0
33
+ - 7
34
+ - 6
25
35
  version: 0.7.6
26
36
  type: :development
27
37
  version_requirements: *id001
@@ -71,17 +81,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
81
  requirements:
72
82
  - - ">="
73
83
  - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
74
87
  version: "0"
75
88
  required_rubygems_version: !ruby/object:Gem::Requirement
76
89
  none: false
77
90
  requirements:
78
91
  - - ">="
79
92
  - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
80
96
  version: "0"
81
97
  requirements: []
82
98
 
83
99
  rubyforge_project:
84
- rubygems_version: 1.5.2
100
+ rubygems_version: 1.4.2
85
101
  signing_key:
86
102
  specification_version: 3
87
103
  summary: posix_spawnp(2) for ruby