tina4ruby 3.13.92 → 3.13.93
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 +1 -1
- data/lib/tina4/cli.rb +14 -7
- data/lib/tina4/health.rb +10 -0
- data/lib/tina4/version.rb +1 -1
- data/lib/tina4.rb +16 -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: f7b916f1f99717b6933e8d4376b760d2c975daefec3b5507d9827480522cfe8f
|
|
4
|
+
data.tar.gz: e800d0a184690267eb84976193744593eea98b2ec355405f15a32214d12e31a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6428126904b059c914f08ca0fc446622a07447075c23e4a20ba12b01f93cf6a5c48454cab6cebfdc98da615f9fbb9ba57d4e3021d6b26d688cb92cdf5a553cb3
|
|
7
|
+
data.tar.gz: 7fb13ab4b8cae5c60ad932ed1a9de7750881381451b294747b6f90441b682dd5658f49394fd29707144fe2e4ae95a5639cb47cc50a6a1a87aae6b4d60eab0e29
|
data/README.md
CHANGED
|
@@ -105,7 +105,7 @@ Tina4 Ruby outperforms Sinatra while delivering **98 features vs ~4**, with zero
|
|
|
105
105
|
|
|
106
106
|
## Cross-Framework Parity
|
|
107
107
|
|
|
108
|
-
Tina4 ships identical features across four languages: same architecture, same conventions, same
|
|
108
|
+
Tina4 ships identical features across four languages: same architecture, same conventions, same 98 features:
|
|
109
109
|
|
|
110
110
|
| | Python | PHP | Ruby | Node.js |
|
|
111
111
|
|---|--------|-----|------|---------|
|
data/lib/tina4/cli.rb
CHANGED
|
@@ -467,12 +467,21 @@ module Tina4
|
|
|
467
467
|
# ── start ─────────────────────────────────────────────────────────────
|
|
468
468
|
|
|
469
469
|
def cmd_start(argv)
|
|
470
|
-
options = { port: nil, host: nil, dev: false, no_browser: false, no_reload: false, production: false
|
|
470
|
+
options = { port: nil, host: nil, dev: false, no_browser: false, no_reload: false, production: false,
|
|
471
|
+
managed: false }
|
|
471
472
|
parser = OptionParser.new do |opts|
|
|
472
473
|
opts.banner = "Usage: tina4ruby start [options]"
|
|
473
474
|
opts.on("-p", "--port PORT", Integer, "Port (default: 7147)") { |v| options[:port] = v }
|
|
474
475
|
opts.on("-h", "--host HOST", "Host (default: 0.0.0.0)") { |v| options[:host] = v }
|
|
475
476
|
opts.on("-d", "--dev", "Enable dev mode with auto-reload") { options[:dev] = true }
|
|
477
|
+
# --managed says the Rust CLI owns this process (it supervises, watches
|
|
478
|
+
# files, and compiles SCSS, so the framework must not duplicate any of
|
|
479
|
+
# it). "managed" was already declared in boolean_flags above, but this
|
|
480
|
+
# parser never accepted it, so `tina4ruby serve --managed` died with
|
|
481
|
+
# OptionParser::InvalidOption -- which is precisely how the Rust CLI
|
|
482
|
+
# invokes PHP. That mismatch is why Ruby could not be launched through
|
|
483
|
+
# the shared launcher the other frameworks use.
|
|
484
|
+
opts.on("--managed", "Running under the tina4 CLI supervisor") { options[:managed] = true }
|
|
476
485
|
opts.on("--production", "Use production server (Puma)") { options[:production] = true }
|
|
477
486
|
opts.on("--no-browser", "Do not open browser on start") { options[:no_browser] = true }
|
|
478
487
|
opts.on("--no-reload", "Disable file watcher / live-reload") { options[:no_reload] = true }
|
|
@@ -502,12 +511,10 @@ module Tina4
|
|
|
502
511
|
root_dir = Dir.pwd
|
|
503
512
|
Tina4.initialize!(root_dir)
|
|
504
513
|
|
|
505
|
-
#
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
# (GET /__frond/live/{name}) so server-rendered live blocks can poll/SSE.
|
|
510
|
-
Tina4::Frond.register_live_endpoint!
|
|
514
|
+
# Built-in routes (health, Frond live). Shared with Tina4.run! so the two
|
|
515
|
+
# entry points cannot drift again -- they did, and app.rb served 404 on
|
|
516
|
+
# /health for it. register! is idempotent, so calling it here is safe.
|
|
517
|
+
Tina4.register_builtin_routes!
|
|
511
518
|
|
|
512
519
|
# Load route files
|
|
513
520
|
load_routes(root_dir)
|
data/lib/tina4/health.rb
CHANGED
|
@@ -16,12 +16,22 @@ module Tina4
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def register!
|
|
19
|
+
# Idempotent by ASKING THE ROUTER, not by remembering. run! and the CLI
|
|
20
|
+
# both call this, and it can run more than once per process. A boolean
|
|
21
|
+
# flag looked equivalent and was not: Router.clear! (every spec, and
|
|
22
|
+
# any re-init) wipes the routes while the flag stays true, so /health
|
|
23
|
+
# silently vanishes for the rest of the run. Querying the router is
|
|
24
|
+
# self-healing -- cleared routes re-register, present ones don't
|
|
25
|
+
# duplicate.
|
|
26
|
+
return if Tina4::Router.find_route("/health", "GET")
|
|
27
|
+
|
|
19
28
|
# Register at the configured path. The legacy "/health" path stays
|
|
20
29
|
# registered for backward-compat.
|
|
21
30
|
Tina4::Router.add("GET", path, method(:handle))
|
|
22
31
|
Tina4::Router.add("GET", "/health", method(:handle)) unless path == "/health"
|
|
23
32
|
end
|
|
24
33
|
|
|
34
|
+
|
|
25
35
|
def handle(_request, response)
|
|
26
36
|
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
27
37
|
uptime = (now - START_TIME).round(2)
|
data/lib/tina4/version.rb
CHANGED
data/lib/tina4.rb
CHANGED
|
@@ -309,6 +309,14 @@ module Tina4
|
|
|
309
309
|
end
|
|
310
310
|
end
|
|
311
311
|
|
|
312
|
+
# The framework's own routes, in ONE place. Both entry points call this:
|
|
313
|
+
# Tina4.run! (app.rb) and the CLI's cmd_start. Anything added here is
|
|
314
|
+
# available however the app was launched -- which is the whole point.
|
|
315
|
+
def register_builtin_routes!
|
|
316
|
+
Tina4::Health.register!
|
|
317
|
+
Tina4::Frond.register_live_endpoint!
|
|
318
|
+
end
|
|
319
|
+
|
|
312
320
|
def run!(root_dir = nil, port: nil, host: nil, debug: nil)
|
|
313
321
|
# Handle legacy call: run!(port: 7147) where root_dir receives the hash
|
|
314
322
|
if root_dir.is_a?(Hash)
|
|
@@ -325,6 +333,14 @@ module Tina4
|
|
|
325
333
|
|
|
326
334
|
initialize!(root_dir) unless @root_dir
|
|
327
335
|
|
|
336
|
+
# Built-in routes. These used to be registered ONLY by the CLI's
|
|
337
|
+
# cmd_start, so an app booted the documented way -- `Tina4.run!` from
|
|
338
|
+
# app.rb, which is exactly what `tina4 init ruby` scaffolds -- served 404
|
|
339
|
+
# on /health while the identical code under `tina4ruby serve` served 200.
|
|
340
|
+
# A container health check pointed at /health therefore failed against a
|
|
341
|
+
# perfectly healthy app.
|
|
342
|
+
register_builtin_routes!
|
|
343
|
+
|
|
328
344
|
host = ENV.fetch("HOST", ENV.fetch("TINA4_HOST", "0.0.0.0"))
|
|
329
345
|
port = ENV.fetch("PORT", ENV.fetch("TINA4_PORT", "7147")).to_i
|
|
330
346
|
|