local-development-gateway 0.1.1 → 0.1.2
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/README.md +19 -0
- data/lib/local_development_gateway/version.rb +1 -1
- data/lib/local_development_gateway.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f3e2ce5cd6347553a1923006ebc26ff3ae5178e67515d6741014dc229ca115d
|
|
4
|
+
data.tar.gz: 3059913ab2b89ae89442c80112fc49701d31690b46c5ca62bf981042c765700f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6190a1c1563636f2a0a6ca2a08c8acb10c0a674e24551a01cac437a02c70c766ff7f6ec81251d10c086a08f414a43c445cff09095ff5f3a57cadab3580b880d3
|
|
7
|
+
data.tar.gz: 6f04fd1c800964cb0d44e65dc792116ece3fd622cfee945f8a2d49bf7e23165bff95050422e826dad0a4f1e4497d90797c417e87f6569da639c9833c7dd98ca1
|
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
|
|
@@ -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",
|
|
@@ -275,6 +289,10 @@ module LocalDevelopmentGateway
|
|
|
275
289
|
Client.new.ensure_running(*args)
|
|
276
290
|
end
|
|
277
291
|
|
|
292
|
+
def with_running(ensure_running: true, &block)
|
|
293
|
+
Client.new.with_running(ensure_running: ensure_running, &block)
|
|
294
|
+
end
|
|
295
|
+
|
|
278
296
|
def start(*args)
|
|
279
297
|
ensure_running(*args)
|
|
280
298
|
end
|