local-development-gateway 0.1.1 → 0.1.3

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: 70776ca78ffae5950698180364c42f598368971d93dcec7a262088b9a599fde1
4
- data.tar.gz: 4fe4a0b113e7d7f6efd6a30f7d9a537fddd9b215ac5c746f22c5699d7e7a557e
3
+ metadata.gz: 10a939f848cae2b9e243772bb0b71e55f9f4ef7db51df904dbc44dceda981b0f
4
+ data.tar.gz: 0fe2303e0a7452356971343a371a73d897550d2461502bafba85ba81beb8bcba
5
5
  SHA512:
6
- metadata.gz: e6543f1423068cdf0ab5aca3215487ae1a343beea7a583c1031de21357e9d1e7f1690fd20cb9bb73748d15d01cd8c33197c610cc5230c5540f6cda94ca9831ba
7
- data.tar.gz: 5ea9608dd49f657d3ae4de5b8da00752f787b9a08da3e83651eeb6dffb92b41005b93587f97e66e2c5fe9302c1494914b0ab9bd0a6b11bddcfd621afe60e6329
6
+ metadata.gz: 9a5b33aceca3f70ae6d50fe53dd6a398badbde7b2f7869a2099507bd361308843cc8189924cae4adb0c8203afe189c62a002ed694d73cb0efe9bc8089edab92e
7
+ data.tar.gz: '086a30b8f018bf0fd4ce44d410ba5dc23cbb4923d28afd225df171a1c9453a2a3f4cf2a24f8c2a4ed75fb3587f00aa9022cf03c4556a1e73ffc98f269936e95b'
data/README.md CHANGED
@@ -87,6 +87,25 @@ version declared by the gem. The `~> 0.1` constraint follows the consuming
87
87
  project's published Gemfile.
88
88
  The repository's `bin/dev` is only a thin wrapper around this executable API.
89
89
 
90
+ ### Ruby API lifecycle
91
+
92
+ Wrap a command that needs the gateway with the block-oriented helper:
93
+
94
+ ```ruby
95
+ require "local_development_gateway"
96
+
97
+ result = LocalDevelopmentGateway.with_running do
98
+ run_development_command
99
+ end
100
+ ```
101
+
102
+ The helper starts or reuses the gateway before yielding, returns the block's
103
+ result, and conditionally stops an unused gateway afterward. Cleanup also runs
104
+ when the block raises without replacing the original exception. For a shutdown
105
+ command that must not start a missing gateway, pass
106
+ `ensure_running: false`; the block still runs and unused-gateway cleanup is
107
+ attempted.
108
+
90
109
  ## Development checks
91
110
 
92
111
  Install the locked development tools with `bundle install`. Run the Ruby
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LocalDevelopmentGateway
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -94,6 +94,20 @@ module LocalDevelopmentGateway
94
94
  :stopped
95
95
  end
96
96
 
97
+ def with_running(ensure_running: true)
98
+ begin
99
+ self.ensure_running if ensure_running
100
+ yield
101
+ ensure
102
+ block_error = $!
103
+ begin
104
+ stop_if_unused
105
+ rescue StandardError => cleanup_error
106
+ raise cleanup_error unless block_error
107
+ end
108
+ end
109
+ end
110
+
97
111
  def compose(*args, capture: true)
98
112
  @runner.call(
99
113
  "compose",
@@ -174,7 +188,6 @@ module LocalDevelopmentGateway
174
188
  output =
175
189
  @runner.call(
176
190
  "ps",
177
- "--all",
178
191
  "--filter",
179
192
  "network=#{NETWORK_NAME}",
180
193
  "--format",
@@ -275,6 +288,10 @@ module LocalDevelopmentGateway
275
288
  Client.new.ensure_running(*args)
276
289
  end
277
290
 
291
+ def with_running(ensure_running: true, &block)
292
+ Client.new.with_running(ensure_running: ensure_running, &block)
293
+ end
294
+
278
295
  def start(*args)
279
296
  ensure_running(*args)
280
297
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local-development-gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marlen Brunner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-28 00:00:00.000000000 Z
11
+ date: 2026-08-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby API and CLI for starting, monitoring, and conditionally stopping
14
14
  the shared Docker gateway.