actioncable-next 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2a646309358247e05b84be4246c044bfae6f289eab7776e5821d6c54e8b1f00
4
- data.tar.gz: d2ec2b1f743af72cdc61a8be7c41e80778cff79d9335baa059fbd791272cf07a
3
+ metadata.gz: b86ee72b0095c7a8ce99b0d354231b2ac29145e07a1482387fa9664f1c9a08b8
4
+ data.tar.gz: e72beed883e8789189fa6811d6fb70cdc4e9efbec2ad9b259648c8575196aca3
5
5
  SHA512:
6
- metadata.gz: 8ff34021af6ec2c0e69676ba92fb64f2f1c9a9141db355eaa1f16fc7e9e7f3e4689b79efd86ebada9fd698e9b76bf95a214969198feb0c4334bbebb86a0597ec
7
- data.tar.gz: aed1822bc56226c76a02f6d9a95f3bc915fe429d3345bd3dbbc964ef6e384337347ed0496427b609788846951409042accb001ca157519f746997d512665b0d3
6
+ metadata.gz: 955b568fb0d4e01d81ad6871292515c1a3d742eef03067c6322d68b7c6908eeac12947aaef91cb9d4fcbccf2e3790ff84c797ad30e462db15179b04ee6a2d8a3
7
+ data.tar.gz: 3cc6151d155e3719b008bad22ecf4fbf0a401a5858a7ef5bd75a941debca5b26ac9d06cb30d781929d6da10399c9f534d06aed6ac7afd2ea7a96490066dc6891
data/CHANGELOG.md CHANGED
@@ -2,4 +2,14 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 0.1.2
6
+
7
+ - Added a hack to prevent third-party extensions from changing the methods visibility.
8
+
9
+ ## 0.1.1
10
+
11
+ - Added RSpec patch.
12
+
13
+ ## 0.1.0
14
+
5
15
  - Initial extraction.
data/README.md CHANGED
@@ -15,3 +15,14 @@ gem "rails", "~> 7.0"
15
15
  ```
16
16
 
17
17
  Then, you can use Action Cable as before. Under the hood, the new implementation would be used.
18
+
19
+ ### RSpec support
20
+
21
+ This gem also includes the corresponding patch for RSpec Rails (see [PR](https://github.com/palkan/rspec-rails/pull/1)). You MUST activate it explicitly
22
+ by adding the following line to your `spec/rails_helper.rb`:
23
+
24
+ ```ruby
25
+ # after rspec-rails is loaded
26
+ require "rspec/rails"
27
+ require "action_cable/next/rspec"
28
+ ```
@@ -162,4 +162,15 @@ module ActionCable
162
162
  end
163
163
  end
164
164
 
165
+ # Hack to make sure legacy extensions do not changes the visibility of API methods
166
+ # (see https://github.com/anycable/actioncable-next/issues/7)
167
+ # We call it from the engine after application initialization.
168
+ class << ActionCable::Connection::Base
169
+ def __restore_visibility__
170
+ %i[handle_open handle_close handle_channel_command transmit close].each do |method|
171
+ instance_method(method).owner.send(:public, method)
172
+ end
173
+ end
174
+ end
175
+
165
176
  ActiveSupport.run_load_hooks(:action_cable_connection, ActionCable::Connection::Base)
@@ -94,5 +94,11 @@ module ActionCable
94
94
  end
95
95
  end
96
96
  end
97
+
98
+ config.after_initialize do
99
+ ActiveSupport.on_load(:action_cable_connection) do
100
+ ActionCable::Connection::Base.__restore_visibility__
101
+ end
102
+ end
97
103
  end
98
104
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # RSpec patches from https://github.com/palkan/rspec-rails/pull/1
4
+
5
+ require "rspec/rails/example/channel_example_group"
6
+
7
+ if defined?(RSpec::Rails::ChannelExampleGroup)
8
+ RSpec::Rails::ChannelExampleGroup.prepend(Module.new do
9
+ def connection_class
10
+ (_connection_class || described_class).then do |klass|
11
+ # Connection class either specified explicitly or is a described class
12
+ next klass if klass && klass <= ::ActionCable::Connection::Base
13
+
14
+ # Otherwise, fallback to the default connection class
15
+ tests_connection ::ActionCable.server.config.connection_class.call
16
+
17
+ _connection_class
18
+ end
19
+ end
20
+ end)
21
+ end
22
+
23
+ RSpec::Rails::Matchers::ActionCable::HaveStream.prepend(Module.new do
24
+ def match(subscription)
25
+ case subscription
26
+ when ::ActionCable::Channel::Base
27
+ @actual = streams_for(subscription)
28
+ no_expected? ? actual.any? : actual.any? { |i| expected === i }
29
+ else
30
+ raise ArgumentError, "have_stream, have_stream_from and have_stream_from support expectations on subscription only"
31
+ end
32
+ end
33
+
34
+ private
35
+ def streams_for(subscription)
36
+ # In Rails 8, subscription.streams returns a real subscriptions hash,
37
+ # not a fake array of stream names like in Rails 6-7.
38
+ # So, we must use #stream_names instead.
39
+ subscription.respond_to?(:stream_names) ? subscription.stream_names : subscription.streams
40
+ end
41
+ end)
data/lib/action_cable.rb CHANGED
@@ -39,6 +39,7 @@ Zeitwerk::Loader.for_gem.tap do |loader|
39
39
  "#{lib}/action_cable/version.rb",
40
40
  "#{lib}/action_cable/deprecator.rb",
41
41
  "#{lib}/actioncable-next.rb",
42
+ "#{lib}/action_cable/next",
42
43
  )
43
44
 
44
45
  loader.do_not_eager_load(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionCableNext
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actioncable-next
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pratik Naik
8
8
  - David Heinemeier Hansson
9
9
  - Vladimir Dementyev
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-09-30 00:00:00.000000000 Z
13
+ date: 2025-01-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -125,6 +125,7 @@ files:
125
125
  - lib/action_cable/engine.rb
126
126
  - lib/action_cable/gem_version.rb
127
127
  - lib/action_cable/helpers/action_cable_helper.rb
128
+ - lib/action_cable/next/rspec.rb
128
129
  - lib/action_cable/remote_connections.rb
129
130
  - lib/action_cable/server/base.rb
130
131
  - lib/action_cable/server/broadcasting.rb
@@ -166,10 +167,10 @@ licenses:
166
167
  - MIT
167
168
  metadata:
168
169
  bug_tracker_uri: https://github.com/anycable/actioncable-next
169
- changelog_uri: https://github.com/anycable/actioncable-next/blob/v0.1.0/CHANGELOG.md
170
+ changelog_uri: https://github.com/anycable/actioncable-next/blob/v0.1.2/CHANGELOG.md
170
171
  source_code_uri: https://github.com/anycable/actioncable-next
171
172
  rubygems_mfa_required: 'true'
172
- post_install_message:
173
+ post_install_message:
173
174
  rdoc_options: []
174
175
  require_paths:
175
176
  - lib
@@ -184,8 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
185
  - !ruby/object:Gem::Version
185
186
  version: '0'
186
187
  requirements: []
187
- rubygems_version: 3.5.18
188
- signing_key:
188
+ rubygems_version: 3.5.22
189
+ signing_key:
189
190
  specification_version: 4
190
191
  summary: Next-gen version of Action Cable
191
192
  test_files: []