hotsock-turbo 0.1.0 → 0.2.0

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: acb980991920b0cf9f918c2eb1415f7236cd68a1b7d32ef32fb23e61ef123ec1
4
- data.tar.gz: 501175af602730032c80b888b419050d3dd9f95258e9c6d3b96c850c91b583e9
3
+ metadata.gz: 9b34d411b6586100a7331fb9a42bcdbe06410cffc9d0657fed5834a973a30324
4
+ data.tar.gz: 1ce7d77b5026c991d42d4d8f4f6e0c3928d6df72b3ac906feefd12624f0a8043
5
5
  SHA512:
6
- metadata.gz: d4f52b687ea9e85db973edad805dac02761ec3f0c1ec602c36473c13a7c38dafd51f6b864004cad85f9db5dd6230d11d0236bf3445e97f6b5ba7b20a74405017
7
- data.tar.gz: 509e133c9a296026acaf7ed40ed161075c688c08da13a9a6379208dbe5317c18cb9932fcf4a561d6feff8285e5f2958f15a55c6f0895dda5f2895236890b3dca
6
+ metadata.gz: 045abe5e27e4ee970f3655702ba4d4c6f0b9abdd3573d75ed85dab4cf081847334f09e41b8ed6d40f296f5bbaabb979fc774cdd27d2b399eac03a234fc126758
7
+ data.tar.gz: 8c119eb0cedfd340810fb279817126234baf8b01800afb6943fa1631b6e3880ce9fcbfc3f30a18b93cff3d94873c48c198fc63ab1f1ee984456c8c840d74f762
data/README.md CHANGED
@@ -96,6 +96,7 @@ end
96
96
  | `log_level` | `"warn"` | JavaScript client log level (`"debug"`, `"info"`, `"warn"`, `"error"`) |
97
97
  | `parent_controller` | `"ApplicationController"` | Base controller for generated routes |
98
98
  | `override_turbo_broadcastable` | `false` | When `true`, overrides standard Turbo broadcast methods to use Hotsock |
99
+ | `suppress_broadcasts` | `false` | When `true`, suppresses all Hotsock turbo broadcasts globally |
99
100
 
100
101
  ## Usage
101
102
 
@@ -273,6 +274,17 @@ message.broadcast_replace_later_to(board)
273
274
 
274
275
  ### Suppressing Broadcasts
275
276
 
277
+ #### Global Suppression (Test Environments)
278
+
279
+ Disable all broadcasts globally, useful for test environments where you don't want to require a Hotsock configuration:
280
+
281
+ ```ruby
282
+ # config/environments/test.rb
283
+ Hotsock::Turbo.config.suppress_broadcasts = true
284
+ ```
285
+
286
+ #### Block-based Suppression
287
+
276
288
  Temporarily disable broadcasts within a block:
277
289
 
278
290
  ```ruby
@@ -3,7 +3,7 @@
3
3
  module Hotsock
4
4
  module Turbo
5
5
  class Config
6
- attr_accessor :parent_controller, :connect_token_path, :wss_url, :log_level, :override_turbo_broadcastable
6
+ attr_accessor :parent_controller, :connect_token_path, :wss_url, :log_level, :override_turbo_broadcastable, :suppress_broadcasts
7
7
 
8
8
  def initialize
9
9
  @parent_controller = "ApplicationController"
@@ -11,6 +11,7 @@ module Hotsock
11
11
  @wss_url = nil
12
12
  @log_level = "warn"
13
13
  @override_turbo_broadcastable = false
14
+ @suppress_broadcasts = false
14
15
  end
15
16
  end
16
17
  end
@@ -74,6 +74,8 @@ module Hotsock
74
74
  end
75
75
 
76
76
  def self.broadcast_to(stream_or_streamable, content, options = {})
77
+ return if Hotsock::Turbo.config.suppress_broadcasts
78
+
77
79
  unless enabled?
78
80
  fail "Turbo Streams is not enabled. Please install turbo-rails to use this method."
79
81
  end
@@ -145,11 +147,15 @@ module Hotsock
145
147
  end
146
148
 
147
149
  def self.broadcast_refresh_later_to(*streamables, request_id: nil)
150
+ return if Hotsock::Turbo.config.suppress_broadcasts
151
+
148
152
  stream_name = serialize_broadcasting(streamables)
149
153
  Hotsock::Turbo::BroadcastRefreshJob.perform_later(stream_name, request_id: request_id)
150
154
  end
151
155
 
152
156
  def self.broadcast_action_later_to(*streamables, action:, target: nil, targets: nil, attributes: {}, **rendering)
157
+ return if Hotsock::Turbo.config.suppress_broadcasts
158
+
153
159
  stream_name = serialize_broadcasting(streamables)
154
160
  Hotsock::Turbo::ActionBroadcastJob.perform_later(
155
161
  stream_name,
@@ -194,6 +200,8 @@ module Hotsock
194
200
  end
195
201
 
196
202
  def self.broadcast_render_later_to(*streamables, **rendering)
203
+ return if Hotsock::Turbo.config.suppress_broadcasts
204
+
197
205
  stream_name = serialize_broadcasting(streamables)
198
206
  Hotsock::Turbo::BroadcastJob.perform_later(stream_name, **rendering)
199
207
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hotsock
4
4
  module Turbo
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotsock-turbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Miller