anycable-rails 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -6
- data/lib/anycable/rails/actioncable/connection.rb +11 -4
- data/lib/anycable/rails/channel_state.rb +9 -2
- data/lib/anycable/rails/compatibility.rb +1 -0
- data/lib/anycable/rails/version.rb +1 -1
- data/lib/generators/anycable/setup/setup_generator.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c58ca24c6710071b8a90eee6a0d84ba9ec3069d0fb86fecebdab3cfba9fe1d3
|
4
|
+
data.tar.gz: f6ca1937e8cf821d3ded458db84cbfc83840ad45af266c04f32388e2ecec621d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ffbcc289fe4be6092c67b9953074f57a976f4375b1ac91408723043e9140e041f2fae83d7c3ac7234aa05651db48be4a663a2812b8a6bf2919fa9fc3c127494
|
7
|
+
data.tar.gz: b22cc5e90dfdc39369efef3feb46628635397313b203e645a042e810342bdbbe7da85ad900f3626a1d99ee85da8b4e9629be398aa68970758aeea78ff8fa95b5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/anycable-rails.svg)](https://rubygems.org/gems/anycable-rails)
|
3
3
|
[![Build](https://github.com/anycable/anycable-rails/workflows/Build/badge.svg)](https://github.com/anycable/anycable-rails/actions)
|
4
4
|
[![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/anycable/Lobby)
|
5
|
-
[![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://docs.anycable.io
|
5
|
+
[![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://docs.anycable.io/#/rails/getting_started)
|
6
6
|
|
7
7
|
# AnyCable Rails
|
8
8
|
|
@@ -14,9 +14,9 @@ You can even use Action Cable in development and not be afraid of [compatibility
|
|
14
14
|
|
15
15
|
**Important** This is a readme for the upcoming v1.0 release. For v0.6.x see the readme from the [0-6-stable](https://github.com/anycable/anycable-rails/tree/0-6-stable) branch.
|
16
16
|
|
17
|
-
|
17
|
+
💾 [Example Application](https://github.com/anycable/anycable_rails_demo)
|
18
18
|
|
19
|
-
📑 [Documentation](https://docs.anycable.io
|
19
|
+
📑 [Documentation](https://docs.anycable.io/#/rails/getting_started).
|
20
20
|
|
21
21
|
<a href="https://evilmartians.com/">
|
22
22
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
@@ -83,17 +83,17 @@ $ bundle exec anycable
|
|
83
83
|
$ RAILS_ENV=production bundle exec anycable
|
84
84
|
```
|
85
85
|
|
86
|
-
And, finally, run AnyCable WebSocket server, e.g. [anycable-go](https://docs.anycable.io/
|
86
|
+
And, finally, run AnyCable WebSocket server, e.g. [anycable-go](https://docs.anycable.io/#/v1/anycable-go/getting_started):
|
87
87
|
|
88
88
|
```sh
|
89
89
|
anycable-go --host=localhost --port=3334
|
90
90
|
```
|
91
91
|
|
92
|
-
See [documentation](https://docs.anycable.io
|
92
|
+
See [documentation](https://docs.anycable.io/#/rails/getting_started) for more information on AnyCable + Rails usage.
|
93
93
|
|
94
94
|
## Action Cable Compatibility
|
95
95
|
|
96
|
-
See [documentation](https://docs.anycable.io
|
96
|
+
See [documentation](https://docs.anycable.io/#/rails/compatibility).
|
97
97
|
|
98
98
|
## Contributing
|
99
99
|
|
@@ -31,7 +31,7 @@ module ActionCable
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def initialize(socket, env, identifiers: "{}", subscriptions:
|
34
|
+
def initialize(socket, env, identifiers: "{}", subscriptions: nil)
|
35
35
|
if env
|
36
36
|
# If env is set, then somehow we're in the context of Action Cable
|
37
37
|
# Return and print a warning in #process
|
@@ -51,8 +51,15 @@ module ActionCable
|
|
51
51
|
@socket = socket
|
52
52
|
@subscriptions = ActionCable::Connection::Subscriptions.new(self)
|
53
53
|
|
54
|
-
|
55
|
-
|
54
|
+
return unless subscriptions
|
55
|
+
|
56
|
+
# Initialize channels (for disconnect)
|
57
|
+
subscriptions.each do |id|
|
58
|
+
channel = @subscriptions.fetch(id)
|
59
|
+
next unless socket.istate[id]
|
60
|
+
|
61
|
+
channel.__istate__ = ActiveSupport::JSON.decode(socket.istate[id])
|
62
|
+
end
|
56
63
|
end
|
57
64
|
|
58
65
|
def process
|
@@ -64,7 +71,7 @@ module ActionCable
|
|
64
71
|
|
65
72
|
def invalid_request_message
|
66
73
|
"You're trying to connect to Action Cable server while using AnyCable. " \
|
67
|
-
"See https://docs.anycable.io
|
74
|
+
"See https://docs.anycable.io/#/troubleshooting?id=server-raises-an-argumenterror-exception-when-client-tries-to-connect"
|
68
75
|
end
|
69
76
|
|
70
77
|
def handle_open
|
@@ -10,11 +10,11 @@ module AnyCable
|
|
10
10
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
11
11
|
def #{name}
|
12
12
|
return @#{name} if instance_variable_defined?(:@#{name})
|
13
|
-
@#{name} = AnyCable::Rails.deserialize(
|
13
|
+
@#{name} = AnyCable::Rails.deserialize(__istate__["#{name}"], json: true) if connection.anycable_socket
|
14
14
|
end
|
15
15
|
|
16
16
|
def #{name}=(val)
|
17
|
-
|
17
|
+
__istate__["#{name}"] = AnyCable::Rails.serialize(val, json: true) if connection.anycable_socket
|
18
18
|
instance_variable_set(:@#{name}, val)
|
19
19
|
end
|
20
20
|
RUBY
|
@@ -36,6 +36,13 @@ module AnyCable
|
|
36
36
|
def self.included(base)
|
37
37
|
base.extend ClassMethods
|
38
38
|
end
|
39
|
+
|
40
|
+
# Make it possible to provide istate explicitly for a channel instance
|
41
|
+
attr_writer :__istate__
|
42
|
+
|
43
|
+
def __istate__
|
44
|
+
@__istate__ ||= connection.socket.istate
|
45
|
+
end
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
@@ -8,7 +8,7 @@ module AnyCableRailsGenerators
|
|
8
8
|
namespace "anycable:setup"
|
9
9
|
source_root File.expand_path("templates", __dir__)
|
10
10
|
|
11
|
-
DOCS_ROOT = "https://docs.anycable.io
|
11
|
+
DOCS_ROOT = "https://docs.anycable.io/#"
|
12
12
|
DEVELOPMENT_METHODS = %w[skip local docker].freeze
|
13
13
|
SERVER_SOURCES = %w[skip brew binary].freeze
|
14
14
|
|
@@ -118,7 +118,7 @@ module AnyCableRailsGenerators
|
|
118
118
|
def stimulus_reflex
|
119
119
|
return unless stimulus_reflex?
|
120
120
|
|
121
|
-
say_status :help, "⚠️ Please, check out the documentation on using AnyCable with Stimulus Reflex: https://docs.anycable.io
|
121
|
+
say_status :help, "⚠️ Please, check out the documentation on using AnyCable with Stimulus Reflex: https://docs.anycable.io/#/rails/stimulus_reflex"
|
122
122
|
end
|
123
123
|
|
124
124
|
def rubocop_compatibility
|
@@ -126,7 +126,7 @@ module AnyCableRailsGenerators
|
|
126
126
|
|
127
127
|
say_status :info, "🤖 Running static compatibility checks with RuboCop"
|
128
128
|
res = run "bundle exec rubocop -r 'anycable/rails/compatibility/rubocop' --only AnyCable/InstanceVars,AnyCable/PeriodicalTimers,AnyCable/InstanceVars"
|
129
|
-
say_status :help, "⚠️ Please, take a look at the icompatibilities above and fix them. See https://docs.anycable.io
|
129
|
+
say_status :help, "⚠️ Please, take a look at the icompatibilities above and fix them. See https://docs.anycable.io/#/rails/compatibility" unless res
|
130
130
|
end
|
131
131
|
|
132
132
|
def finish
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anycable-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anycable
|