anycable-rails-core 1.5.0.rc.1 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b614e500208e2a3f4ea896da9228028302800348084305868ea0c22178f858b
4
- data.tar.gz: 83c91a4e4aa9dde124ed862addaf6e927a3638fd3187e7df781bfb8745c71319
3
+ metadata.gz: 047a37c59ff5b5e9e0074302b02450b8e7ab78af36382db634843eb8d1e0a802
4
+ data.tar.gz: 92234b820387917f2f1321b1175b3f1bdfd6305d386320fefcbfc68384476f9d
5
5
  SHA512:
6
- metadata.gz: 18066377abcddc253760bc1afe77f5701f20fc9c7de4f83ed9ba9f98d91c8c68efe01943b724d39eaf39e58280825fe858b195871386a21acb34a191cede0b8a
7
- data.tar.gz: ade05b2cd18c667d69626782031beb41885d3d9162c42042663baee100aaa930ff22a1f939bb3424ca7f7e2ec31225bf6ae9cdefc1b4892e692cd4c6a6d4dcc2
6
+ metadata.gz: 86938782b2903250bf2a6fdfa205ff70f8356414c035e4d195c93967051fccc731d520b74b373b54ac74cbbd0b3182678b863a06f466ddd17926c2dba3209025
7
+ data.tar.gz: 2112a294b4fe22efd05835a2a93b60dfecaae996e990d8690af89d28017ae495d79df147b0cc451bb1a8ae429bceed594d38ded78c1b09de8518f20fe1075b55
data/CHANGELOG.md CHANGED
@@ -2,7 +2,21 @@
2
2
 
3
3
  ## master
4
4
 
5
- ## 1.5.0.rc.1
5
+ ## 1.5.1 (2024-04-05)
6
+
7
+ - Add `anycable-rails-core.rb` to avoid adding `require: ["anycable-rails"]` to Gemfiles manually. ([@palkan][])
8
+
9
+ - Mount HTTP RPC independently of the current Action Cable adapter. ([@palkan][])
10
+
11
+ This makes it possible to use it in tests without manually adding the middleware.
12
+
13
+ ## 1.5.0 (2024-04-01)
14
+
15
+ - Allow specifying the _whispering_ stream via `#stream_from(..., whisper: true)`. ([@palkan][])
16
+
17
+ You can use specify the stream to use for _whispering_ (client-initiated broadcasts) by adding `whisper: true` to the `#stream_from` (or `#stream_for`) method call.
18
+
19
+ NOTE: This feature is only supported when using AnyCable server and ignored otherwise.
6
20
 
7
21
  - Support passing objects to `ActionCable.server.broadcast`. ([@palkan][])
8
22
 
@@ -22,12 +22,20 @@ ActionCable::Channel::Base.prepend(Module.new do
22
22
  super unless anycabled?
23
23
  end
24
24
 
25
- def stream_from(broadcasting, _callback = nil, **)
25
+ def stream_from(broadcasting, _callback = nil, **opts)
26
+ whispering = opts.delete(:whisper)
26
27
  return super unless anycabled?
27
28
 
28
29
  broadcasting = String(broadcasting)
29
30
 
30
31
  connection.anycable_socket.subscribe identifier, broadcasting
32
+ if whispering
33
+ connection.anycable_socket.whisper identifier, broadcasting
34
+ end
35
+ end
36
+
37
+ def stream_for(model, callback = nil, **opts, &block)
38
+ stream_from(broadcasting_for(model), callback || block, **opts)
31
39
  end
32
40
 
33
41
  def stop_stream_from(broadcasting)
@@ -12,9 +12,10 @@ module AnyCable
12
12
  return @#{name} if instance_variable_defined?(:@#{name})
13
13
  return unless anycabled?
14
14
 
15
- val = __istate__["#{name}"]
15
+ raw_val = __istate__["#{name}"]
16
+ val = raw_val.present? ? AnyCable::Serializer.deserialize(JSON.parse(raw_val)) : nil
16
17
 
17
- @#{name} = val.present? ? AnyCable::Serializer.deserialize(JSON.parse(val)) : nil
18
+ @#{name} = val.try(:with_indifferent_access) || val
18
19
  end
19
20
 
20
21
  def #{name}=(val)
@@ -11,7 +11,7 @@ module AnyCable
11
11
  ]
12
12
 
13
13
  ActionCable::Channel::Base.prepend(Module.new do
14
- def stream_from(broadcasting, callback = nil, coder: nil)
14
+ def stream_from(broadcasting, callback = nil, coder: nil, **)
15
15
  if coder.present? && coder != ActiveSupport::JSON
16
16
  raise AnyCable::CompatibilityError, "Custom coders are not supported by AnyCable"
17
17
  end
@@ -117,8 +117,6 @@ module AnyCable
117
117
  end
118
118
 
119
119
  initializer "anycable.routes" do
120
- next unless AnyCable::Rails.enabled?
121
-
122
120
  config.after_initialize do |app|
123
121
  config = AnyCable.config
124
122
  unless config.http_rpc_mount_path.nil?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AnyCable
4
4
  module Rails
5
- VERSION = "1.5.0.rc.1"
5
+ VERSION = "1.5.1"
6
6
  end
7
7
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "anycable/rails"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable-rails-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.rc.1
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-13 00:00:00.000000000 Z
11
+ date: 2024-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anycable-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.0.rc.1
19
+ version: 1.5.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: 1.5.0.rc.1
26
+ version: 1.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actioncable
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -64,6 +64,7 @@ files:
64
64
  - README.md
65
65
  - lib/action_cable/subscription_adapter/any_cable.rb
66
66
  - lib/action_cable/subscription_adapter/anycable.rb
67
+ - lib/anycable-rails-core.rb
67
68
  - lib/anycable-rails.rb
68
69
  - lib/anycable/rails.rb
69
70
  - lib/anycable/rails/action_cable_ext/broadcast_options.rb
@@ -118,7 +119,7 @@ metadata:
118
119
  homepage_uri: https://anycable.io/
119
120
  source_code_uri: http://github.com/anycable/anycable-rails
120
121
  funding_uri: https://github.com/sponsors/anycable
121
- post_install_message:
122
+ post_install_message:
122
123
  rdoc_options: []
123
124
  require_paths:
124
125
  - lib
@@ -129,12 +130,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
130
  version: '2.7'
130
131
  required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  requirements:
132
- - - ">"
133
+ - - ">="
133
134
  - !ruby/object:Gem::Version
134
- version: 1.3.1
135
+ version: '0'
135
136
  requirements: []
136
- rubygems_version: 3.4.20
137
- signing_key:
137
+ rubygems_version: 3.4.19
138
+ signing_key:
138
139
  specification_version: 4
139
140
  summary: AnyCable integration for Rails (w/o RPC dependencies)
140
141
  test_files: []