process_executer 1.0.2 → 1.1.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
  SHA256:
3
- metadata.gz: 05077fa5757c373b7587a35c2f32aaa3deeaa5708845ec5db485fccb4f29bc5c
4
- data.tar.gz: 9b1fda5d3669f6f09100e2b4b47ec8905d8448632cbd1998af0e606d724967cf
3
+ metadata.gz: 5d476a9c88bc9491b887b5a5507dd2288f1aadf1b4735c8c15b790dbbfa423f9
4
+ data.tar.gz: 763c100ce03c3f625e323fefcdafe3788300c51429296110a5aa9222eb05d039
5
5
  SHA512:
6
- metadata.gz: 6f48795cd44788c27a9931a1960e9d5f83d72ab794fd37d5d24b0a3110a1582211f80cdeef4e8cd171183f3ef9ccfec615f60fda46dd480cdaed10856d69a373
7
- data.tar.gz: 54b9a282d8dc8d0ebca8e5e2b1368a0040ec140c5a793d438fe4891363d74574b31541d9d22aea566f09f8b3284cb7d12c49f071f9dca3cd29bbcd8df9babfbe
6
+ metadata.gz: f27eebdee1a46bac93ecfa8c78d29feba3ebb2c833d53dda7cd3213ee43c441994f50e0317592898a31d0eff42ca3a83cc3e3ad201d746fd641c7de9d3d9d762
7
+ data.tar.gz: 1e303f09b81b1605cfef527b41fbfc52f8e247a10c5ad3af1bed944bab2d6cf839eac9850b1b1c6038d73549abd1e7d0cef18de3dc081930f8d764512a3adc43
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.0.5
1
+ ruby 3.3.5
data/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@ All notable changes to the process_executer gem will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## v1.1.1 (2024-09-25)
9
+
10
+ [Full Changelog](https://github.com/main-branch/process_executer/compare/v1.1.0..v1.1.1)
11
+
12
+ Changes since v1.1.0:
13
+
14
+ * c3f063a Use a later version of ruby for development
15
+ * d4eeb1e Use latest version of the actions/checkout to v4
16
+ * eb4dad7 Fix flakey test on JRuby
17
+ * ac9417a Update CI build to run on v1.x branch
18
+ * 014e70f Remove unused require for 'forwardable' and 'ostruct' (for v1.x)
19
+
20
+ ## v1.1.0 (2024-02-02)
21
+
22
+ [Full Changelog](https://github.com/main-branch/process_executer/compare/v1.0.2..v1.1.0)
23
+
24
+ Changes since v1.0.2:
25
+
26
+ * a473281 ProcessExecuter.spawn should indicate if the subprocess timed out or not (#43)
27
+
8
28
  ## v1.0.2 (2024-02-01)
9
29
 
10
30
  [Full Changelog](https://github.com/main-branch/process_executer/compare/v1.0.1..v1.0.2)
data/README.md CHANGED
@@ -77,7 +77,15 @@ important behaviorial differences:
77
77
  2. A timeout can be specified using the `:timeout` option
78
78
 
79
79
  If the command does not terminate before the timeout, the process is killed by
80
- sending it the SIGKILL signal.
80
+ sending it the SIGKILL signal. The returned status object's `timeout?` attribute will
81
+ return `true`. For example:
82
+
83
+ ```ruby
84
+ status = ProcessExecuter.spawn('sleep 10', timeout: 0.01)
85
+ status.signaled? #=> true
86
+ status.termsig #=> 9
87
+ status.timeout? #=> true
88
+ ```
81
89
 
82
90
  ## Installation
83
91
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
4
- require 'ostruct'
5
3
  require 'pp'
6
4
 
7
5
  module ProcessExecuter
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'delegate'
4
+
5
+ module ProcessExecuter
6
+ # A simple delegator for Process::Status that adds a `timeout?` attribute
7
+ #
8
+ # @api public
9
+ #
10
+ class Status < SimpleDelegator
11
+ extend Forwardable
12
+
13
+ # Create a new Status object from a Process::Status and timeout flag
14
+ #
15
+ # @param status [Process::Status] the status to delegate to
16
+ # @param timeout [Boolean] true if the process timed out
17
+ #
18
+ # @example
19
+ # status = Process.wait2(pid).last
20
+ # timeout = false
21
+ # ProcessExecuter::Status.new(status, timeout)
22
+ #
23
+ # @api public
24
+ #
25
+ def initialize(status, timeout)
26
+ super(status)
27
+ @timeout = timeout
28
+ end
29
+
30
+ # @!attribute [r] timeout?
31
+ #
32
+ # True if the process timed out and was sent the SIGKILL signal
33
+ #
34
+ # @example
35
+ # status = ProcessExecuter.spawn('sleep 10', timeout: 0.01)
36
+ # status.timeout? # => true
37
+ #
38
+ # @return [Boolean]
39
+ #
40
+ # @api public
41
+ #
42
+ def timeout? = @timeout
43
+ end
44
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ProcessExecuter
4
4
  # The current Gem version
5
- VERSION = '1.0.2'
5
+ VERSION = '1.1.1'
6
6
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'process_executer/monitored_pipe'
4
4
  require 'process_executer/options'
5
+ require 'process_executer/status'
5
6
 
6
7
  require 'timeout'
7
8
 
@@ -59,16 +60,16 @@ module ProcessExecuter
59
60
  # @param pid [Integer] the process id
60
61
  # @param options [ProcessExecuter::Options] the options used
61
62
  #
62
- # @return [Process::Status] the status of the process
63
+ # @return [ProcessExecuter::Status] the status of the process
63
64
  #
64
65
  # @api private
65
66
  #
66
67
  private_class_method def self.wait_for_process(pid, options)
67
68
  Timeout.timeout(options.timeout) do
68
- Process.wait2(pid).last
69
+ ProcessExecuter::Status.new(Process.wait2(pid).last, false)
69
70
  end
70
71
  rescue Timeout::Error
71
72
  Process.kill('KILL', pid)
72
- Process.wait2(pid).last
73
+ ProcessExecuter::Status.new(Process.wait2(pid).last, true)
73
74
  end
74
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_executer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Couball
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-02 00:00:00.000000000 Z
11
+ date: 2024-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler-audit
@@ -190,6 +190,7 @@ files:
190
190
  - lib/process_executer.rb
191
191
  - lib/process_executer/monitored_pipe.rb
192
192
  - lib/process_executer/options.rb
193
+ - lib/process_executer/status.rb
193
194
  - lib/process_executer/version.rb
194
195
  - process_executer.gemspec
195
196
  homepage: https://github.com/main-branch/process_executer
@@ -199,8 +200,8 @@ metadata:
199
200
  allowed_push_host: https://rubygems.org
200
201
  homepage_uri: https://github.com/main-branch/process_executer
201
202
  source_code_uri: https://github.com/main-branch/process_executer
202
- changelog_uri: https://rubydoc.info/gems/process_executer/1.0.2/file/CHANGELOG.md
203
- documentation_uri: https://rubydoc.info/gems/process_executer/1.0.2
203
+ changelog_uri: https://rubydoc.info/gems/process_executer/1.1.1/file/CHANGELOG.md
204
+ documentation_uri: https://rubydoc.info/gems/process_executer/1.1.1
204
205
  rubygems_mfa_required: 'true'
205
206
  post_install_message:
206
207
  rdoc_options: []
@@ -217,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
218
  - !ruby/object:Gem::Version
218
219
  version: '0'
219
220
  requirements: []
220
- rubygems_version: 3.2.33
221
+ rubygems_version: 3.5.16
221
222
  signing_key:
222
223
  specification_version: 4
223
224
  summary: An API for executing commands in a subprocess