anycable-rails 1.1.0 → 1.1.4

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: 4b2017a00c28bf2656e223a5ba109d66044d4554c061cd4903b52485ff656906
4
- data.tar.gz: c99be090e2e7517a9e4d680e5602a2d35331be05f39e9816813518e8726887cc
3
+ metadata.gz: 59a60ff31ba3907089d78beaedf01b69a66ff2e7da83175dcd8e19d78bd6e9aa
4
+ data.tar.gz: 1b9a709873bf7409502c2e114b9b90ae32ce94a724d5a3091d22ea8a7c86cd76
5
5
  SHA512:
6
- metadata.gz: e3d265c017a5dbed395324ea17d9e91bdbb94aa5d8678d2df882a1d756b893eaa53272fe654ae98bcc79472e4358e9b4e45121632de3bcdc68c3d84f9d8736bc
7
- data.tar.gz: 6184f438d860d7ee83537a2115367a84002ac833e9b58c2e767a68003039cc6ef6f0f907c76d1c599ac60729d104e5bb556012a5dc58b0eb9e0bb69c35175113
6
+ metadata.gz: 80d3114d9eb008e7dce61d772a71608f87c0c24eb60dbed31f857abbdb7271d7a13a4a1103609910e6eef51d576a761e92f8a40cc134f3ab95b314f247e60551
7
+ data.tar.gz: cbd7a8c52da4ddd60023f536d99be251dee6158c0639744c0235b9876d4efcba9ab983ad9f06a0605cd187afaa34f2b2c1975c7b949a188e26d44860553cd88e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.1.4 (2021-11-11)
6
+
7
+ - Added `Connection#state_attr_accessor`. ([@palkan][])
8
+
9
+ ## 1.1.3 (2021-10-11)
10
+
11
+ - Relax Action Cable dependency. ([@palkan][])
12
+
13
+ Action Cable 5.1 is allowed (though not recommended).
14
+
15
+ ## 1.1.2 (2021-06-23)
16
+
17
+ - Bring back dependency on `anycable` (instead of `anycable-core`). ([@palkan][])
18
+
19
+ Make it easier to get started by adding just a single gem.
20
+
21
+ ## 1.1.1 (2021-06-08)
22
+
23
+ - Updated documentation links in the generator. ([@palkan][])
24
+
5
25
  ## 1.1.0 🚸 (2021-06-01)
6
26
 
7
27
  - No changes since 1.1.0.rc1.1.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/anycable-rails.svg)](https://rubygems.org/gems/anycable-rails)
2
2
  [![Build](https://github.com/anycable/anycable-rails/workflows/Build/badge.svg)](https://github.com/anycable/anycable-rails/actions)
3
3
  [![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/anycable/Lobby)
4
- [![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://docs.anycable.io/#/rails/getting_started)
4
+ [![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://docs.anycable.io/rails/getting_started)
5
5
 
6
6
  # AnyCable Rails
7
7
 
@@ -13,7 +13,9 @@ You can even use Action Cable in development and not be afraid of [compatibility
13
13
 
14
14
  💾 [Example Application](https://github.com/anycable/anycable_rails_demo)
15
15
 
16
- 📑 [Documentation](https://docs.anycable.io/#/rails/getting_started).
16
+ 📑 [Documentation](https://docs.anycable.io/rails/getting_started).
17
+
18
+ > [AnyCable Pro](https://docs.anycable.io/pro) has been launched 🚀
17
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>
@@ -21,15 +23,14 @@ You can even use Action Cable in development and not be afraid of [compatibility
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` and `anycable` gems to your Gemfile:
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
@@ -81,17 +82,17 @@ $ bundle exec anycable
81
82
  $ RAILS_ENV=production bundle exec anycable
82
83
  ```
83
84
 
84
- And, finally, run AnyCable WebSocket server, e.g. [anycable-go](https://docs.anycable.io/#/v1/anycable-go/getting_started):
85
+ And, finally, run AnyCable WebSocket server, e.g. [anycable-go](https://docs.anycable.io/anycable-go/getting_started):
85
86
 
86
87
  ```sh
87
88
  anycable-go --host=localhost --port=8080
88
89
  ```
89
90
 
90
- See [documentation](https://docs.anycable.io/#/rails/getting_started) for more information on AnyCable + Rails usage.
91
+ See [documentation](https://docs.anycable.io/rails/getting_started) for more information on AnyCable + Rails usage.
91
92
 
92
93
  ## Action Cable Compatibility
93
94
 
94
- See [documentation](https://docs.anycable.io/#/rails/compatibility).
95
+ See [documentation](https://docs.anycable.io/rails/compatibility).
95
96
 
96
97
  ## Contributing
97
98
 
@@ -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
@@ -71,7 +70,7 @@ module ActionCable
71
70
 
72
71
  def invalid_request_message
73
72
  "You're trying to connect to Action Cable server while using AnyCable. " \
74
- "See https://docs.anycable.io/#/troubleshooting?id=server-raises-an-argumenterror-exception-when-client-tries-to-connect"
73
+ "See https://docs.anycable.io/troubleshooting?id=server-raises-an-argumenterror-exception-when-client-tries-to-connect"
75
74
  end
76
75
 
77
76
  def handle_open
@@ -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
@@ -5,7 +5,7 @@
5
5
  # Trigger autoload (if constant is defined)
6
6
  begin
7
7
  ActionCable::Channel::TestCase # rubocop:disable Lint/Void
8
- ActionCable::Connection::TestCase # rubocop:disable Lint/Void
8
+ ActionCable::Connection::TestCase
9
9
  rescue NameError
10
10
  return
11
11
  end
@@ -44,10 +44,54 @@ 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
93
  ActiveSupport.on_load(:action_cable) do
51
94
  # `state_attr_accessor` must be available in Action Cable
95
+ ::ActionCable::Connection::Base.include(AnyCable::Rails::ConnectionState)
52
96
  ::ActionCable::Channel::Base.include(AnyCable::Rails::ChannelState)
53
97
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AnyCable
4
4
  module Rails
5
- VERSION = "1.1.0"
5
+ VERSION = "1.1.4"
6
6
  end
7
7
  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/#/rails/stimulus_reflex"
121
+ say_status :help, "⚠️ Please, check out the documentation on using AnyCable with Stimulus Reflex: #{DOCS_ROOT}/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/#/rails/compatibility" unless res
129
+ say_status :help, "⚠️ Please, take a look at the icompatibilities above and fix them. See #{DOCS_ROOT}/rails/compatibility" unless res
130
130
  end
131
131
 
132
132
  def finish
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: anycable-core
14
+ name: anycable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '6'
33
+ version: '5.1'
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: '5.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: globalid
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  - !ruby/object:Gem::Version
206
206
  version: '0'
207
207
  requirements: []
208
- rubygems_version: 3.2.15
208
+ rubygems_version: 3.2.22
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: Rails adapter for AnyCable