From 72573066231be9c2e392747a5c6af738bff34e4c Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Tue, 6 Dec 2016 09:41:39 -0600 Subject: ActionCable::Connection::Base doc code sample syntax error --- actioncable/lib/action_cable/connection/base.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'actioncable') diff --git a/actioncable/lib/action_cable/connection/base.rb b/actioncable/lib/action_cable/connection/base.rb index dfee123ea2..e1da126d64 100644 --- a/actioncable/lib/action_cable/connection/base.rb +++ b/actioncable/lib/action_cable/connection/base.rb @@ -24,11 +24,8 @@ module ActionCable # # protected # def find_verified_user - # if current_user = User.find_by_identity cookies.signed[:identity_id] - # current_user - # else + # User.find_by_identity(cookies.signed[:identity_id]) || # reject_unauthorized_connection - # end # end # end # end -- cgit v1.2.3 From 2b39b5bfa16821d735049f50aa32aea8dd2f7e23 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Monti Date: Mon, 19 Dec 2016 12:31:42 -0300 Subject: Fix typo in channel generator usage message --- actioncable/lib/rails/generators/channel/USAGE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actioncable') diff --git a/actioncable/lib/rails/generators/channel/USAGE b/actioncable/lib/rails/generators/channel/USAGE index 6249553c22..dd109fda80 100644 --- a/actioncable/lib/rails/generators/channel/USAGE +++ b/actioncable/lib/rails/generators/channel/USAGE @@ -3,7 +3,7 @@ Description: Stubs out a new cable channel for the server (in Ruby) and client (in CoffeeScript). Pass the channel name, either CamelCased or under_scored, and an optional list of channel actions as arguments. - Note: Turn on the cable connection in app/assets/javascript/cable.js after generating any channels. + Note: Turn on the cable connection in app/assets/javascripts/cable.js after generating any channels. Example: ======== @@ -11,4 +11,4 @@ Example: creates a Chat channel class and CoffeeScript asset: Channel: app/channels/chat_channel.rb - Assets: app/assets/javascript/channels/chat.coffee + Assets: app/assets/javascripts/channels/chat.coffee -- cgit v1.2.3 From 21e5fd4a2a1c162ad33708d3e01b1fda165f204d Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Mon, 19 Dec 2016 19:10:49 +0900 Subject: Describe what we are protecting --- actioncable/lib/action_cable/connection/base.rb | 2 ++ actioncable/lib/action_cable/connection/message_buffer.rb | 2 ++ actioncable/lib/action_cable/connection/subscriptions.rb | 2 ++ actioncable/lib/action_cable/connection/web_socket.rb | 2 ++ 4 files changed, 8 insertions(+) (limited to 'actioncable') diff --git a/actioncable/lib/action_cable/connection/base.rb b/actioncable/lib/action_cable/connection/base.rb index e1da126d64..6d94b0eab0 100644 --- a/actioncable/lib/action_cable/connection/base.rb +++ b/actioncable/lib/action_cable/connection/base.rb @@ -133,6 +133,8 @@ module ActionCable send_async :handle_close end + # TODO Change this to private once we've dropped Ruby 2.2 support. + # Workaround for Ruby 2.2 "private attribute?" warning. protected # The request that initiated the WebSocket connection is available here. This gives access to the environment, cookies, etc. def request diff --git a/actioncable/lib/action_cable/connection/message_buffer.rb b/actioncable/lib/action_cable/connection/message_buffer.rb index 6a80770cae..4ccd322644 100644 --- a/actioncable/lib/action_cable/connection/message_buffer.rb +++ b/actioncable/lib/action_cable/connection/message_buffer.rb @@ -28,6 +28,8 @@ module ActionCable receive_buffered_messages end + # TODO Change this to private once we've dropped Ruby 2.2 support. + # Workaround for Ruby 2.2 "private attribute?" warning. protected attr_reader :connection attr_reader :buffered_messages diff --git a/actioncable/lib/action_cable/connection/subscriptions.rb b/actioncable/lib/action_cable/connection/subscriptions.rb index 00511aead5..abf42c99d5 100644 --- a/actioncable/lib/action_cable/connection/subscriptions.rb +++ b/actioncable/lib/action_cable/connection/subscriptions.rb @@ -61,6 +61,8 @@ module ActionCable subscriptions.each { |id, channel| remove_subscription(channel) } end + # TODO Change this to private once we've dropped Ruby 2.2 support. + # Workaround for Ruby 2.2 "private attribute?" warning. protected attr_reader :connection, :subscriptions diff --git a/actioncable/lib/action_cable/connection/web_socket.rb b/actioncable/lib/action_cable/connection/web_socket.rb index 382141b89f..03eb6e2ea8 100644 --- a/actioncable/lib/action_cable/connection/web_socket.rb +++ b/actioncable/lib/action_cable/connection/web_socket.rb @@ -32,6 +32,8 @@ module ActionCable websocket.rack_response end + # TODO Change this to private once we've dropped Ruby 2.2 support. + # Workaround for Ruby 2.2 "private attribute?" warning. protected attr_reader :websocket end -- cgit v1.2.3 From 79c17a2d913821e8bb32127e7f435a6d4e3ed058 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 23 Dec 2016 23:44:10 +0900 Subject: Privatize unneededly protected methods in Action Cable tests --- actioncable/test/connection/identifier_test.rb | 2 +- actioncable/test/connection/multiple_identifiers_test.rb | 2 +- actioncable/test/connection/string_identifier_test.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'actioncable') diff --git a/actioncable/test/connection/identifier_test.rb b/actioncable/test/connection/identifier_test.rb index a4dfcc06f0..f3d3bc0603 100644 --- a/actioncable/test/connection/identifier_test.rb +++ b/actioncable/test/connection/identifier_test.rb @@ -53,7 +53,7 @@ class ActionCable::Connection::IdentifierTest < ActionCable::TestCase end end - protected + private def open_connection_with_stubbed_pubsub server = TestServer.new server.stubs(:adapter).returns(stub_everything("adapter")) diff --git a/actioncable/test/connection/multiple_identifiers_test.rb b/actioncable/test/connection/multiple_identifiers_test.rb index 67e68355c5..ca1a08f4d6 100644 --- a/actioncable/test/connection/multiple_identifiers_test.rb +++ b/actioncable/test/connection/multiple_identifiers_test.rb @@ -19,7 +19,7 @@ class ActionCable::Connection::MultipleIdentifiersTest < ActionCable::TestCase end end - protected + private def open_connection_with_stubbed_pubsub server = TestServer.new server.stubs(:pubsub).returns(stub_everything("pubsub")) diff --git a/actioncable/test/connection/string_identifier_test.rb b/actioncable/test/connection/string_identifier_test.rb index 87484765e5..6d53e249cb 100644 --- a/actioncable/test/connection/string_identifier_test.rb +++ b/actioncable/test/connection/string_identifier_test.rb @@ -21,7 +21,7 @@ class ActionCable::Connection::StringIdentifierTest < ActionCable::TestCase end end - protected + private def open_connection_with_stubbed_pubsub @server = TestServer.new @server.stubs(:pubsub).returns(stub_everything("pubsub")) -- cgit v1.2.3 From 91fa2b71c3fecb26a1dc7836874478f12e6d7a02 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 22 Dec 2016 19:16:38 +0900 Subject: Privatize unneededly protected methods in Action Cable --- actioncable/README.md | 2 +- actioncable/lib/action_cable/channel/base.rb | 27 +++++++++++----------- actioncable/lib/action_cable/connection/base.rb | 14 +++++------ .../action_cable/connection/tagged_logger_proxy.rb | 4 ++-- .../rails/generators/channel/channel_generator.rb | 2 +- 5 files changed, 24 insertions(+), 25 deletions(-) (limited to 'actioncable') diff --git a/actioncable/README.md b/actioncable/README.md index 8ad9aeb1f1..cccb55a196 100644 --- a/actioncable/README.md +++ b/actioncable/README.md @@ -51,7 +51,7 @@ module ApplicationCable self.current_user = find_verified_user end - protected + private def find_verified_user if current_user = User.find_by(id: cookies.signed[:user_id]) current_user diff --git a/actioncable/lib/action_cable/channel/base.rb b/actioncable/lib/action_cable/channel/base.rb index a866044f95..6739a62ba0 100644 --- a/actioncable/lib/action_cable/channel/base.rb +++ b/actioncable/lib/action_cable/channel/base.rb @@ -122,16 +122,16 @@ module ActionCable end end - protected + private # action_methods are cached and there is sometimes need to refresh # them. ::clear_action_methods! allows you to do that, so next time # you run action_methods, they will be recalculated. - def clear_action_methods! + def clear_action_methods! # :doc: @action_methods = nil end # Refresh the cached action_methods when a new action_method is added. - def method_added(name) + def method_added(name) # :doc: super clear_action_methods! end @@ -189,22 +189,22 @@ module ActionCable end end - protected + private # Called once a consumer has become a subscriber of the channel. Usually the place to setup any streams # you want this channel to be sending to the subscriber. - def subscribed + def subscribed # :doc: # Override in subclasses end # Called once a consumer has cut its cable connection. Can be used for cleaning up connections or marking # users as offline or the like. - def unsubscribed + def unsubscribed # :doc: # Override in subclasses end # Transmit a hash of data to the subscriber. The hash will automatically be wrapped in a JSON envelope with # the proper channel identifier marked as the recipient. - def transmit(data, via: nil) + def transmit(data, via: nil) # :doc: logger.info "#{self.class.name} transmitting #{data.inspect.truncate(300)}".tap { |m| m << " (via #{via})" if via } payload = { channel_class: self.class.name, data: data, via: via } @@ -213,33 +213,32 @@ module ActionCable end end - def ensure_confirmation_sent + def ensure_confirmation_sent # :doc: return if subscription_rejected? @defer_subscription_confirmation_counter.decrement transmit_subscription_confirmation unless defer_subscription_confirmation? end - def defer_subscription_confirmation! + def defer_subscription_confirmation! # :doc: @defer_subscription_confirmation_counter.increment end - def defer_subscription_confirmation? + def defer_subscription_confirmation? # :doc: @defer_subscription_confirmation_counter.value > 0 end - def subscription_confirmation_sent? + def subscription_confirmation_sent? # :doc: @subscription_confirmation_sent end - def reject + def reject # :doc: @reject_subscription = true end - def subscription_rejected? + def subscription_rejected? # :doc: @reject_subscription end - private def delegate_connection_identifiers connection.identifiers.each do |identifier| define_singleton_method(identifier) do diff --git a/actioncable/lib/action_cable/connection/base.rb b/actioncable/lib/action_cable/connection/base.rb index 6d94b0eab0..0a517a532d 100644 --- a/actioncable/lib/action_cable/connection/base.rb +++ b/actioncable/lib/action_cable/connection/base.rb @@ -22,7 +22,7 @@ module ActionCable # # Any cleanup work needed when the cable connection is cut. # end # - # protected + # private # def find_verified_user # User.find_by_identity(cookies.signed[:identity_id]) || # reject_unauthorized_connection @@ -136,8 +136,12 @@ module ActionCable # TODO Change this to private once we've dropped Ruby 2.2 support. # Workaround for Ruby 2.2 "private attribute?" warning. protected + attr_reader :websocket + attr_reader :message_buffer + + private # The request that initiated the WebSocket connection is available here. This gives access to the environment, cookies, etc. - def request + def request # :doc: @request ||= begin environment = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application ActionDispatch::Request.new(environment || env) @@ -145,14 +149,10 @@ module ActionCable end # The cookies of the request that initiated the WebSocket connection. Useful for performing authorization checks. - def cookies + def cookies # :doc: request.cookie_jar end - attr_reader :websocket - attr_reader :message_buffer - - private def encode(cable_message) @coder.encode cable_message end diff --git a/actioncable/lib/action_cable/connection/tagged_logger_proxy.rb b/actioncable/lib/action_cable/connection/tagged_logger_proxy.rb index 41afa9680a..aef549aa86 100644 --- a/actioncable/lib/action_cable/connection/tagged_logger_proxy.rb +++ b/actioncable/lib/action_cable/connection/tagged_logger_proxy.rb @@ -31,8 +31,8 @@ module ActionCable end end - protected - def log(type, message) + private + def log(type, message) # :doc: tag(@logger) { @logger.send type, message } end end diff --git a/actioncable/lib/rails/generators/channel/channel_generator.rb b/actioncable/lib/rails/generators/channel/channel_generator.rb index 20d807c033..04b787c3a4 100644 --- a/actioncable/lib/rails/generators/channel/channel_generator.rb +++ b/actioncable/lib/rails/generators/channel/channel_generator.rb @@ -23,7 +23,7 @@ module Rails generate_application_cable_files end - protected + private def file_name @_file_name ||= super.gsub(/_channel/i, "") end -- cgit v1.2.3 From d99c772da0d22a1651445fe953c386b1e528f728 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Tue, 27 Dec 2016 08:41:28 -0500 Subject: Small edits to actioncable/CHANGELOG.md [ci skip] - capitalize WebSocket --- actioncable/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actioncable') diff --git a/actioncable/CHANGELOG.md b/actioncable/CHANGELOG.md index 2c84d3158f..4f17274a01 100644 --- a/actioncable/CHANGELOG.md +++ b/actioncable/CHANGELOG.md @@ -13,12 +13,12 @@ *Vladimir Dementyev* -* Buffer now writes to websocket connections, to avoid blocking threads +* Buffer now writes to WebSocket connections, to avoid blocking threads that could be doing more useful things. *Matthew Draper*, *Tinco Andringa* -* Protect against concurrent writes to a websocket connection from +* Protect against concurrent writes to a WebSocket connection from multiple threads; the underlying OS write is not always threadsafe. *Tinco Andringa* -- cgit v1.2.3 From c434b97628e414d8c8ad27894e3ebecb51b32e2b Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 28 Dec 2016 19:45:39 -0800 Subject: Upgrade to nio4r 2.0.0 nio4r 2.0.0 primarily includes new features and bugfixes, with few breaking changes. The primary reason for bumping the major version is dropping support for all Ruby versions prior to 2.2.2, so as to match Rails 5. Full release announcement here: https://groups.google.com/forum/#!topic/socketry/ZDIUj1ufiJ8 --- actioncable/actioncable.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actioncable') diff --git a/actioncable/actioncable.gemspec b/actioncable/actioncable.gemspec index e7f91d0e34..6d95f022fa 100644 --- a/actioncable/actioncable.gemspec +++ b/actioncable/actioncable.gemspec @@ -20,6 +20,6 @@ Gem::Specification.new do |s| s.add_dependency "actionpack", version - s.add_dependency "nio4r", "~> 1.2" + s.add_dependency "nio4r", "~> 2.0" s.add_dependency "websocket-driver", "~> 0.6.1" end -- cgit v1.2.3