philiprehberger-task_runner 0.2.0 → 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: ac71950b0f8ccde0b9330b8962d7513e3f630bf12e7bd2b442f3dbacc4176c5d
4
- data.tar.gz: 4233518a744a4cce5303b43885eeba5fe1eeea69792734ec238f301ffbfab4aa
3
+ metadata.gz: 590a04ed4c85ae234b9a0d43827629228ad40905b4519de722ccface3b4c1a94
4
+ data.tar.gz: dff5e1dc4852a48dcd6baec3355ad54294854bae050663ec72383dd23705e49b
5
5
  SHA512:
6
- metadata.gz: 7af1c5084052976871ef648652fc5f739c27eebb91c04419a6762bad3c554a37b499637585fa3c58018f8751bf07cef5b05a9b7221933ad198b6c98b213243a2
7
- data.tar.gz: e42e5cd9fbdcd1e18d0738a2e53d7d77daba4a54fd4de915364bc889efe86c2faeb023024e366ffd0a6e1bab5fef800744711e0a31d2986d032e7fff329398fd
6
+ metadata.gz: ad0d734a2a0e763e6f8bff1fd0baf02c0351be84f73e3fd7b40fd9846f751c9b73d9c77fda9e3149aea65c3f3b31fbc66e1d3002b3c84b030c726d4b6085eac7
7
+ data.tar.gz: a1794ab2ad9d37557c340d91c70d7167fb4befe9d9b5dc0195daaedae951c0a154c60f8704aed4563eba651ce5a5bd92f06bf994e1795e51de4dd7c14d8fff01
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.3.0] - 2026-04-09
11
+
12
+ ### Added
13
+ - `TaskRunner.run!` raises `CommandError` on non-zero exit code (same API as `run`)
14
+ - `CommandError#result` exposes the full `Result` object for inspection
15
+ - `Result#to_h` for hash serialization of command results
16
+
17
+ ## [0.2.1] - 2026-03-31
18
+
19
+ ### Changed
20
+ - Standardize README badges, support section, and license format
21
+
10
22
  ## [0.2.0] - 2026-03-30
11
23
 
12
24
  ### Added
data/README.md CHANGED
@@ -2,12 +2,7 @@
2
2
 
3
3
  [![Tests](https://github.com/philiprehberger/rb-task-runner/actions/workflows/ci.yml/badge.svg)](https://github.com/philiprehberger/rb-task-runner/actions/workflows/ci.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/philiprehberger-task_runner.svg)](https://rubygems.org/gems/philiprehberger-task_runner)
5
- [![GitHub release](https://img.shields.io/github/v/release/philiprehberger/rb-task-runner)](https://github.com/philiprehberger/rb-task-runner/releases)
6
5
  [![Last updated](https://img.shields.io/github/last-commit/philiprehberger/rb-task-runner)](https://github.com/philiprehberger/rb-task-runner/commits/main)
7
- [![License](https://img.shields.io/github/license/philiprehberger/rb-task-runner)](LICENSE)
8
- [![Bug Reports](https://img.shields.io/github/issues/philiprehberger/rb-task-runner/bug)](https://github.com/philiprehberger/rb-task-runner/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
9
- [![Feature Requests](https://img.shields.io/github/issues/philiprehberger/rb-task-runner/enhancement)](https://github.com/philiprehberger/rb-task-runner/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
10
- [![Sponsor](https://img.shields.io/badge/sponsor-GitHub%20Sponsors-ec6cb9)](https://github.com/sponsors/philiprehberger)
11
6
 
12
7
  Shell command runner with output capture, timeout, streaming, signal handling, and stdin piping
13
8
 
@@ -41,6 +36,21 @@ puts result.success? # => true
41
36
  puts result.duration # => 0.012
42
37
  ```
43
38
 
39
+ ### Raising on Failure
40
+
41
+ ```ruby
42
+ # Raises CommandError if the command exits non-zero
43
+ result = Philiprehberger::TaskRunner.run!('make', 'build')
44
+
45
+ # The error includes the full Result for inspection
46
+ begin
47
+ Philiprehberger::TaskRunner.run!('false')
48
+ rescue Philiprehberger::TaskRunner::CommandError => e
49
+ puts e.message # => "command exited with code 1"
50
+ puts e.result.stderr # => captured stderr
51
+ end
52
+ ```
53
+
44
54
  ### Timeout
45
55
 
46
56
  ```ruby
@@ -104,6 +114,8 @@ end
104
114
  | Method / Class | Description |
105
115
  |----------------|-------------|
106
116
  | `.run(cmd, *args, timeout:, env:, chdir:, signal:, kill_after:, stdin:)` | Run a command and return a Result |
117
+ | `.run!(cmd, *args, **opts)` | Same as `run`, raises `CommandError` on non-zero exit |
118
+ | `CommandError#result` | The failed `Result` object |
107
119
  | `.run(cmd) { \|line\| ... }` | Run with line-by-line stdout streaming |
108
120
  | `.run(cmd) { \|line, stream\| ... }` | Run with stdout and stderr streaming |
109
121
  | `Result#stdout` | Captured standard output |
@@ -112,6 +124,7 @@ end
112
124
  | `Result#success?` | Whether exit code is 0 |
113
125
  | `Result#duration` | Execution time in seconds |
114
126
  | `Result#signal` | Signal that killed the process (:TERM, :KILL, or nil) |
127
+ | `Result#to_h` | Hash representation of the result |
115
128
 
116
129
  ## Development
117
130
 
@@ -123,10 +136,21 @@ bundle exec rubocop
123
136
 
124
137
  ## Support
125
138
 
126
- If you find this package useful, consider giving it a star on GitHub — it helps motivate continued maintenance and development.
139
+ If you find this project useful:
140
+
141
+ ⭐ [Star the repo](https://github.com/philiprehberger/rb-task-runner)
142
+
143
+ 🐛 [Report issues](https://github.com/philiprehberger/rb-task-runner/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
144
+
145
+ 💡 [Suggest features](https://github.com/philiprehberger/rb-task-runner/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
146
+
147
+ ❤️ [Sponsor development](https://github.com/sponsors/philiprehberger)
148
+
149
+ 🌐 [All Open Source Projects](https://philiprehberger.com/open-source-packages)
150
+
151
+ 💻 [GitHub Profile](https://github.com/philiprehberger)
127
152
 
128
- [![LinkedIn](https://img.shields.io/badge/Philip%20Rehberger-LinkedIn-0A66C2?logo=linkedin)](https://www.linkedin.com/in/philiprehberger)
129
- [![More packages](https://img.shields.io/badge/more-open%20source%20packages-blue)](https://philiprehberger.com/open-source-packages)
153
+ 🔗 [LinkedIn Profile](https://www.linkedin.com/in/philiprehberger)
130
154
 
131
155
  ## License
132
156
 
@@ -38,6 +38,20 @@ module Philiprehberger
38
38
  def success?
39
39
  @exit_code.zero?
40
40
  end
41
+
42
+ # Hash representation of the result.
43
+ #
44
+ # @return [Hash]
45
+ def to_h
46
+ {
47
+ stdout: @stdout,
48
+ stderr: @stderr,
49
+ exit_code: @exit_code,
50
+ duration: @duration,
51
+ signal: @signal,
52
+ success: success?
53
+ }
54
+ end
41
55
  end
42
56
  end
43
57
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module TaskRunner
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -11,6 +11,17 @@ module Philiprehberger
11
11
  class Error < StandardError; end
12
12
  class TimeoutError < Error; end
13
13
 
14
+ # Raised by run! when the command exits with a non-zero status.
15
+ class CommandError < Error
16
+ # @return [Result] the failed command result
17
+ attr_reader :result
18
+
19
+ def initialize(result)
20
+ @result = result
21
+ super("command exited with code #{result.exit_code}")
22
+ end
23
+ end
24
+
14
25
  # Run a shell command with output capture, optional timeout, streaming, signal handling, and stdin piping.
15
26
  #
16
27
  # When a block is given, each line of stdout/stderr is yielded as it arrives.
@@ -45,6 +56,20 @@ module Philiprehberger
45
56
  end
46
57
  end
47
58
 
59
+ # Run a shell command, raising CommandError on non-zero exit.
60
+ #
61
+ # Accepts the same arguments as {.run}.
62
+ #
63
+ # @return [Result] the command result
64
+ # @raise [CommandError] if the command exits with a non-zero status
65
+ # @raise [TimeoutError] if the command exceeds the timeout
66
+ def self.run!(cmd, ...)
67
+ result = run(cmd, ...)
68
+ raise CommandError, result unless result.success?
69
+
70
+ result
71
+ end
72
+
48
73
  # @api private
49
74
  def self.run_capture(env_hash, full_cmd, spawn_opts, timeout, start_time, signal, kill_after, stdin_data)
50
75
  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.2.0
4
+ version: 0.3.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-03-30 00:00:00.000000000 Z
11
+ date: 2026-04-10 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
@@ -25,11 +25,11 @@ files:
25
25
  - lib/philiprehberger/task_runner.rb
26
26
  - lib/philiprehberger/task_runner/result.rb
27
27
  - lib/philiprehberger/task_runner/version.rb
28
- homepage: https://github.com/philiprehberger/rb-task-runner
28
+ homepage: https://philiprehberger.com/open-source-packages/ruby/philiprehberger-task_runner
29
29
  licenses:
30
30
  - MIT
31
31
  metadata:
32
- homepage_uri: https://github.com/philiprehberger/rb-task-runner
32
+ homepage_uri: https://philiprehberger.com/open-source-packages/ruby/philiprehberger-task_runner
33
33
  source_code_uri: https://github.com/philiprehberger/rb-task-runner
34
34
  changelog_uri: https://github.com/philiprehberger/rb-task-runner/blob/main/CHANGELOG.md
35
35
  bug_tracker_uri: https://github.com/philiprehberger/rb-task-runner/issues