childprocess 0.5.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1bf2633335fa2da24ffd367d4a83e624b9e22b1
4
- data.tar.gz: 4f05990d1fb49c76270f9ff11211fe4e05daca46
3
+ metadata.gz: 0a69d7a6d2d1a65d1496d2b2dc327348cfdf6801
4
+ data.tar.gz: ec705f40bd0330bea05aa4ed556e047fa8cdf337
5
5
  SHA512:
6
- metadata.gz: 08bc35f482edba588bf05e54777a2e3f1c2a91c0126a32d9cbdf126511deaf6c6958366e5fafd7e2f00fa370942ffe791fbb1b2aa211a0f34748f94a85789beb
7
- data.tar.gz: 7531827c11b12ab23b4f87c487a05bce4cf3fb4a2ee0fd3f45f8dbe7c1803364a7f9577b43c6d0a4b62e92e3bd03ab9a5cb263bf64bf623f1c84a6b7f830c38b
6
+ metadata.gz: 474cbc9d237b873332e387e602b575628c49479cb60705509fc154dd35b5409fe1b48d2b8b9d5b5775d72b5b3787359cde2b9f35a37fb5834a444efb327b0002
7
+ data.tar.gz: a25cb4f8d10b38537b101484bebf8888530020ff3876615d4daa5b78ee96b104758973f0e15b2f2e97e50cd82fd5de532d4bff1352a3bcc47d7497dafd0ac745
@@ -13,18 +13,16 @@ module ChildProcess
13
13
  actions = Lib::FileActions.new
14
14
  attrs = Lib::Attrs.new
15
15
 
16
- if @io
17
- if @io.stdout
18
- actions.add_dup fileno_for(@io.stdout), fileno_for($stdout)
19
- else
20
- actions.add_open fileno_for($stdout), "/dev/null", File::WRONLY, 0644
21
- end
16
+ if io.stdout
17
+ actions.add_dup fileno_for(io.stdout), fileno_for($stdout)
18
+ else
19
+ actions.add_open fileno_for($stdout), "/dev/null", File::WRONLY, 0644
20
+ end
22
21
 
23
- if @io.stderr
24
- actions.add_dup fileno_for(@io.stderr), fileno_for($stderr)
25
- else
26
- actions.add_open fileno_for($stderr), "/dev/null", File::WRONLY, 0644
27
- end
22
+ if io.stderr
23
+ actions.add_dup fileno_for(io.stderr), fileno_for($stderr)
24
+ else
25
+ actions.add_open fileno_for($stderr), "/dev/null", File::WRONLY, 0644
28
26
  end
29
27
 
30
28
  if duplex?
@@ -1,3 +1,3 @@
1
1
  module ChildProcess
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/spec/io_spec.rb CHANGED
@@ -204,4 +204,15 @@ describe ChildProcess do
204
204
  out.close
205
205
  end
206
206
  end
207
+
208
+ it 'should not inherit stdout and stderr by default' do
209
+ cap = capture_std do
210
+ process = echo
211
+ process.start
212
+ process.wait
213
+ end
214
+
215
+ expect(cap.stdout).to eq ''
216
+ expect(cap.stderr).to eq ''
217
+ end
207
218
  end
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,7 @@ require 'rspec'
11
11
  require 'tempfile'
12
12
  require 'socket'
13
13
  require 'stringio'
14
+ require 'ostruct'
14
15
 
15
16
  module ChildProcessSpecHelper
16
17
  RUBY = defined?(Gem) ? Gem.ruby : 'ruby'
@@ -212,6 +213,26 @@ module ChildProcessSpecHelper
212
213
  end
213
214
  end
214
215
 
216
+ def capture_std
217
+ orig_out = STDOUT.clone
218
+ orig_err = STDERR.clone
219
+
220
+ out = Tempfile.new 'captured-stdout'
221
+ err = Tempfile.new 'captured-stderr'
222
+ out.sync = true
223
+ err.sync = true
224
+
225
+ STDOUT.reopen out
226
+ STDERR.reopen err
227
+
228
+ yield
229
+
230
+ OpenStruct.new stdout: rewind_and_read(out), stderr: rewind_and_read(err)
231
+ ensure
232
+ STDOUT.reopen orig_out
233
+ STDERR.reopen orig_err
234
+ end
235
+
215
236
  end # ChildProcessSpecHelper
216
237
 
217
238
  Thread.abort_on_exception = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: childprocess
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken