open3 0.2.1 → 0.3.0

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
  SHA256:
3
- metadata.gz: 627e2ba8abf0e5093f8e5188915236d4bc2becb3041a8356025ab9872d4038e1
4
- data.tar.gz: dc4e1a4027f17bd9a4fbb1e7d7c85521679553af87127561ff2f72a02a4fdd30
3
+ metadata.gz: '0428b6beebc524086f81a7c67d9102fd5074e802a1b89b835dacbe676eea2450'
4
+ data.tar.gz: 65c65d180f3a714850a3df02e90fc9ee99f5cdcffac1c0900f60e4a2d5d711e7
5
5
  SHA512:
6
- metadata.gz: 5cff7891c4d3edb418dd973c2dff88cd2ca8e69708658dbecef260c5133081ed4e4cd6ed499f05b0b38ee0430fadecafd71ee7e4f71f6af87f63ff64b30a4a15
7
- data.tar.gz: 0f3db4c91d7d1fb56fa4ae6d0a2ee83a7d298350378bf9e218f15ed7cb112a7db4ce9993a6f41e304ae5b7f867714bc1d6119b3b9e50a1db2e81ae5ccca2e2df
6
+ metadata.gz: e39d951ead49eb48da4072b028245dce57417eeb074c90dd398639dd971277705149b0f21467ae4045aa9560c07fc57d1d39b1acbbbeac076cfa23e3a561c1a5
7
+ data.tar.gz: 8daaa229ed746d37b4312f026aa83cf491f900f6fdc17d8803c3f81c2bc996110d4bda013f7c40b05eccd8f8788960555d0c5c3216d81adbde4e17e5e68ae0a5
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ LICENSE.txt
2
+ README.md
3
+ lib/
@@ -0,0 +1,4 @@
1
+ changelog:
2
+ exclude:
3
+ labels:
4
+ - dependencies # Added by Dependabot
@@ -0,0 +1,46 @@
1
+ name: Publish gem to rubygems.org
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ push:
13
+ if: github.repository == 'ruby/open3'
14
+ runs-on: ubuntu-latest
15
+
16
+ environment:
17
+ name: rubygems.org
18
+ url: https://rubygems.org/gems/open3
19
+
20
+ permissions:
21
+ contents: write
22
+ id-token: write
23
+
24
+ steps:
25
+ - name: Harden Runner
26
+ uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
27
+ with:
28
+ egress-policy: audit
29
+
30
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31
+
32
+ - name: Set up Ruby
33
+ uses: ruby/setup-ruby@d5126b9b3579e429dd52e51e68624dda2e05be25 # v1.267.0
34
+ with:
35
+ bundler-cache: true
36
+ ruby-version: ruby
37
+
38
+ - name: Publish to RubyGems
39
+ uses: rubygems/release-gem@7f9650160c1a4e7989fdc9855807bdbd421d8b6b # v1.4.1
40
+
41
+ - name: Create GitHub release
42
+ run: |
43
+ tag_name="$(git describe --tags --abbrev=0)"
44
+ gh release create "${tag_name}" --verify-tag --generate-notes
45
+ env:
46
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,33 @@
1
+ name: Sync ruby
2
+ on:
3
+ push:
4
+ branches: [master]
5
+ jobs:
6
+ sync:
7
+ name: Sync ruby
8
+ runs-on: ubuntu-latest
9
+ if: ${{ github.repository_owner == 'ruby' }}
10
+ steps:
11
+ - uses: actions/checkout@v7
12
+
13
+ - name: Create GitHub App token
14
+ id: app-token
15
+ uses: actions/create-github-app-token@v3
16
+ with:
17
+ app-id: 2060836
18
+ private-key: ${{ secrets.RUBY_SYNC_DEFAULT_GEMS_PRIVATE_KEY }}
19
+ owner: ruby
20
+ repositories: ruby
21
+
22
+ - name: Sync to ruby/ruby
23
+ uses: convictional/trigger-workflow-and-wait@v1.6.5
24
+ with:
25
+ owner: ruby
26
+ repo: ruby
27
+ workflow_file_name: sync_default_gems.yml
28
+ github_token: ${{ steps.app-token.outputs.token }}
29
+ ref: master
30
+ client_payload: |
31
+ {"gem":"${{ github.event.repository.name }}","before":"${{ github.event.before }}","after":"${{ github.event.after }}"}
32
+ propagate_failure: true
33
+ wait_interval: 10
@@ -6,7 +6,7 @@ jobs:
6
6
  ruby-versions:
7
7
  uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
8
  with:
9
- engine: cruby
9
+ engine: cruby-jruby
10
10
  min_version: 2.6
11
11
 
12
12
  test:
@@ -15,10 +15,18 @@ jobs:
15
15
  strategy:
16
16
  matrix:
17
17
  ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
18
- os: [ ubuntu-latest, macos-latest ]
18
+ os: [ ubuntu-latest, macos-latest, windows-latest ]
19
+ include:
20
+ - ruby: mswin
21
+ os: windows-latest
22
+ exclude:
23
+ - ruby: jruby
24
+ os: windows-latest
25
+ - ruby: jruby-head
26
+ os: windows-latest
19
27
  runs-on: ${{ matrix.os }}
20
28
  steps:
21
- - uses: actions/checkout@v4
29
+ - uses: actions/checkout@v7
22
30
  - name: Set up Ruby
23
31
  uses: ruby/setup-ruby@v1
24
32
  with:
@@ -20,15 +20,15 @@ module Open3
20
20
  end
21
21
  module_function :popen3
22
22
 
23
- IO_3 = proc do |process|
23
+ IO_3 = proc do |process| # :nodoc:
24
24
  [process.getOutputStream.to_io, process.getInputStream.to_io, process.getErrorStream.to_io]
25
25
  end
26
26
 
27
- BUILD_2 = proc do |builder|
27
+ BUILD_2 = proc do |builder| # :nodoc:
28
28
  builder.redirectError(ProcessBuilder::Redirect::INHERIT)
29
29
  end
30
30
 
31
- IO_2 = proc do |process|
31
+ IO_2 = proc do |process| # :nodoc:
32
32
  [process.getOutputStream.to_io, process.getInputStream.to_io]
33
33
  end
34
34
 
@@ -42,7 +42,7 @@ module Open3
42
42
  end
43
43
  module_function :popen2
44
44
 
45
- BUILD_2E = proc do |builder|
45
+ BUILD_2E = proc do |builder| # :nodoc:
46
46
  builder.redirectErrorStream(true)
47
47
  end
48
48
 
@@ -56,7 +56,7 @@ module Open3
56
56
  end
57
57
  module_function :popen2e
58
58
 
59
- def processbuilder_run(cmd, opts, build: nil, io:)
59
+ def processbuilder_run(cmd, opts, build: nil, io:) # :nodoc:
60
60
  opts.each do |k, v|
61
61
  if Integer === k
62
62
  if IO == v || !(String === v || v.respond_to?(:to_path))
@@ -113,7 +113,7 @@ module Open3
113
113
  private :processbuilder_run
114
114
  end
115
115
 
116
- class DetachThread < Thread
116
+ class DetachThread < Thread # :nodoc:
117
117
  attr_reader :pid
118
118
 
119
119
  def initialize(pid)
data/lib/open3/version.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Open3
2
- VERSION = "0.2.1"
2
+ # The version string
3
+ VERSION = "0.3.0"
3
4
  end
data/lib/open3.rb CHANGED
@@ -520,13 +520,6 @@ module Open3
520
520
  opts[[:out, :err]] = out_w
521
521
 
522
522
  popen_run(cmd, opts, [in_r, out_w], [in_w, out_r], &block)
523
- ensure
524
- if block
525
- in_r.close
526
- in_w.close
527
- out_r.close
528
- out_w.close
529
- end
530
523
  end
531
524
  module_function :popen2e
532
525
 
@@ -534,16 +527,23 @@ module Open3
534
527
  pid = spawn(*cmd, opts)
535
528
  wait_thr = Process.detach(pid)
536
529
  child_io.each(&:close)
530
+ child_io = nil
537
531
  result = [*parent_io, wait_thr]
538
532
  if defined? yield
539
- begin
540
- return yield(*result)
541
- ensure
533
+ yield(*result)
534
+ else
535
+ result
536
+ end
537
+ ensure
538
+ if result
539
+ if defined? yield
542
540
  parent_io.each(&:close)
543
541
  wait_thr.join
544
542
  end
543
+ else
544
+ child_io&.each(&:close)
545
+ parent_io.each(&:close)
545
546
  end
546
- result
547
547
  end
548
548
  module_function :popen_run
549
549
  class << self
@@ -1354,7 +1354,7 @@ module Open3
1354
1354
  opts_base.delete :out
1355
1355
 
1356
1356
  wait_thrs = []
1357
- r = nil
1357
+ r = r2 = w2 = nil
1358
1358
  cmds.each_with_index {|cmd, i|
1359
1359
  cmd_opts = opts_base.dup
1360
1360
  if String === cmd
@@ -1387,17 +1387,25 @@ module Open3
1387
1387
  w2&.close
1388
1388
  r = r2
1389
1389
  }
1390
- result = parent_io + [wait_thrs]
1391
1390
  child_io.each(&:close)
1391
+ child_io = nil
1392
+ result = parent_io + [wait_thrs]
1392
1393
  if defined? yield
1393
- begin
1394
- return yield(*result)
1395
- ensure
1394
+ yield(*result)
1395
+ else
1396
+ result
1397
+ end
1398
+ ensure
1399
+ if result
1400
+ if defined? yield
1396
1401
  parent_io.each(&:close)
1397
1402
  wait_thrs.each(&:join)
1398
1403
  end
1404
+ else
1405
+ [r, r2, w2, *child_io, *parent_io].each do |io|
1406
+ io&.close
1407
+ end
1399
1408
  end
1400
- result
1401
1409
  end
1402
1410
  module_function :pipeline_run
1403
1411
  class << self
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-12-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Popen, but with stderr, too
14
13
  email:
@@ -17,8 +16,11 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
19
+ - ".document"
20
20
  - ".github/dependabot.yml"
21
- - ".github/workflows/test-jruby.yml"
21
+ - ".github/release.yml"
22
+ - ".github/workflows/push_gem.yml"
23
+ - ".github/workflows/sync-ruby.yml"
22
24
  - ".github/workflows/test.yml"
23
25
  - ".gitignore"
24
26
  - Gemfile
@@ -38,7 +40,6 @@ licenses:
38
40
  metadata:
39
41
  homepage_uri: https://github.com/ruby/open3
40
42
  source_code_uri: https://github.com/ruby/open3
41
- post_install_message:
42
43
  rdoc_options: []
43
44
  require_paths:
44
45
  - lib
@@ -53,8 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
54
  - !ruby/object:Gem::Version
54
55
  version: '0'
55
56
  requirements: []
56
- rubygems_version: 3.5.0.dev
57
- signing_key:
57
+ rubygems_version: 3.6.9
58
58
  specification_version: 4
59
59
  summary: Popen, but with stderr, too
60
60
  test_files: []
@@ -1,21 +0,0 @@
1
- name: test
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
- strategy:
9
- matrix:
10
- ruby: [ 2.7, 2.6, head, jruby-9.3 ]
11
- os: [ ubuntu-latest, macos-latest ]
12
- runs-on: ${{ matrix.os }}
13
- steps:
14
- - uses: actions/checkout@v4
15
- - name: Set up Ruby
16
- uses: ruby/setup-ruby@v1
17
- with:
18
- ruby-version: ${{ matrix.ruby }}
19
- bundler-cache: true # 'bundle install' and cache
20
- - name: Run test
21
- run: bundle exec rake test