anycable-rails 0.6.5 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -110
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +34 -37
  5. data/lib/action_cable/subscription_adapter/any_cable.rb +2 -1
  6. data/lib/anycable/rails.rb +37 -2
  7. data/lib/anycable/rails/actioncable/channel.rb +4 -0
  8. data/lib/anycable/rails/actioncable/connection.rb +72 -50
  9. data/lib/anycable/rails/actioncable/connection/persistent_session.rb +34 -0
  10. data/lib/anycable/rails/actioncable/connection/serializable_identification.rb +42 -0
  11. data/lib/anycable/rails/actioncable/remote_connections.rb +11 -0
  12. data/lib/anycable/rails/actioncable/testing.rb +35 -0
  13. data/lib/anycable/rails/channel_state.rb +46 -0
  14. data/lib/anycable/rails/compatibility.rb +7 -10
  15. data/lib/anycable/rails/compatibility/rubocop.rb +0 -1
  16. data/lib/anycable/rails/compatibility/rubocop/config/default.yml +3 -1
  17. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/instance_vars.rb +1 -1
  18. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/stream_from.rb +4 -4
  19. data/lib/anycable/rails/config.rb +8 -4
  20. data/lib/anycable/rails/rack.rb +56 -0
  21. data/lib/anycable/rails/railtie.rb +28 -13
  22. data/lib/anycable/rails/refinements/subscriptions.rb +1 -1
  23. data/lib/anycable/rails/session_proxy.rb +79 -0
  24. data/lib/anycable/rails/version.rb +1 -1
  25. data/lib/generators/anycable/download/USAGE +14 -0
  26. data/lib/generators/anycable/download/download_generator.rb +83 -0
  27. data/lib/generators/anycable/setup/USAGE +2 -0
  28. data/lib/generators/anycable/setup/setup_generator.rb +266 -0
  29. data/lib/generators/anycable/setup/templates/Procfile.dev +3 -0
  30. data/lib/generators/anycable/setup/templates/config/anycable.yml.tt +43 -0
  31. data/lib/generators/anycable/setup/templates/config/cable.yml.tt +11 -0
  32. data/lib/generators/anycable/setup/templates/config/initializers/anycable.rb.tt +9 -0
  33. data/lib/generators/anycable/with_os_helpers.rb +55 -0
  34. metadata +45 -30
  35. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb +0 -31
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AnyCableRailsGenerators
4
+ module WithOSHelpers
5
+ OS_NAMES = %w[linux darwin freebsd win].freeze
6
+ CPU_NAMES = %w[amd64 arm64 386 arm].freeze
7
+ DEFAULT_BIN_PATH = "/usr/local/bin"
8
+
9
+ def self.included(base)
10
+ base.class_option :os,
11
+ type: :string,
12
+ desc: "Specify the OS for AnyCable-Go server binary (options: #{OS_NAMES.join(", ")})"
13
+ base.class_option :cpu,
14
+ type: :string,
15
+ desc: "Specify the CPU architecturefor AnyCable-Go server binary (options: #{CPU_NAMES.join(", ")})"
16
+
17
+ private :current_cpu, :supported_current_cpu, :supported_current_os
18
+ end
19
+
20
+ def current_cpu
21
+ case Gem::Platform.local.cpu
22
+ when "x86_64", "x64"
23
+ "amd64"
24
+ when "x86_32", "x86", "i386", "i486", "i686"
25
+ "i386"
26
+ when "aarch64", "aarch64_be", /armv8/
27
+ "arm64"
28
+ when "arm", /armv7/, /armv6/
29
+ "arm"
30
+ else
31
+ "unknown"
32
+ end
33
+ end
34
+
35
+ def os_name
36
+ options[:os] ||
37
+ supported_current_os ||
38
+ ask("What is your OS name?", limited_to: OS_NAMES)
39
+ end
40
+
41
+ def cpu_name
42
+ options[:cpu] ||
43
+ supported_current_cpu ||
44
+ ask("What is your CPU architecture?", limited_to: CPU_NAMES)
45
+ end
46
+
47
+ def supported_current_cpu
48
+ CPU_NAMES.find(&current_cpu.method(:==))
49
+ end
50
+
51
+ def supported_current_os
52
+ OS_NAMES.find(&Gem::Platform.local.os.method(:==))
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
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-02-05 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
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.0
19
+ version: 1.0.0.rc1
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: 0.6.0
26
+ version: 1.0.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,89 +39,89 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: ammeter
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.10'
47
+ version: '1.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.10'
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: pry-byebug
56
+ name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
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
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 0.67.0
103
+ version: '0.80'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.67.0
110
+ version: '0.80'
111
111
  - !ruby/object:Gem::Dependency
112
- name: simplecov
112
+ name: warden
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 0.3.8
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 0.3.8
124
+ version: '0'
125
125
  description: Rails adapter for AnyCable
126
126
  email:
127
127
  - dementiev.vm@gmail.com
@@ -138,19 +138,34 @@ files:
138
138
  - lib/anycable/rails.rb
139
139
  - lib/anycable/rails/actioncable/channel.rb
140
140
  - lib/anycable/rails/actioncable/connection.rb
141
+ - lib/anycable/rails/actioncable/connection/persistent_session.rb
142
+ - lib/anycable/rails/actioncable/connection/serializable_identification.rb
143
+ - lib/anycable/rails/actioncable/remote_connections.rb
144
+ - lib/anycable/rails/actioncable/testing.rb
145
+ - lib/anycable/rails/channel_state.rb
141
146
  - lib/anycable/rails/compatibility.rb
142
147
  - lib/anycable/rails/compatibility/rubocop.rb
143
148
  - lib/anycable/rails/compatibility/rubocop/config/default.yml
144
149
  - lib/anycable/rails/compatibility/rubocop/cops/anycable/instance_vars.rb
145
150
  - lib/anycable/rails/compatibility/rubocop/cops/anycable/periodical_timers.rb
146
- - lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb
147
151
  - lib/anycable/rails/compatibility/rubocop/cops/anycable/stream_from.rb
148
152
  - lib/anycable/rails/config.rb
149
153
  - lib/anycable/rails/middlewares/executor.rb
150
154
  - lib/anycable/rails/middlewares/log_tagging.rb
155
+ - lib/anycable/rails/rack.rb
151
156
  - lib/anycable/rails/railtie.rb
152
157
  - lib/anycable/rails/refinements/subscriptions.rb
158
+ - lib/anycable/rails/session_proxy.rb
153
159
  - lib/anycable/rails/version.rb
160
+ - lib/generators/anycable/download/USAGE
161
+ - lib/generators/anycable/download/download_generator.rb
162
+ - lib/generators/anycable/setup/USAGE
163
+ - lib/generators/anycable/setup/setup_generator.rb
164
+ - lib/generators/anycable/setup/templates/Procfile.dev
165
+ - lib/generators/anycable/setup/templates/config/anycable.yml.tt
166
+ - lib/generators/anycable/setup/templates/config/cable.yml.tt
167
+ - lib/generators/anycable/setup/templates/config/initializers/anycable.rb.tt
168
+ - lib/generators/anycable/with_os_helpers.rb
154
169
  homepage: http://github.com/anycable/anycable-rails
155
170
  licenses:
156
171
  - MIT
@@ -168,12 +183,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
183
  requirements:
169
184
  - - ">="
170
185
  - !ruby/object:Gem::Version
171
- version: '2.4'
186
+ version: '2.5'
172
187
  required_rubygems_version: !ruby/object:Gem::Requirement
173
188
  requirements:
174
- - - ">="
189
+ - - ">"
175
190
  - !ruby/object:Gem::Version
176
- version: '0'
191
+ version: 1.3.1
177
192
  requirements: []
178
193
  rubygems_version: 3.0.6
179
194
  signing_key:
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubocop"
4
-
5
- module RuboCop
6
- module Cop
7
- module AnyCable
8
- # Checks for remote disconnect usage.
9
- #
10
- # @example
11
- # # bad
12
- # class MyServive
13
- # def call(user)
14
- # ActionCable.server.remote_connections.where(current_user: user).disconnect
15
- # end
16
- # end
17
- #
18
- class RemoteDisconnect < RuboCop::Cop::Cop
19
- MSG = "Disconnecting remote clients is not supported in AnyCable"
20
-
21
- def_node_matcher :has_remote_disconnect?, <<-PATTERN
22
- (send (send (send _ :remote_connections) ...) :disconnect)
23
- PATTERN
24
-
25
- def on_send(node)
26
- add_offense(node) if has_remote_disconnect?(node)
27
- end
28
- end
29
- end
30
- end
31
- end