tina4ruby 3.10.68 → 3.10.70

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: 616f1c89797014131b2b43e8c7b5a9ca6f95ddb20627375e82043c8c2fd26698
4
- data.tar.gz: f846cc82475f82545be62e916eb7bf9cc38acf6b00792bc4453da4a46b39abfb
3
+ metadata.gz: 3f06a2255a534d40f28782434bddf172642b0d1b620a47c6d7474e2be64310ae
4
+ data.tar.gz: dcd8f0b4d62a0a6cbb9cbaf1005d1dde8175ff06efc1c42c4fd0ea0750253915
5
5
  SHA512:
6
- metadata.gz: e4a317f3c88f2353a6a59312c02d50a130eac8b25b4925bb03160d54c2792012069fc84f0edef0c12510447f7e391e5e54a0af98edb91b57a3797a78d58b7584
7
- data.tar.gz: 646e0e66ec3cb40f91c7a9978ee8e3ce35149740696872a078bf6b8b1f50bb5e1365640e3aa289eba035d78d877f851b4afc716f3337a905c5bc144282f0e8d1
6
+ metadata.gz: 40f1bd5b474dded10a2551d4f7384973b44bdb5779b3fadcbd86977ef46a199f16c3e1aa9b4fd82408f9b3286491cd42c274181e019d0de55f44a85772e30a29
7
+ data.tar.gz: df3b82c1d8bbc2ac80b7aed0980d3167c1feca0cdcb66a39614c8ee3b066e133bab0edc97d668218e06c122cc4e20be371089695c056624e3919651f92327028
@@ -205,20 +205,50 @@ module Tina4
205
205
  self
206
206
  end
207
207
 
208
+ # Stream response from a block for Server-Sent Events (SSE).
209
+ #
210
+ # Usage:
211
+ # Tina4::Router.get "/events" do |request, response|
212
+ # response.stream do |out|
213
+ # 10.times do |i|
214
+ # out << "data: message #{i}\n\n"
215
+ # sleep 1
216
+ # end
217
+ # end
218
+ # end
219
+ #
220
+ # @param content_type [String] Content type (default: text/event-stream)
221
+ # @yield [Enumerator::Yielder] Block receives a yielder to push chunks
222
+ # @return [self]
223
+ def stream(content_type: "text/event-stream", &block)
224
+ @status_code = @status_code || 200
225
+ @headers["content-type"] = content_type
226
+ @headers["cache-control"] = "no-cache"
227
+ @headers["connection"] = "keep-alive"
228
+ @headers["x-accel-buffering"] = "no"
229
+ @_streaming = true
230
+ @_stream_block = block
231
+ self
232
+ end
233
+
208
234
  # Flush / finalize -- alias for to_rack for semantic clarity
209
235
  def send
210
236
  to_rack
211
237
  end
212
238
 
213
239
  def to_rack
214
- # Fast path: no cookies (99% of API responses)
215
- if @cookies.nil? || @cookies.empty?
216
- return [@status_code, @headers, [@body.to_s]]
240
+ final_headers = @headers.dup
241
+ final_headers["set-cookie"] = @cookies.join("\n") if @cookies && !@cookies.empty?
242
+
243
+ if @_streaming
244
+ # Streaming mode — return an Enumerator as the body
245
+ body = Enumerator.new do |yielder|
246
+ @_stream_block.call(yielder)
247
+ end
248
+ return [@status_code, final_headers, body]
217
249
  end
218
250
 
219
- # Cookie path
220
- final_headers = @headers.dup
221
- final_headers["set-cookie"] = @cookies.join("\n")
251
+ # Normal buffered response
222
252
  [@status_code, final_headers, [@body.to_s]]
223
253
  end
224
254
 
data/lib/tina4/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tina4
4
- VERSION = "3.10.68"
4
+ VERSION = "3.10.70"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.68
4
+ version: 3.10.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-03 00:00:00.000000000 Z
11
+ date: 2026-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack