Use frozen string literal in actioncable/

This commit is contained in:
Kir Shatrov 2017-07-16 20:10:15 +03:00
parent 68191d0f6e
commit 385825fb70
81 changed files with 159 additions and 1 deletions

@ -89,6 +89,7 @@ Style/FrozenStringLiteralComment:
Include: Include:
- 'activesupport/**/*' - 'activesupport/**/*'
- 'activemodel/**/*' - 'activemodel/**/*'
- 'actioncable/**/*'
- 'activejob/**/*' - 'activejob/**/*'
- 'activerecord/**/*' - 'activerecord/**/*'
- 'actionmailer/**/*' - 'actionmailer/**/*'

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rake/testtask" require "rake/testtask"
require "pathname" require "pathname"
require "open3" require "open3"

@ -1,3 +1,5 @@
# frozen_string_literal: true
version = File.read(File.expand_path("../RAILS_VERSION", __dir__)).strip version = File.read(File.expand_path("../RAILS_VERSION", __dir__)).strip
Gem::Specification.new do |s| Gem::Specification.new do |s|

@ -1,4 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true
COMPONENT_ROOT = File.expand_path("..", __dir__) COMPONENT_ROOT = File.expand_path("..", __dir__)
require_relative "../../tools/test" require_relative "../../tools/test"

@ -1,3 +1,5 @@
# frozen_string_literal: true
#-- #--
# Copyright (c) 2015-2017 Basecamp, LLC # Copyright (c) 2015-2017 Basecamp, LLC
# #

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Channel module Channel
extend ActiveSupport::Autoload extend ActiveSupport::Autoload

@ -270,7 +270,7 @@ def dispatch_action(action, data)
end end
def action_signature(action, data) def action_signature(action, data)
"#{self.class.name}##{action}".tap do |signature| "#{self.class.name}##{action}".dup.tap do |signature|
if (arguments = data.except("action")).any? if (arguments = data.except("action")).any?
signature << "(#{arguments.inspect})" signature << "(#{arguments.inspect})"
end end

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/core_ext/object/to_param" require "active_support/core_ext/object/to_param"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/callbacks" require "active_support/callbacks"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Channel module Channel
module Naming module Naming

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Channel module Channel
module PeriodicTimers module PeriodicTimers

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Channel module Channel
# Streams allow channels to route broadcastings to the subscriber. A broadcasting is, as discussed elsewhere, a pubsub queue where any data # Streams allow channels to route broadcastings to the subscriber. A broadcasting is, as discussed elsewhere, a pubsub queue where any data

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Connection module Connection
extend ActiveSupport::Autoload extend ActiveSupport::Autoload

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Connection module Connection
module Authorization module Authorization

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "action_dispatch" require "action_dispatch"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "websocket/driver" require "websocket/driver"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "set" require "set"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Connection module Connection
# Makes it possible for the RemoteConnection to disconnect a specific connection. # Makes it possible for the RemoteConnection to disconnect a specific connection.

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Connection module Connection
# Allows us to buffer messages received from the WebSocket before the Connection has been fully initialized, and is ready to receive them. # Allows us to buffer messages received from the WebSocket before the Connection has been fully initialized, and is ready to receive them.

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "thread" require "thread"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "nio" require "nio"
require "thread" require "thread"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/core_ext/hash/indifferent_access" require "active_support/core_ext/hash/indifferent_access"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Connection module Connection
# Allows the use of per-connection tags against the server logger. This wouldn't work using the traditional # Allows the use of per-connection tags against the server logger. This wouldn't work using the traditional

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "websocket/driver" require "websocket/driver"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails" require "rails"
require "action_cable" require "action_cable"
require_relative "helpers/action_cable_helper" require_relative "helpers/action_cable_helper"

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
# Returns the version of the currently loaded Action Cable as a <tt>Gem::Version</tt>. # Returns the version of the currently loaded Action Cable as a <tt>Gem::Version</tt>.
def self.gem_version def self.gem_version

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Helpers module Helpers
module ActionCableHelper module ActionCableHelper

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
# If you need to disconnect a given connection, you can go through the # If you need to disconnect a given connection, you can go through the
# RemoteConnections. You can find the connections you're looking for by # RemoteConnections. You can find the connections you're looking for by

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Server module Server
extend ActiveSupport::Autoload extend ActiveSupport::Autoload

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "monitor" require "monitor"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Server module Server
# Broadcasting is how other parts of your application can send messages to a channel's subscribers. As explained in Channel, most of the time, these # Broadcasting is how other parts of your application can send messages to a channel's subscribers. As explained in Channel, most of the time, these

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Server module Server
# An instance of this configuration object is available via ActionCable.server.config, which allows you to tweak Action Cable configuration # An instance of this configuration object is available via ActionCable.server.config, which allows you to tweak Action Cable configuration

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Server module Server
# Collection class for all the connections that have been established on this specific server. Remember, usually you'll run many Action Cable servers, so # Collection class for all the connections that have been established on this specific server. Remember, usually you'll run many Action Cable servers, so

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/callbacks" require "active_support/callbacks"
require "active_support/core_ext/module/attribute_accessors_per_thread" require "active_support/core_ext/module/attribute_accessors_per_thread"
require "concurrent" require "concurrent"

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module Server module Server
class Worker class Worker

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module SubscriptionAdapter module SubscriptionAdapter
extend ActiveSupport::Autoload extend ActiveSupport::Autoload

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative "inline" require_relative "inline"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module SubscriptionAdapter module SubscriptionAdapter
class Base class Base

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module SubscriptionAdapter module SubscriptionAdapter
module ChannelPrefix # :nodoc: module ChannelPrefix # :nodoc:

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "thread" require "thread"
gem "em-hiredis", "~> 0.3.0" gem "em-hiredis", "~> 0.3.0"

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module SubscriptionAdapter module SubscriptionAdapter
class Inline < Base # :nodoc: class Inline < Base # :nodoc:

@ -1,3 +1,5 @@
# frozen_string_literal: true
gem "pg", "~> 0.18" gem "pg", "~> 0.18"
require "pg" require "pg"
require "thread" require "thread"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "thread" require "thread"
gem "redis", "~> 3.0" gem "redis", "~> 3.0"

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionCable module ActionCable
module SubscriptionAdapter module SubscriptionAdapter
class SubscriberMap class SubscriberMap

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_relative "gem_version" require_relative "gem_version"
module ActionCable module ActionCable

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Rails module Rails
module Generators module Generators
class ChannelGenerator < NamedBase class ChannelGenerator < NamedBase

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_connection" require "stubs/test_connection"
require "stubs/room" require "stubs/room"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_connection" require "stubs/test_connection"
require "stubs/room" require "stubs/room"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
class ActionCable::Channel::NamingTest < ActiveSupport::TestCase class ActionCable::Channel::NamingTest < ActiveSupport::TestCase

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_connection" require "stubs/test_connection"
require "stubs/room" require "stubs/room"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_connection" require "stubs/test_connection"
require "stubs/room" require "stubs/room"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_connection" require "stubs/test_connection"
require "stubs/room" require "stubs/room"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "concurrent" require "concurrent"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"
require "active_support/core_ext/object/json" require "active_support/core_ext/object/json"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"
require "stubs/user" require "stubs/user"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"
require "stubs/user" require "stubs/user"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase class ActionCable::Connection::SubscriptionsTest < ActionCable::TestCase

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"
require "active_support/core_ext/hash/indifferent_access" require "active_support/core_ext/hash/indifferent_access"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GlobalID class GlobalID
attr_reader :uri attr_reader :uri
delegate :to_param, :to_s, to: :uri delegate :to_param, :to_s, to: :uri

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Room class Room
attr_reader :id, :name attr_reader :id, :name

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SuccessAdapter < ActionCable::SubscriptionAdapter::Base class SuccessAdapter < ActionCable::SubscriptionAdapter::Base
def broadcast(channel, payload) def broadcast(channel, payload)
end end

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "stubs/user" require "stubs/user"
class TestConnection class TestConnection

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "ostruct" require "ostruct"
class TestServer class TestServer

@ -1,3 +1,5 @@
# frozen_string_literal: true
class User class User
attr_reader :name attr_reader :name

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require_relative "common" require_relative "common"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "stubs/test_server" require "stubs/test_server"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
class ActionCable::Server::WithIndependentConfig < ActionCable::Server::Base class ActionCable::Server::WithIndependentConfig < ActionCable::Server::Base

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require "concurrent" require "concurrent"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require_relative "common" require_relative "common"
require_relative "channel_prefix" require_relative "channel_prefix"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require_relative "common" require_relative "common"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require_relative "common" require_relative "common"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
require_relative "common" require_relative "common"
require_relative "channel_prefix" require_relative "channel_prefix"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
class SubscriberMapTest < ActionCable::TestCase class SubscriberMapTest < ActionCable::TestCase

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "action_cable" require "action_cable"
require "active_support/testing/autorun" require "active_support/testing/autorun"

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "test_helper" require "test_helper"
class WorkerTest < ActiveSupport::TestCase class WorkerTest < ActiveSupport::TestCase