actioncable-next 0.3.1 → 0.3.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/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/action_cable/channel/test_case.rb +9 -0
- data/lib/action_cable/connection/test_case.rb +38 -3
- data/lib/actioncable-next.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4218440a66ebe42d3a2f0e3acddb8ee929308296e9bef6b7efe6028e1ea00c89
|
|
4
|
+
data.tar.gz: 4474877342a6bb7520ca7b114aed1f0fec551bb2df5d0041bbf445fca3372775
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 22bf0972d72b0b016b620b748c6d5b7aa783e7ad298786c2da92aa47e3af704b5e14aab94c0267375c7a26554dc166e41bc8c47de8b127d32657b3c7b9652a7c
|
|
7
|
+
data.tar.gz: f908764444fb87f16f9d52e693325bfb52469cfec7ef16484f95d984227591b65908b5b1cdafb4fef9818653f4abede75e54567a2d41f6b80e0d6919a09343a2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Add this line to your application's Gemfile **before Rails or Action Cable**:
|
|
|
13
13
|
```ruby
|
|
14
14
|
gem "actioncable-next"
|
|
15
15
|
|
|
16
|
-
gem "rails", "
|
|
16
|
+
gem "rails", ">= 7.0"
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Then, you can use Action Cable as before. Under the hood, the new implementation would be used.
|
|
@@ -238,6 +238,15 @@ module ActionCable
|
|
|
238
238
|
subscription.perform_action(data.stringify_keys.merge("action" => action.to_s))
|
|
239
239
|
end
|
|
240
240
|
|
|
241
|
+
# Advance the virtual clock used by `periodically` timers.
|
|
242
|
+
#
|
|
243
|
+
# subscribe
|
|
244
|
+
# advance_time 5.seconds
|
|
245
|
+
# assert_equal 1, subscription.tick_count
|
|
246
|
+
def advance_time(seconds)
|
|
247
|
+
testserver.advance_time(seconds)
|
|
248
|
+
end
|
|
249
|
+
|
|
241
250
|
# Returns messages transmitted into channel
|
|
242
251
|
def transmissions
|
|
243
252
|
# Return only directly sent message (via #transmit)
|
|
@@ -100,15 +100,44 @@ module ActionCable
|
|
|
100
100
|
def close
|
|
101
101
|
@closed = true
|
|
102
102
|
end
|
|
103
|
+
|
|
104
|
+
def perform_work(receiver, method_name, *args)
|
|
105
|
+
receiver.public_send(method_name, *args)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class TestTimer
|
|
110
|
+
attr_reader :interval
|
|
111
|
+
|
|
112
|
+
def initialize(interval, &block)
|
|
113
|
+
@interval = interval
|
|
114
|
+
@block = block
|
|
115
|
+
@elapsed = 0
|
|
116
|
+
@shutdown = false
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def shutdown
|
|
120
|
+
@shutdown = true
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def advance(seconds)
|
|
124
|
+
return if @shutdown
|
|
125
|
+
@elapsed += seconds
|
|
126
|
+
while @elapsed >= @interval
|
|
127
|
+
@elapsed -= @interval
|
|
128
|
+
@block&.call
|
|
129
|
+
end
|
|
130
|
+
end
|
|
103
131
|
end
|
|
104
132
|
|
|
105
133
|
# TestServer provides test pub/sub and executor implementations
|
|
106
134
|
class TestServer
|
|
107
|
-
attr_reader :streams, :config
|
|
135
|
+
attr_reader :streams, :config, :timers
|
|
108
136
|
|
|
109
137
|
def initialize(server)
|
|
110
138
|
@streams = Hash.new { |h, k| h[k] = [] }
|
|
111
139
|
@config = server.config
|
|
140
|
+
@timers = []
|
|
112
141
|
end
|
|
113
142
|
|
|
114
143
|
alias_method :pubsub, :itself
|
|
@@ -118,8 +147,14 @@ module ActionCable
|
|
|
118
147
|
|
|
119
148
|
# Inline async calls
|
|
120
149
|
def post(&work) = work.call
|
|
121
|
-
|
|
122
|
-
def timer(
|
|
150
|
+
|
|
151
|
+
def timer(every, &block)
|
|
152
|
+
TestTimer.new(every, &block).tap { |t| @timers << t }
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def advance_time(seconds)
|
|
156
|
+
@timers.each { |timer| timer.advance(seconds) }
|
|
157
|
+
end
|
|
123
158
|
|
|
124
159
|
#== Pub/sub interface ==
|
|
125
160
|
def subscribe(stream, callback, success_callback = nil)
|
data/lib/actioncable-next.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: actioncable-next
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pratik Naik
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-04-30 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|
|
@@ -167,7 +167,7 @@ licenses:
|
|
|
167
167
|
- MIT
|
|
168
168
|
metadata:
|
|
169
169
|
bug_tracker_uri: https://github.com/anycable/actioncable-next
|
|
170
|
-
changelog_uri: https://github.com/anycable/actioncable-next/blob/v0.3.
|
|
170
|
+
changelog_uri: https://github.com/anycable/actioncable-next/blob/v0.3.2/CHANGELOG.md
|
|
171
171
|
source_code_uri: https://github.com/anycable/actioncable-next
|
|
172
172
|
rubygems_mfa_required: 'true'
|
|
173
173
|
post_install_message:
|