process_executer 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec0548ff8356b9466db5fe9c9992e134010c9842561e1b0c0b95a5418fb2c2d2
4
- data.tar.gz: 7b9ead3538f7117b453a5353ad0a1ed352b7c60fa86fbacaa12081ff32b411cb
3
+ metadata.gz: 05077fa5757c373b7587a35c2f32aaa3deeaa5708845ec5db485fccb4f29bc5c
4
+ data.tar.gz: 9b1fda5d3669f6f09100e2b4b47ec8905d8448632cbd1998af0e606d724967cf
5
5
  SHA512:
6
- metadata.gz: a35f9cd143bf7236efbb107a8de130784c195bedb83e95262cc26ae7e2b7e586b7230bdf1ad680c508a5dd8b2c3398c89290ad01a1e5914e165179c298bf5b11
7
- data.tar.gz: 5dabb78fd2151f587078b3a139974eb390e23e86be961ce93a7d4f65dd161007e8a175b36b208d13939d38cd5dab41f0a446e7d5213aee34c7f07273c4804f49
6
+ metadata.gz: 6f48795cd44788c27a9931a1960e9d5f83d72ab794fd37d5d24b0a3110a1582211f80cdeef4e8cd171183f3ef9ccfec615f60fda46dd480cdaed10856d69a373
7
+ data.tar.gz: 54b9a282d8dc8d0ebca8e5e2b1368a0040ec140c5a793d438fe4891363d74574b31541d9d22aea566f09f8b3284cb7d12c49f071f9dca3cd29bbcd8df9babfbe
data/CHANGELOG.md CHANGED
@@ -5,6 +5,25 @@ 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.0.2 (2024-02-01)
9
+
10
+ [Full Changelog](https://github.com/main-branch/process_executer/compare/v1.0.1..v1.0.2)
11
+
12
+ Changes since v1.0.1:
13
+
14
+ * 76ffb91 An invalid timeout value should raise an ArgumentError (#41)
15
+ * b748819 Release v1.0.1 (#40)
16
+
17
+ ## v1.0.1 (2024-01-04)
18
+
19
+ [Full Changelog](https://github.com/main-branch/process_executer/compare/v1.0.0..v1.0.1)
20
+
21
+ Changes since v1.0.0:
22
+
23
+ * f434aa1 Add an experimental build for jruby-head on windows (#15)
24
+ * 97dbcf5 Make updates resulting from doc review (#38)
25
+ * 93eab18 Release v1.0.0 (#37)
26
+
8
27
  ## v1.0.0 (2023-12-31)
9
28
 
10
29
  [Full Changelog](https://github.com/main-branch/process_executer/compare/v0.7.0..v1.0.0)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'forwardable'
4
4
  require 'ostruct'
5
+ require 'pp'
5
6
 
6
7
  module ProcessExecuter
7
8
  # Validate ProcessExecuter::Executer#spawn options and return Process.spawn options
@@ -27,13 +28,14 @@ module ProcessExecuter
27
28
  close_others chdir
28
29
  ].freeze
29
30
 
30
- # These options are allowed but should NOT be passed to `Process.spawn`
31
+ # These options are allowed by `ProcessExecuter.spawn` but should NOT be passed
32
+ # to `Process.spawn`
31
33
  #
32
34
  NON_SPAWN_OPTIONS = %i[
33
35
  timeout
34
36
  ].freeze
35
37
 
36
- # Any `SPAWN_OPTIONS`` set to this value will not be passed to `Process.spawn`
38
+ # Any `SPAWN_OPTIONS` set to `NOT_SET` will not be passed to `Process.spawn`
37
39
  #
38
40
  NOT_SET = :not_set
39
41
 
@@ -76,7 +78,7 @@ module ProcessExecuter
76
78
  # @param options [Hash] Process.spawn options plus additional options listed below.
77
79
  #
78
80
  # See [Process.spawn](https://ruby-doc.org/core/Process.html#method-c-spawn)
79
- # for a list of valid.
81
+ # for a list of valid options that can be passed to `Process.spawn`.
80
82
  #
81
83
  # @option options [Integer, Float, nil] :timeout
82
84
  # Number of seconds to wait for the process to terminate. Any number
@@ -86,6 +88,7 @@ module ProcessExecuter
86
88
  def initialize(**options)
87
89
  assert_no_unknown_options(options)
88
90
  @options = DEFAULTS.merge(options)
91
+ assert_timeout_is_valid
89
92
  end
90
93
 
91
94
  # Returns the options to be passed to Process.spawn
@@ -129,6 +132,24 @@ module ProcessExecuter
129
132
  raise ArgumentError, "Unknown options: #{unknown_options.join(', ')}" unless unknown_options.empty?
130
133
  end
131
134
 
135
+ # Raise an error if timeout is not a real non-negative number
136
+ # @return [void]
137
+ # @raise [ArgumentError] if timeout is not a real non-negative number
138
+ # @api private
139
+ def assert_timeout_is_valid
140
+ return if @options[:timeout].nil?
141
+ return if @options[:timeout].is_a?(Numeric) && @options[:timeout].real? && !@options[:timeout].negative?
142
+
143
+ raise ArgumentError, invalid_timeout_message
144
+ end
145
+
146
+ # The message to be used when raising an error for an invalid timeout
147
+ # @return [String]
148
+ # @api private
149
+ def invalid_timeout_message
150
+ "timeout must be nil or a real non-negative number but was #{options[:timeout].pretty_inspect}"
151
+ end
152
+
132
153
  # Determine if the given option is a valid option
133
154
  # @param option [Symbol] the option to be tested
134
155
  # @return [Boolean] true if the given option is a valid option
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ProcessExecuter
4
4
  # The current Gem version
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.2'
6
6
  end
@@ -12,7 +12,8 @@ require 'timeout'
12
12
  module ProcessExecuter
13
13
  # Execute the specified command as a subprocess and return the exit status
14
14
  #
15
- # This method blocks until the command has terminated.
15
+ # This is a convenience method that calls Process.spawn and blocks until the
16
+ # command has terminated.
16
17
  #
17
18
  # The command will be send the SIGKILL signal if it does not terminate within
18
19
  # the specified timeout.
@@ -38,7 +39,7 @@ module ProcessExecuter
38
39
  # documentation for valid command and options
39
40
  #
40
41
  # @see ProcessExecuter::Options#initialize See ProcessExecuter::Options#initialize
41
- # for additional options that may be specified
42
+ # for options that may be specified
42
43
  #
43
44
  # @param command [Array<String>] the command to execute
44
45
  # @param options_hash [Hash] the options to use when exectuting the command
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.metadata['homepage_uri'] = spec.homepage
20
20
  spec.metadata['source_code_uri'] = 'https://github.com/main-branch/process_executer'
21
- spec.metadata['changelog_uri'] = 'https://rubydoc.info/gems/process_executer/file/CHANGELOG.md'
21
+ spec.metadata['changelog_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}/file/CHANGELOG.md"
22
+ spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}"
22
23
 
23
24
  # Specify which files should be added to the gem when it is released.
24
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
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.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Couball
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-31 00:00:00.000000000 Z
11
+ date: 2024-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler-audit
@@ -199,7 +199,8 @@ metadata:
199
199
  allowed_push_host: https://rubygems.org
200
200
  homepage_uri: https://github.com/main-branch/process_executer
201
201
  source_code_uri: https://github.com/main-branch/process_executer
202
- changelog_uri: https://rubydoc.info/gems/process_executer/file/CHANGELOG.md
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
204
  rubygems_mfa_required: 'true'
204
205
  post_install_message:
205
206
  rdoc_options: []