anycable-rails 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +3 -1
- data/lib/anycable/rails.rb +12 -0
- data/lib/anycable/rails/railtie.rb +18 -3
- data/lib/anycable/rails/version.rb +1 -1
- data/lib/generators/anycable/templates/script +0 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f487f9b1437eeeb4fab3bec3ec73c3f06e32bc3
|
4
|
+
data.tar.gz: 5d1105fbde9dfcce31da1cb02ac1699bbe80fd5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b87a26ed485cb1391fc388fa96734f37487b11c0862b149dcc64fb9ecb9d31c47fe1c50be1d297b0dbb1dad91a35d6aa9c6b88d96559c17feed058058e4704
|
7
|
+
data.tar.gz: 9634bf30406506e577496c92afe462377c1d8da5b3e7d005b36c2a6c849a596b11c782bad4a40c3bcadc071eaeeac0b632ab25479223d8e39d2139462dc58d38
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
##
|
3
|
+
## 0.5.1
|
4
|
+
|
5
|
+
- Improve Rails integration. ([@palkan][])
|
6
|
+
|
7
|
+
Log to STDOUT in development.
|
8
|
+
Make order of initializers more deterministic.
|
9
|
+
Show warning if AnyCable is loaded after application initialization.
|
10
|
+
|
11
|
+
## 0.5.0
|
4
12
|
|
5
13
|
- [#17](https://github.com/anycable/anycable-rails/issues/17) Refactor logging. ([@palkan][])
|
6
14
|
|
data/README.md
CHANGED
@@ -51,6 +51,9 @@ gem 'anycable-rails'
|
|
51
51
|
gem 'anycable-rails', group: :production
|
52
52
|
```
|
53
53
|
|
54
|
+
**NOTE**: if you want to require `anycable-rails` _manually_ (i.e. with `require: false` in your `Gemfile`)
|
55
|
+
make sure that it's loaded prior to `Rails.application.initialize!` call (see `config/environment.rb`).
|
56
|
+
|
54
57
|
And then run:
|
55
58
|
|
56
59
|
```shell
|
@@ -116,7 +119,6 @@ production:
|
|
116
119
|
access_logs_disabled: false
|
117
120
|
```
|
118
121
|
|
119
|
-
|
120
122
|
## ActionCable Compatibility
|
121
123
|
|
122
124
|
This is the compatibility list for the AnyCable gem, not for AnyCable servers (which may not support some of the features yet).
|
data/lib/anycable/rails.rb
CHANGED
@@ -12,3 +12,15 @@ module Anycable
|
|
12
12
|
require "anycable/rails/actioncable/connection"
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
# Warn if application has been already initialized.
|
17
|
+
# Anycable should be loaded before initialization in order to work correctly.
|
18
|
+
if defined?(::Rails) && ::Rails.application && ::Rails.application.initialized?
|
19
|
+
puts("\n**************************************************")
|
20
|
+
puts(
|
21
|
+
"⛔️ WARNING: AnyCable loaded after application initialization. Might not work correctly.\n"\
|
22
|
+
"Please, make sure to remove `require: false` in your Gemfile or "\
|
23
|
+
"require manually in `environment.rb` before `Rails.application.initialize!`"
|
24
|
+
)
|
25
|
+
puts("**************************************************\n\n")
|
26
|
+
end
|
@@ -20,20 +20,35 @@ module Anycable
|
|
20
20
|
end
|
21
21
|
|
22
22
|
class Railtie < ::Rails::Railtie # :nodoc:
|
23
|
-
initializer "
|
23
|
+
initializer "anycable.disable_action_cable_mount", before: "action_cable.routes" do |app|
|
24
24
|
app.config.action_cable.mount_path = nil
|
25
25
|
end
|
26
26
|
|
27
|
-
initializer "
|
27
|
+
initializer "anycable.logger", after: :initialize_logger do |_app|
|
28
28
|
Anycable.logger = LoggerProxy.new(::Rails.logger)
|
29
|
+
|
30
|
+
# Broadcast logs to STDOUT in development
|
31
|
+
if ::Rails.env.development? &&
|
32
|
+
!ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, STDOUT)
|
33
|
+
console = ActiveSupport::Logger.new(STDOUT)
|
34
|
+
console.formatter = ::Rails.logger.formatter
|
35
|
+
console.level = ::Rails.logger.level
|
36
|
+
::Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
|
37
|
+
end
|
29
38
|
end
|
30
39
|
|
31
|
-
initializer "
|
40
|
+
initializer "anycable.release_connections" do |_app|
|
32
41
|
ActiveSupport.on_load(:active_record) do
|
33
42
|
require "anycable/rails/activerecord/release_connection"
|
34
43
|
Anycable::RPCHandler.prepend Anycable::Rails::ActiveRecord::ReleaseConnection
|
35
44
|
end
|
36
45
|
end
|
46
|
+
|
47
|
+
initializer "anycable.connection_factory", after: "action_cable.set_configs" do |_app|
|
48
|
+
ActiveSupport.on_load(:action_cable) do
|
49
|
+
Anycable.connection_factory = connection_class.call
|
50
|
+
end
|
51
|
+
end
|
37
52
|
end
|
38
53
|
end
|
39
54
|
end
|
@@ -2,10 +2,5 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require ::File.expand_path('../../config/environment', __FILE__)
|
5
|
-
require "anycable-rails"
|
6
|
-
|
7
|
-
Anycable.connection_factory = ActionCable.server.config.connection_class.call
|
8
|
-
|
9
|
-
Rails.application.eager_load!
|
10
5
|
|
11
6
|
Anycable::Server.start
|
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: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|