actioncable 5.0.0.rc1 → 5.0.0.rc2

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
  SHA1:
3
- metadata.gz: 09ca86b01cffaa07735637d919a21948f661b818
4
- data.tar.gz: f6b7fb38210c814dcf40d48ec7c27b88faa3eba5
3
+ metadata.gz: c6b94adefd33df52bd3071fc352f3e02005f5f3d
4
+ data.tar.gz: a92b0ef36b341b4c69e886c74aca629187ba6237
5
5
  SHA512:
6
- metadata.gz: fbba1cf208048a75ac161e122f9fbb718d41d86141f33ec015101696914d15cb3468515cc2f35458aeb760cc5b2d3b2f37c6e4016cfaa12c44df8452cd06aeec
7
- data.tar.gz: 69576050fbc1a908d31ae9f31d19ea2858a7df51fb8f45828e02ebd56929b720e8541013fda65b03af36cee01c76042845463829f0ccfd510a7499bd16d4460c
6
+ metadata.gz: af38e63777c21351f22aa57d2f5599a6bc39fffb2ba39950c57c46c93f23ebbef390b8290bc9cf68e464004d2aab1b9d47f447cf33fb3527250fbb3e58175759
7
+ data.tar.gz: 771f3def063419544f25963795cb3c972467a7de86d5f002be0147922399ed353ad602c924aaeb299174df7734aace7a22d1811d05460e0cbc419989f9837ad8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## Rails 5.0.0.rc2 (June 22, 2016) ##
2
+
3
+
4
+ * Fix development reloading support: new cable connections are now correctly
5
+ dispatched to the reloaded channel class, instead of using a cached reference
6
+ to the originally-loaded version.
7
+
8
+ *Matthew Draper*
9
+
10
+
1
11
  ## Rails 5.0.0.rc1 (May 06, 2016) ##
2
12
 
3
13
  * No changes.
@@ -26,12 +26,12 @@ module ActionCable
26
26
  id_key = data['identifier']
27
27
  id_options = ActiveSupport::JSON.decode(id_key).with_indifferent_access
28
28
 
29
- subscription_klass = connection.server.channel_classes[id_options[:channel]]
29
+ subscription_klass = id_options[:channel].safe_constantize
30
30
 
31
- if subscription_klass
31
+ if subscription_klass && ActionCable::Channel::Base >= subscription_klass
32
32
  subscriptions[id_key] ||= subscription_klass.new(connection, id_key, id_options)
33
33
  else
34
- logger.error "Subscription class not found (#{data.inspect})"
34
+ logger.error "Subscription class not found: #{id_options[:channel].inspect}"
35
35
  end
36
36
  end
37
37
 
@@ -31,11 +31,8 @@ module ActionCable
31
31
  self.cable = Rails.application.config_for(config_path).with_indifferent_access
32
32
  end
33
33
 
34
- if 'ApplicationCable::Connection'.safe_constantize
35
- self.connection_class = ApplicationCable::Connection
36
- end
37
-
38
- self.channel_paths = Rails.application.paths['app/channels'].existent
34
+ previous_connection_class = self.connection_class
35
+ self.connection_class = -> { 'ApplicationCable::Connection'.safe_constantize || previous_connection_class.call }
39
36
 
40
37
  options.each { |k,v| send("#{k}=", v) }
41
38
  end
@@ -8,7 +8,7 @@ module ActionCable
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
10
  TINY = 0
11
- PRE = "rc1"
11
+ PRE = "rc2"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -19,13 +19,13 @@ module ActionCable
19
19
 
20
20
  def initialize
21
21
  @mutex = Monitor.new
22
- @remote_connections = @event_loop = @worker_pool = @channel_classes = @pubsub = nil
22
+ @remote_connections = @event_loop = @worker_pool = @pubsub = nil
23
23
  end
24
24
 
25
25
  # Called by Rack to setup the server.
26
26
  def call(env)
27
27
  setup_heartbeat_timer
28
- config.connection_class.new(self, env).process
28
+ config.connection_class.call.new(self, env).process
29
29
  end
30
30
 
31
31
  # Disconnect all the connections identified by `identifiers` on this server or any others via RemoteConnections.
@@ -67,16 +67,6 @@ module ActionCable
67
67
  @worker_pool || @mutex.synchronize { @worker_pool ||= ActionCable::Server::Worker.new(max_size: config.worker_pool_size) }
68
68
  end
69
69
 
70
- # Requires and returns a hash of all of the channel class constants, which are keyed by name.
71
- def channel_classes
72
- @channel_classes || @mutex.synchronize do
73
- @channel_classes ||= begin
74
- config.channel_paths.each { |channel_path| require channel_path }
75
- config.channel_class_names.each_with_object({}) { |name, hash| hash[name] = name.constantize }
76
- end
77
- end
78
- end
79
-
80
70
  # Adapter used for all streams/broadcasting.
81
71
  def pubsub
82
72
  @pubsub || @mutex.synchronize { @pubsub ||= config.pubsub_adapter.new(self) }
@@ -84,7 +74,7 @@ module ActionCable
84
74
 
85
75
  # All of the identifiers applied to the connection class associated with this server.
86
76
  def connection_identifiers
87
- config.connection_class.identifiers
77
+ config.connection_class.call.identifiers
88
78
  end
89
79
  end
90
80
 
@@ -8,23 +8,15 @@ module ActionCable
8
8
  attr_accessor :disable_request_forgery_protection, :allowed_request_origins
9
9
  attr_accessor :cable, :url, :mount_path
10
10
 
11
- attr_accessor :channel_paths # :nodoc:
12
-
13
11
  def initialize
14
12
  @log_tags = []
15
13
 
16
- @connection_class = ActionCable::Connection::Base
14
+ @connection_class = -> { ActionCable::Connection::Base }
17
15
  @worker_pool_size = 4
18
16
 
19
17
  @disable_request_forgery_protection = false
20
18
  end
21
19
 
22
- def channel_class_names
23
- @channel_class_names ||= channel_paths.collect do |channel_path|
24
- Pathname.new(channel_path).basename.to_s.split('.').first.camelize
25
- end
26
- end
27
-
28
20
  # Returns constant of subscription adapter specified in config/cable.yml.
29
21
  # If the adapter cannot be found, this will default to the Redis adapter.
30
22
  # Also makes sure proper dependencies are required.
@@ -16,7 +16,8 @@ module Rails
16
16
  if self.behavior == :invoke
17
17
  template "assets/cable.js", "app/assets/javascripts/cable.js"
18
18
  end
19
- template "assets/channel.coffee", File.join('app/assets/javascripts/channels', class_path, "#{file_name}.coffee")
19
+
20
+ js_template "assets/channel", File.join('app/assets/javascripts/channels', class_path, "#{file_name}")
20
21
  end
21
22
 
22
23
  generate_application_cable_files
@@ -0,0 +1,18 @@
1
+ App.<%= class_name.underscore %> = App.cable.subscriptions.create("<%= class_name %>Channel", {
2
+ connected: function() {
3
+ // Called when the subscription is ready for use on the server
4
+ },
5
+
6
+ disconnected: function() {
7
+ // Called when the subscription has been terminated by the server
8
+ },
9
+
10
+ received: function(data) {
11
+ // Called when there's incoming data on the websocket for this channel
12
+ }<%= actions.any? ? ",\n" : '' %>
13
+ <% actions.each do |action| -%>
14
+ <%=action %>: function() {
15
+ return this.perform('<%= action %>');
16
+ }<%= action == actions[-1] ? '' : ",\n" %>
17
+ <% end -%>
18
+ });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actioncable
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.rc1
4
+ version: 5.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pratik Naik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-06 00:00:00.000000000 Z
12
+ date: 2016-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 5.0.0.rc1
20
+ version: 5.0.0.rc2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 5.0.0.rc1
27
+ version: 5.0.0.rc2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: nio4r
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 0.6.1
56
+ - !ruby/object:Gem::Dependency
57
+ name: blade
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.5.1
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 0.5.1
56
70
  description: Structure many real-time application concerns into channels over a single
57
71
  WebSocket connection.
58
72
  email:
@@ -114,6 +128,7 @@ files:
114
128
  - lib/rails/generators/channel/templates/application_cable/connection.rb
115
129
  - lib/rails/generators/channel/templates/assets/cable.js
116
130
  - lib/rails/generators/channel/templates/assets/channel.coffee
131
+ - lib/rails/generators/channel/templates/assets/channel.js
117
132
  - lib/rails/generators/channel/templates/channel.rb
118
133
  homepage: http://rubyonrails.org
119
134
  licenses:
@@ -135,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
150
  version: 1.3.1
136
151
  requirements: []
137
152
  rubyforge_project:
138
- rubygems_version: 2.5.1
153
+ rubygems_version: 2.6.4
139
154
  signing_key:
140
155
  specification_version: 4
141
156
  summary: WebSocket framework for Rails.