anycable-rails 1.1.1 → 1.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 +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +4 -3
- data/lib/anycable/rails/actioncable/connection.rb +0 -2
- data/lib/anycable/rails/actioncable/testing.rb +1 -1
- data/lib/anycable/rails/channel_state.rb +57 -2
- data/lib/anycable/rails/version.rb +1 -1
- data/lib/generators/anycable/setup/setup_generator.rb +18 -2
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6502d9587bfab38ed0e12416741885869551926e2d8fae5282cca66ca59e97cf
|
4
|
+
data.tar.gz: 7c16519ba1a470e68fbcf0d5baaa261df245d64618277f8b4b2992821d543d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbfe72bae1b477034e32f7bb85e3c936bef3caf03db7d54cfe126e2cccbd7cc24494ec8cd7718887f9a56a41d3dab10ec24cf30ca6c7de0bd162e1658aa143f9
|
7
|
+
data.tar.gz: ba01f329e4388d4257952592f214842214432e9c211261362bf530913ace6eb3b9bc74bf2bab3e8a9446b6d7e48b9dd54a82bc44f21276506b9c743403e0afae
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,28 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.2.0 (2021-12-21) 🎄
|
6
|
+
|
7
|
+
- Drop Rails 5 support.
|
8
|
+
|
9
|
+
- Drop Ruby 2.6 support.
|
10
|
+
|
11
|
+
## 1.1.4 (2021-11-11)
|
12
|
+
|
13
|
+
- Added `Connection#state_attr_accessor`. ([@palkan][])
|
14
|
+
|
15
|
+
## 1.1.3 (2021-10-11)
|
16
|
+
|
17
|
+
- Relax Action Cable dependency. ([@palkan][])
|
18
|
+
|
19
|
+
Action Cable 5.1 is allowed (though not recommended).
|
20
|
+
|
21
|
+
## 1.1.2 (2021-06-23)
|
22
|
+
|
23
|
+
- Bring back dependency on `anycable` (instead of `anycable-core`). ([@palkan][])
|
24
|
+
|
25
|
+
Make it easier to get started by adding just a single gem.
|
26
|
+
|
5
27
|
## 1.1.1 (2021-06-08)
|
6
28
|
|
7
29
|
- Updated documentation links in the generator. ([@palkan][])
|
data/README.md
CHANGED
@@ -15,21 +15,22 @@ You can even use Action Cable in development and not be afraid of [compatibility
|
|
15
15
|
|
16
16
|
📑 [Documentation](https://docs.anycable.io/rails/getting_started).
|
17
17
|
|
18
|
+
> [AnyCable Pro](https://docs.anycable.io/pro) has been launched 🚀
|
19
|
+
|
18
20
|
<a href="https://evilmartians.com/">
|
19
21
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
20
22
|
|
21
23
|
## Requirements
|
22
24
|
|
23
25
|
- Ruby >= 2.6
|
24
|
-
- Rails >= 6.0
|
26
|
+
- Rails >= 6.0 (Rails 5.1 could work but we're no longer enforce compatibility on CI)
|
25
27
|
- Redis (see [other options](https://github.com/anycable/anycable/issues/2) for broadcasting)
|
26
28
|
|
27
29
|
## Usage
|
28
30
|
|
29
|
-
Add `anycable-rails`
|
31
|
+
Add `anycable-rails` gem to your Gemfile:
|
30
32
|
|
31
33
|
```ruby
|
32
|
-
gem "anycable"
|
33
34
|
gem "anycable-rails"
|
34
35
|
|
35
36
|
# when using Redis broadcast adapter
|
@@ -9,7 +9,6 @@ require "anycable/rails/session_proxy"
|
|
9
9
|
|
10
10
|
module ActionCable
|
11
11
|
module Connection
|
12
|
-
# rubocop: disable Metrics/ClassLength
|
13
12
|
class Base # :nodoc:
|
14
13
|
# We store logger tags in the connection state to be able
|
15
14
|
# to re-use them in the subsequent calls
|
@@ -98,7 +97,6 @@ module ActionCable
|
|
98
97
|
true
|
99
98
|
end
|
100
99
|
|
101
|
-
# rubocop:disable Metrics/MethodLength
|
102
100
|
def handle_channel_command(identifier, command, data)
|
103
101
|
channel = subscriptions.fetch(identifier)
|
104
102
|
case command
|
@@ -44,10 +44,65 @@ module AnyCable
|
|
44
44
|
@__istate__ ||= connection.socket.istate
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
module ConnectionState
|
49
|
+
module ClassMethods
|
50
|
+
def state_attr_accessor(*names)
|
51
|
+
names.each do |name|
|
52
|
+
connection_state_attributes << name
|
53
|
+
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
54
|
+
def #{name}
|
55
|
+
return @#{name} if instance_variable_defined?(:@#{name})
|
56
|
+
@#{name} = AnyCable::Rails.deserialize(__cstate__["#{name}"], json: true) if anycable_socket
|
57
|
+
end
|
58
|
+
|
59
|
+
def #{name}=(val)
|
60
|
+
__cstate__["#{name}"] = AnyCable::Rails.serialize(val, json: true) if anycable_socket
|
61
|
+
instance_variable_set(:@#{name}, val)
|
62
|
+
end
|
63
|
+
RUBY
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def connection_state_attributes
|
68
|
+
return @connection_state_attributes if instance_variable_defined?(:@connection_state_attributes)
|
69
|
+
|
70
|
+
@connection_state_attributes =
|
71
|
+
if superclass.respond_to?(:connection_state_attributes)
|
72
|
+
superclass.connection_state_attributes.dup
|
73
|
+
else
|
74
|
+
[]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.included(base)
|
80
|
+
base.extend ClassMethods
|
81
|
+
end
|
82
|
+
|
83
|
+
# Make it possible to provide istate explicitly for a connection instance
|
84
|
+
attr_writer :__cstate__
|
85
|
+
|
86
|
+
def __cstate__
|
87
|
+
@__cstate__ ||= socket.cstate
|
88
|
+
end
|
89
|
+
end
|
47
90
|
end
|
48
91
|
end
|
49
92
|
|
50
|
-
ActiveSupport
|
93
|
+
if ActiveSupport::VERSION::MAJOR < 6
|
94
|
+
# `state_attr_accessor` must be available in Action Cable
|
95
|
+
ActiveSupport.on_load(:action_cable) do
|
96
|
+
::ActionCable::Connection::Base.include(AnyCable::Rails::ConnectionState)
|
97
|
+
::ActionCable::Channel::Base.include(AnyCable::Rails::ChannelState)
|
98
|
+
end
|
99
|
+
else
|
51
100
|
# `state_attr_accessor` must be available in Action Cable
|
52
|
-
|
101
|
+
ActiveSupport.on_load(:action_cable_connection) do
|
102
|
+
::ActionCable::Connection::Base.include(AnyCable::Rails::ConnectionState)
|
103
|
+
end
|
104
|
+
|
105
|
+
ActiveSupport.on_load(:action_cable_channel) do
|
106
|
+
::ActionCable::Channel::Base.include(AnyCable::Rails::ChannelState)
|
107
|
+
end
|
53
108
|
end
|
@@ -24,6 +24,12 @@ module AnyCableRailsGenerators
|
|
24
24
|
class_option :skip_procfile_dev,
|
25
25
|
type: :boolean,
|
26
26
|
desc: "Do not create Procfile.dev"
|
27
|
+
class_option :skip_jwt,
|
28
|
+
type: :boolean,
|
29
|
+
desc: "Do not install anycable-rails-jwt"
|
30
|
+
class_option :skip_install,
|
31
|
+
type: :boolean,
|
32
|
+
desc: "Do not run bundle install when adding new gems"
|
27
33
|
|
28
34
|
include WithOSHelpers
|
29
35
|
|
@@ -59,7 +65,7 @@ module AnyCableRailsGenerators
|
|
59
65
|
<<~SNIPPET
|
60
66
|
# Specify AnyCable WebSocket server URL to use by JS client
|
61
67
|
config.after_initialize do
|
62
|
-
config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL") if AnyCable::Rails.enabled?
|
68
|
+
config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL", "/cable") if AnyCable::Rails.enabled?
|
63
69
|
end
|
64
70
|
SNIPPET
|
65
71
|
end
|
@@ -129,6 +135,16 @@ module AnyCableRailsGenerators
|
|
129
135
|
say_status :help, "⚠️ Please, take a look at the icompatibilities above and fix them. See #{DOCS_ROOT}/rails/compatibility" unless res
|
130
136
|
end
|
131
137
|
|
138
|
+
def jwt
|
139
|
+
return if options[:skip_jwt]
|
140
|
+
|
141
|
+
return unless options[:skip_jwt] == false || yes?("Do you want to use JWT for authentication? [Yn]")
|
142
|
+
|
143
|
+
opts = " --skip-install" if options[:skip_install]
|
144
|
+
|
145
|
+
run "bundle add anycable-rails-jwt#{opts}"
|
146
|
+
end
|
147
|
+
|
132
148
|
def finish
|
133
149
|
say_status :info, "✅ AnyCable has been configured successfully!"
|
134
150
|
end
|
@@ -172,7 +188,7 @@ module AnyCableRailsGenerators
|
|
172
188
|
say <<~YML
|
173
189
|
─────────────────────────────────────────
|
174
190
|
ws:
|
175
|
-
image: anycable/anycable-go:1.
|
191
|
+
image: anycable/anycable-go:1.2
|
176
192
|
ports:
|
177
193
|
- '8080:8080'
|
178
194
|
environment:
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anycable-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: anycable
|
14
|
+
name: anycable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actioncable
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '6'
|
33
|
+
version: '6.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '6'
|
40
|
+
version: '6.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: globalid
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +198,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: '2.
|
201
|
+
version: '2.7'
|
202
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
203
|
requirements:
|
204
204
|
- - ">="
|
205
205
|
- !ruby/object:Gem::Version
|
206
206
|
version: '0'
|
207
207
|
requirements: []
|
208
|
-
rubygems_version: 3.2.
|
208
|
+
rubygems_version: 3.2.22
|
209
209
|
signing_key:
|
210
210
|
specification_version: 4
|
211
211
|
summary: Rails adapter for AnyCable
|