rage-rb 1.28.0 → 1.28.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbfe0ad2460e5d9f51317d8be527259b500e28de3dd2817fe50017d6d44558fe
4
- data.tar.gz: d55249b98d2daad91122eb8f1a0f47618df0775edeaaee1203576d034fc32a18
3
+ metadata.gz: 73e373fc25e95467aa4a38003efafda30488596a75fb1ad7cd617891a6918962
4
+ data.tar.gz: 4183890376650de1e9133bcbe08ed645e628610629745d20c729e7464cb9ecb3
5
5
  SHA512:
6
- metadata.gz: 3d7a3af0e96961ff51803cb02e4e5d15de02e92d076a76a6cc3f8f27c2e0ae0d6e413f97079db7590a1b476c2feace91795f1ea2c46d01aab1e16ff35581a4b0
7
- data.tar.gz: 77852270e3ef3c276f0941ce346741b69f28595e03ff53d6350ca4e58423b88527baa81701365599b2fbeec3d823b6e816f37772a5c1e7d62f94936c66701db7
6
+ metadata.gz: 4ac0ef8e80416b82f0249675ae98eb973df2e419b12f32521c30933105ad17cef790620a8965eec7c810dc67313d6be4d39e10d05bf937483eeea154c6136088
7
+ data.tar.gz: 10b35efd2ba54aabc8eddc446669e945b530f0f7078899b43d45f8450fd2cf9db6ba746c695b4d2386e300a1adc84d98a2b9a0bd2e86e30d8ecf2f1804dd223f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.28.2] - 2026-10-09
4
+
5
+ - Support `unsubscribe` commands in Action Cable.
6
+ - Gracefully handle requests with no content type.
7
+
3
8
  ## [1.28.0] - 2026-09-15
4
9
 
5
10
  ### Added
@@ -434,11 +434,16 @@ class Rage::Cable::Channel
434
434
  #
435
435
  # @param stream [String] the name of the stream
436
436
  # @raise [ArgumentError] if the stream name is not a String
437
+ # @note Calling {stop_stream_from} in {unsubscribed} is not strictly required, but is important when clients are dynamically subscribing/unsubscribing from channels on a single connection.
437
438
  # @example Subscribe to a stream
438
439
  # class NotificationsChannel < Rage::Cable::Channel
439
440
  # def subscribed
440
441
  # stream_from "notifications"
441
442
  # end
443
+ #
444
+ # def unsubscribed
445
+ # stop_stream_from "notifications"
446
+ # end
442
447
  # end
443
448
  # @example Broadcast to the stream
444
449
  # Rage::Cable.broadcast("notifications", { message: "A new member has joined!" })
@@ -451,11 +456,16 @@ class Rage::Cable::Channel
451
456
  #
452
457
  # @param streamable [#id, String, Symbol, Numeric, Array] an object that will be used to generate the stream name
453
458
  # @raise [ArgumentError] if the streamable object does not satisfy the type requirements
459
+ # @note Calling {stop_stream_for} in {unsubscribed} is not strictly required, but is important when clients are dynamically subscribing/unsubscribing from channels on a single connection.
454
460
  # @example Subscribe to a stream
455
461
  # class NotificationsChannel < Rage::Cable::Channel
456
462
  # def subscribed
457
463
  # stream_for current_user
458
464
  # end
465
+ #
466
+ # def unsubscribed
467
+ # stop_stream_for current_user
468
+ # end
459
469
  # end
460
470
  # @example Broadcast to the stream
461
471
  # NotificationsChannel.broadcast_to(current_user, { message: "You have a new notification!" })
@@ -49,6 +49,7 @@ class Rage::Cable::Protocols::ActioncableV1Json < Rage::Cable::Protocols::Base
49
49
 
50
50
  module COMMAND
51
51
  SUBSCRIBE = "subscribe"
52
+ UNSUBSCRIBE = "unsubscribe"
52
53
  MESSAGE = "message"
53
54
  end
54
55
 
@@ -121,6 +122,9 @@ class Rage::Cable::Protocols::ActioncableV1Json < Rage::Cable::Protocols::Base
121
122
  connection.write(MESSAGES::INVALID)
122
123
  end
123
124
 
125
+ return
126
+ elsif command == COMMAND::UNSUBSCRIBE
127
+ @router.process_disconnection(connection)
124
128
  return
125
129
  end
126
130
 
@@ -13,11 +13,11 @@ class Rage::ParamsParser
13
13
  end
14
14
  end
15
15
 
16
- request_params = if content_type.start_with?("application/json")
16
+ request_params = if content_type&.start_with?("application/json")
17
17
  json_parse(env["rack.input"].tap { |io| io.rewind }.read)
18
- elsif content_type.start_with?("application/x-www-form-urlencoded")
18
+ elsif content_type&.start_with?("application/x-www-form-urlencoded") || content_type.nil?
19
19
  Iodine::Rack::Utils.parse_urlencoded_nested_query(env["rack.input"].tap { |io| io.rewind }.read)
20
- elsif content_type.start_with?("multipart/form-data")
20
+ elsif content_type&.start_with?("multipart/form-data")
21
21
  Iodine::Rack::Utils.parse_multipart(env["rack.input"], content_type)
22
22
  end
23
23
 
data/lib/rage/request.rb CHANGED
@@ -223,6 +223,14 @@ class Rage::Request
223
223
  end
224
224
  end
225
225
 
226
+ # Get the request body stream.
227
+ # @return [IO] the request body stream
228
+ # @example
229
+ # request.body.read # => '{"name":"Rage"}'
230
+ def body
231
+ @env["rack.input"].tap(&:rewind)
232
+ end
233
+
226
234
  private
227
235
 
228
236
  def rack_request
data/lib/rage/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rage
4
- VERSION = "1.28.0"
4
+ VERSION = "1.28.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rage-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.28.0
4
+ version: 1.28.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Samoilov