anycable-rails 1.0.0.rc2 → 1.0.0.rc3

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: e0de4d95da59574a14f3f56219154cf3e12513a74e677520acf0cffbbf566e49
4
- data.tar.gz: c6a4e9b87c3c59aac495663f8acc9f3150a8de5f43d5ab55d19c265039ba2af1
3
+ metadata.gz: 3ebb4dc7b8483998770f7168cc8884d8a56a0e5376e04550b2f98b1d11046cdf
4
+ data.tar.gz: 29a21773378af2c3bcc6cd3265d58d028a7bef7b8fc2be13bafda3f54677d8b1
5
5
  SHA512:
6
- metadata.gz: 93f85efbfa20cffe71b3b52115b98321158577a36439b9875e6bbfb18ecee32c44fd31376a05f8883b8eff7d8b06b4d2d5abf762f86f6765248e3051869f3b17
7
- data.tar.gz: 2ca2cd646321b0ed567af383847e4ae5f5cab116be0a7c410ea18d91f43378c024c47e3002c0aa70ddd0970a4e2bad50fd173c0b1fdf9088f229bad3ea53a05d
6
+ metadata.gz: cde255681a0348c2edc41fc3130d632f8f17ea02937691b62a388f8a73a699b9e1669e9c7ea55f1dad3a74b6e0d289a3a07feda97adbcbbfcc5d1e316213a704
7
+ data.tar.gz: 88c80148d66a610472bf8a129a381198d044c89884a800f4209c19f67a6cf527763620bfd804b03cbddb0f6752b6e69c8065e4bfbf1c33da11e66cb7def49688
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.0.0.rc3 (2020-06-24)
6
+
7
+ - Make AnyCable patches compatible with Action Cable testing. ([@palkan][])
8
+
9
+ - Do not add localhost `redis_url` to `anycable.yml` when Docker development method is chosen in `anycable:setup`. ([@palkan][])
10
+
5
11
  ## 1.0.0.rc2 (2020-06-16)
6
12
 
7
13
  - Fix connection identifiers deserialization regression. ([@palkan][])
@@ -21,6 +21,8 @@ module ActionCable
21
21
 
22
22
  attr_reader :socket
23
23
 
24
+ alias anycable_socket socket
25
+
24
26
  delegate :env, :session, to: :request
25
27
 
26
28
  class << self
@@ -28,3 +28,7 @@ module ActionCable
28
28
  end
29
29
  end
30
30
  end
31
+
32
+ ::ActionCable::Connection::Base.prepend(
33
+ ::ActionCable::Connection::PersistentSession
34
+ )
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file contains patches to Action Cable testing modules
4
+
5
+ # Trigger autoload (if constant is defined)
6
+ begin
7
+ ActionCable::Channel::TestCase # rubocop:disable Lint/Void
8
+ ActionCable::Connection::TestCase # rubocop:disable Lint/Void
9
+ rescue NameError
10
+ return
11
+ end
12
+
13
+ ActionCable::Channel::ChannelStub.prepend(Module.new do
14
+ def subscribe_to_channel
15
+ # allocate @streams
16
+ streams
17
+ handle_subscribe
18
+ end
19
+ end)
20
+
21
+ ActionCable::Channel::ConnectionStub.prepend(Module.new do
22
+ def socket
23
+ @socket ||= AnyCable::Socket.new(env: {})
24
+ end
25
+
26
+ alias_method :anycable_socket, :socket
27
+ end)
28
+
29
+ ActionCable::Connection::TestConnection.prepend(Module.new do
30
+ def initialize(request)
31
+ @request = request
32
+ @cached_ids = {}
33
+ super
34
+ end
35
+ end)
@@ -5,18 +5,16 @@ module AnyCable
5
5
  module ChannelState
6
6
  module ClassMethods
7
7
  def state_attr_accessor(*names)
8
- return attr_accessor(*names) unless AnyCable::Rails.enabled?
9
-
10
8
  names.each do |name|
11
9
  channel_state_attributes << name
12
10
  class_eval <<~RUBY, __FILE__, __LINE__ + 1
13
11
  def #{name}
14
12
  return @#{name} if instance_variable_defined?(:@#{name})
15
- @#{name} = AnyCable::Rails.deserialize(connection.socket.istate["#{name}"], json: true)
13
+ @#{name} = AnyCable::Rails.deserialize(connection.socket.istate["#{name}"], json: true) if connection.anycable_socket
16
14
  end
17
15
 
18
16
  def #{name}=(val)
19
- connection.socket.istate["#{name}"] = AnyCable::Rails.serialize(val, json: true)
17
+ connection.socket.istate["#{name}"] = AnyCable::Rails.serialize(val, json: true) if connection.anycable_socket
20
18
  instance_variable_set(:@#{name}, val)
21
19
  end
22
20
  RUBY
@@ -43,22 +43,30 @@ module AnyCable
43
43
 
44
44
  initializer "anycable.connection_factory", after: "action_cable.set_configs" do |app|
45
45
  ActiveSupport.on_load(:action_cable) do
46
+ # Add AnyCable patch method stub (we use it in ChannelState to distinguish between Action Cable and AnyCable)
47
+ # NOTE: Method could be already defined if patch was loaded manually
48
+ ActionCable::Connection::Base.attr_reader(:anycable_socket) unless ActionCable::Connection::Base.method_defined?(:anycable_socket)
49
+
50
+ app.config.to_prepare do
51
+ AnyCable.connection_factory = ActionCable.server.config.connection_class.call
52
+ end
53
+
46
54
  if AnyCable::Rails.enabled?
47
55
  require "anycable/rails/actioncable/connection"
48
-
49
56
  if AnyCable.config.persistent_session_enabled
50
57
  require "anycable/rails/actioncable/connection/persistent_session"
51
- ::ActionCable::Connection::Base.prepend(
52
- ::ActionCable::Connection::PersistentSession
53
- )
54
- end
55
-
56
- app.config.to_prepare do
57
- AnyCable.connection_factory = ActionCable.server.config.connection_class.call
58
58
  end
59
59
  end
60
60
  end
61
61
  end
62
+
63
+ initializer "anycable.testing" do |app|
64
+ next unless ::Rails.env.test?
65
+
66
+ ActiveSupport.on_load(:action_cable) do
67
+ require "anycable/rails/actioncable/testing"
68
+ end
69
+ end
62
70
  end
63
71
  end
64
72
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AnyCable
4
4
  module Rails
5
- VERSION = "1.0.0.rc2"
5
+ VERSION = "1.0.0.rc3"
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  Description:
2
- Install AnyCable-Go web server.
2
+ Install AnyCable-Go web server locally (the latest version by default).
3
3
 
4
4
  Example:
5
5
  rails generate anycable:download
@@ -9,8 +9,7 @@ module AnyCableRailsGenerators
9
9
 
10
10
  include WithOSHelpers
11
11
 
12
- # TODO: change to latest release
13
- VERSION = "1.0.0.preview1"
12
+ VERSION = "latest"
14
13
 
15
14
  class_option :bin_path,
16
15
  type: :string,
@@ -35,20 +34,27 @@ module AnyCableRailsGenerators
35
34
  private
36
35
 
37
36
  def release_url(version)
37
+ return latest_release_url(version) if version == "latest"
38
+
38
39
  if Gem::Version.new(version).segments.first >= 1
39
- new_release_url(version)
40
+ new_release_url("v#{version}")
40
41
  else
41
- legacy_release_url(version)
42
+ legacy_release_url("v#{version}")
42
43
  end
43
44
  end
44
45
 
45
46
  def legacy_release_url(version)
46
- "https://github.com/anycable/anycable-go/releases/download/v#{version}/" \
47
+ "https://github.com/anycable/anycable-go/releases/download/#{version}/" \
47
48
  "anycable-go-v#{version}-#{os_name}-#{cpu_name}"
48
49
  end
49
50
 
50
51
  def new_release_url(version)
51
- "https://github.com/anycable/anycable-go/releases/download/v#{version}/" \
52
+ "https://github.com/anycable/anycable-go/releases/download/#{version}/" \
53
+ "anycable-go-#{os_name}-#{cpu_name}"
54
+ end
55
+
56
+ def latest_release_url(version)
57
+ "https://github.com/anycable/anycable-go/releases/latest/download/" \
52
58
  "anycable-go-#{os_name}-#{cpu_name}"
53
59
  end
54
60
 
@@ -159,6 +159,9 @@ module AnyCableRailsGenerators
159
159
  end
160
160
 
161
161
  def install_for_docker
162
+ # Remove localhost from configuraiton
163
+ gsub_file "config/anycable.yml", /^.*redis_url:.*localhost[^\n]+\n/, ""
164
+
162
165
  say_status :help, "️️⚠️ Docker development configuration could vary", :yellow
163
166
 
164
167
  say "Here is an example snippet for docker-compose.yml:"
@@ -174,8 +177,8 @@ module AnyCableRailsGenerators
174
177
  ANYCABLE_RPC_HOST: anycable:50051
175
178
  ANYCABLE_DEBUG: 1
176
179
  depends_on:
177
- - anycable
178
- - redis
180
+ redis:
181
+ condition: service_healthy
179
182
 
180
183
  anycable:
181
184
  <<: *backend
@@ -184,8 +187,13 @@ module AnyCableRailsGenerators
184
187
  <<: *backend_environment
185
188
  ANYCABLE_REDIS_URL: redis://redis:6379/0
186
189
  ANYCABLE_RPC_HOST: 0.0.0.0:50051
190
+ ANYCABLE_DEBUG: 1
187
191
  ports:
188
192
  - '50051'
193
+ depends_on:
194
+ <<: *backend_depends_on
195
+ ws:
196
+ condition: service_started
189
197
  ─────────────────────────────────────────
190
198
  YML
191
199
  end
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.0.rc2
4
+ version: 1.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-16 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anycable
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec
84
+ name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '3.4'
89
+ version: 4.0.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '3.4'
96
+ version: 4.0.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -141,6 +141,7 @@ files:
141
141
  - lib/anycable/rails/actioncable/connection/persistent_session.rb
142
142
  - lib/anycable/rails/actioncable/connection/serializable_identification.rb
143
143
  - lib/anycable/rails/actioncable/remote_connections.rb
144
+ - lib/anycable/rails/actioncable/testing.rb
144
145
  - lib/anycable/rails/channel_state.rb
145
146
  - lib/anycable/rails/compatibility.rb
146
147
  - lib/anycable/rails/compatibility/rubocop.rb