philiprehberger-task_runner 0.3.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +13 -1
- data/lib/philiprehberger/task_runner/result.rb +18 -1
- data/lib/philiprehberger/task_runner/version.rb +1 -1
- data/lib/philiprehberger/task_runner.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e264781c1fb8c863a53e85b4d6b80f4bc1644a27bbeb17446473719d5efc10c
|
|
4
|
+
data.tar.gz: d7b4719dab1483d43ec494ac3aa00718ecfd6d408b9241c21cbbd7695e4bce2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ea18413fb9724653c6621d57f24af1384567aa5361ea3ae4d9ba165f97d5685644d8b45c2ad2cc9e2537db2e9e19f223b4983c94bd2514640c325c8422a46dd
|
|
7
|
+
data.tar.gz: bd148577cae30e1bb877622f60cdfda40887bee65653a5568c6b6faa420f37cf38bfe95d6d8317508a7a6502c3c67395a242218f6731d16227d338266131c862
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.5.0] - 2026-04-21
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `TaskRunner.run?` — Boolean convenience returning true only when the command exits with status 0; swallows `TimeoutError` as `false`
|
|
14
|
+
|
|
15
|
+
## [0.4.0] - 2026-04-20
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- `Result#failure?` — logical inverse of `#success?` for clearer branching
|
|
19
|
+
- `Result#timed_out?` — true when the process was killed by the task runner for exceeding its timeout (`:TERM` or `:KILL` signal)
|
|
20
|
+
- `:timed_out` key added to `Result#to_h` alongside the existing `:success` flag
|
|
21
|
+
|
|
10
22
|
## [0.3.0] - 2026-04-09
|
|
11
23
|
|
|
12
24
|
### Added
|
data/README.md
CHANGED
|
@@ -51,6 +51,15 @@ rescue Philiprehberger::TaskRunner::CommandError => e
|
|
|
51
51
|
end
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
### Boolean Success Check
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
# Returns true for exit 0, false otherwise (timeouts also return false)
|
|
58
|
+
if Philiprehberger::TaskRunner.run?('which', 'git')
|
|
59
|
+
puts 'git is installed'
|
|
60
|
+
end
|
|
61
|
+
```
|
|
62
|
+
|
|
54
63
|
### Timeout
|
|
55
64
|
|
|
56
65
|
```ruby
|
|
@@ -115,6 +124,7 @@ end
|
|
|
115
124
|
|----------------|-------------|
|
|
116
125
|
| `.run(cmd, *args, timeout:, env:, chdir:, signal:, kill_after:, stdin:)` | Run a command and return a Result |
|
|
117
126
|
| `.run!(cmd, *args, **opts)` | Same as `run`, raises `CommandError` on non-zero exit |
|
|
127
|
+
| `.run?(cmd, *args, **opts)` | Boolean shortcut — true only when exit code is 0; timeouts return false |
|
|
118
128
|
| `CommandError#result` | The failed `Result` object |
|
|
119
129
|
| `.run(cmd) { \|line\| ... }` | Run with line-by-line stdout streaming |
|
|
120
130
|
| `.run(cmd) { \|line, stream\| ... }` | Run with stdout and stderr streaming |
|
|
@@ -122,9 +132,11 @@ end
|
|
|
122
132
|
| `Result#stderr` | Captured standard error |
|
|
123
133
|
| `Result#exit_code` | Process exit code |
|
|
124
134
|
| `Result#success?` | Whether exit code is 0 |
|
|
135
|
+
| `Result#failure?` | Logical inverse of `#success?` |
|
|
125
136
|
| `Result#duration` | Execution time in seconds |
|
|
126
137
|
| `Result#signal` | Signal that killed the process (:TERM, :KILL, or nil) |
|
|
127
|
-
| `Result#
|
|
138
|
+
| `Result#timed_out?` | Whether the process was killed for exceeding its timeout |
|
|
139
|
+
| `Result#to_h` | Hash representation of the result (includes `:success` and `:timed_out`) |
|
|
128
140
|
|
|
129
141
|
## Development
|
|
130
142
|
|
|
@@ -39,6 +39,22 @@ module Philiprehberger
|
|
|
39
39
|
@exit_code.zero?
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# Whether the command exited with a non-zero status, was killed by a
|
|
43
|
+
# signal, or timed out. The logical inverse of {#success?}.
|
|
44
|
+
#
|
|
45
|
+
# @return [Boolean]
|
|
46
|
+
def failure?
|
|
47
|
+
!success?
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Whether the command was terminated by the task runner because it
|
|
51
|
+
# exceeded its timeout (SIGTERM or SIGKILL).
|
|
52
|
+
#
|
|
53
|
+
# @return [Boolean]
|
|
54
|
+
def timed_out?
|
|
55
|
+
%i[TERM KILL].include?(@signal)
|
|
56
|
+
end
|
|
57
|
+
|
|
42
58
|
# Hash representation of the result.
|
|
43
59
|
#
|
|
44
60
|
# @return [Hash]
|
|
@@ -49,7 +65,8 @@ module Philiprehberger
|
|
|
49
65
|
exit_code: @exit_code,
|
|
50
66
|
duration: @duration,
|
|
51
67
|
signal: @signal,
|
|
52
|
-
success: success
|
|
68
|
+
success: success?,
|
|
69
|
+
timed_out: timed_out?
|
|
53
70
|
}
|
|
54
71
|
end
|
|
55
72
|
end
|
|
@@ -70,6 +70,17 @@ module Philiprehberger
|
|
|
70
70
|
result
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
+
# Boolean convenience — run the command and return whether it succeeded
|
|
74
|
+
# (exit code 0). Swallows `TimeoutError` (reported as false). Accepts the
|
|
75
|
+
# same arguments as {.run}.
|
|
76
|
+
#
|
|
77
|
+
# @return [Boolean] true if the command exited with status 0
|
|
78
|
+
def self.run?(cmd, ...)
|
|
79
|
+
run(cmd, ...).success?
|
|
80
|
+
rescue TimeoutError
|
|
81
|
+
false
|
|
82
|
+
end
|
|
83
|
+
|
|
73
84
|
# @api private
|
|
74
85
|
def self.run_capture(env_hash, full_cmd, spawn_opts, timeout, start_time, signal, kill_after, stdin_data)
|
|
75
86
|
stdout_buf = +''
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: philiprehberger-task_runner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Rehberger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Run shell commands with captured stdout/stderr, exit code, duration measurement,
|
|
14
14
|
configurable timeout, environment variables, line-by-line streaming, graceful signal
|