From 89e097fa46687706b0095db228bfe9d92de7e0ce Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Fri, 12 May 2017 15:37:40 +0900 Subject: Suppress `warning: assigned but unused variable - stdout` --- actioncable/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actioncable') diff --git a/actioncable/Rakefile b/actioncable/Rakefile index bda8c7b6c8..0ee1a859e5 100644 --- a/actioncable/Rakefile +++ b/actioncable/Rakefile @@ -65,7 +65,7 @@ namespace :assets do end print "[verify] #{dir} can be required as a module " - stdout, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{dir}');") + _, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{dir}');") if status.success? puts "[OK]" else -- cgit v1.2.3 From f31ad74f7b102bdc0730cd70b42e5f92f4479a23 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 21 May 2017 12:34:38 +0900 Subject: identifiers is already defined via Connection::Identification module --- actioncable/lib/action_cable/remote_connections.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actioncable') diff --git a/actioncable/lib/action_cable/remote_connections.rb b/actioncable/lib/action_cable/remote_connections.rb index d2856bc6ae..e689fbf21b 100644 --- a/actioncable/lib/action_cable/remote_connections.rb +++ b/actioncable/lib/action_cable/remote_connections.rb @@ -45,7 +45,7 @@ module ActionCable end # Returns all the identifiers that were applied to this connection. - def identifiers + redefine_method :identifiers do server.connection_identifiers end -- cgit v1.2.3 From 40bdbce191ad90dfea43dad51fac5c4726b89392 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Mon, 15 May 2017 14:17:28 +0000 Subject: Define path with __dir__ ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f --- actioncable/README.md | 2 +- actioncable/Rakefile | 10 ++++------ actioncable/actioncable.gemspec | 2 +- actioncable/lib/rails/generators/channel/channel_generator.rb | 2 +- actioncable/test/test_helper.rb | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) (limited to 'actioncable') diff --git a/actioncable/README.md b/actioncable/README.md index e044f54b45..d14f20d75b 100644 --- a/actioncable/README.md +++ b/actioncable/README.md @@ -409,7 +409,7 @@ application. The recommended basic setup is as follows: ```ruby # cable/config.ru -require ::File.expand_path('../../config/environment', __FILE__) +require ::File.expand_path('../config/environment', __dir__) Rails.application.eager_load! run ActionCable.server diff --git a/actioncable/Rakefile b/actioncable/Rakefile index 0ee1a859e5..e21843bb44 100644 --- a/actioncable/Rakefile +++ b/actioncable/Rakefile @@ -3,15 +3,13 @@ require "pathname" require "open3" require "action_cable" -dir = File.dirname(__FILE__) - task default: :test task package: %w( assets:compile assets:verify ) Rake::TestTask.new do |t| t.libs << "test" - t.test_files = Dir.glob("#{dir}/test/**/*_test.rb") + t.test_files = Dir.glob("#{__dir__}/test/**/*_test.rb") t.warning = true t.verbose = true t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION) @@ -46,7 +44,7 @@ namespace :assets do desc "Verify compiled Action Cable assets" task :verify do file = "lib/assets/compiled/action_cable.js" - pathname = Pathname.new("#{dir}/#{file}") + pathname = Pathname.new("#{__dir__}/#{file}") print "[verify] #{file} exists " if pathname.exist? @@ -64,8 +62,8 @@ namespace :assets do fail end - print "[verify] #{dir} can be required as a module " - _, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{dir}');") + print "[verify] #{__dir__} can be required as a module " + _, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{__dir__}');") if status.success? puts "[OK]" else diff --git a/actioncable/actioncable.gemspec b/actioncable/actioncable.gemspec index 6d95f022fa..05ffd655e8 100644 --- a/actioncable/actioncable.gemspec +++ b/actioncable/actioncable.gemspec @@ -1,4 +1,4 @@ -version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip +version = File.read(File.expand_path("../RAILS_VERSION", __dir__)).strip Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY diff --git a/actioncable/lib/rails/generators/channel/channel_generator.rb b/actioncable/lib/rails/generators/channel/channel_generator.rb index 984b78bc9c..80f512c94c 100644 --- a/actioncable/lib/rails/generators/channel/channel_generator.rb +++ b/actioncable/lib/rails/generators/channel/channel_generator.rb @@ -1,7 +1,7 @@ module Rails module Generators class ChannelGenerator < NamedBase - source_root File.expand_path("../templates", __FILE__) + source_root File.expand_path("templates", __dir__) argument :actions, type: :array, default: [], banner: "method method" diff --git a/actioncable/test/test_helper.rb b/actioncable/test/test_helper.rb index a47032753b..5d246c2b76 100644 --- a/actioncable/test/test_helper.rb +++ b/actioncable/test/test_helper.rb @@ -11,7 +11,7 @@ rescue LoadError end # Require all the stubs and models -Dir[File.dirname(__FILE__) + "/stubs/*.rb"].each { |file| require file } +Dir[File.expand_path("stubs/*.rb", __dir__)].each { |file| require file } class ActionCable::TestCase < ActiveSupport::TestCase def wait_for_async -- cgit v1.2.3 From 1c275d812f35f53f93cd96184a4f319983766cc5 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 29 May 2017 18:01:50 +0200 Subject: Add option for class_attribute default (#29270) * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation --- actioncable/lib/action_cable/channel/periodic_timers.rb | 3 +-- actioncable/lib/action_cable/connection/identification.rb | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'actioncable') diff --git a/actioncable/lib/action_cable/channel/periodic_timers.rb b/actioncable/lib/action_cable/channel/periodic_timers.rb index c9daa0bcd3..90c68cfe84 100644 --- a/actioncable/lib/action_cable/channel/periodic_timers.rb +++ b/actioncable/lib/action_cable/channel/periodic_timers.rb @@ -4,8 +4,7 @@ module ActionCable extend ActiveSupport::Concern included do - class_attribute :periodic_timers, instance_reader: false - self.periodic_timers = [] + class_attribute :periodic_timers, instance_reader: false, default: [] after_subscribe :start_periodic_timers after_unsubscribe :stop_periodic_timers diff --git a/actioncable/lib/action_cable/connection/identification.rb b/actioncable/lib/action_cable/connection/identification.rb index c91a1d1fd7..ffab359429 100644 --- a/actioncable/lib/action_cable/connection/identification.rb +++ b/actioncable/lib/action_cable/connection/identification.rb @@ -6,8 +6,7 @@ module ActionCable extend ActiveSupport::Concern included do - class_attribute :identifiers - self.identifiers = Set.new + class_attribute :identifiers, default: Set.new end class_methods do -- cgit v1.2.3 From b6b0c99ff3e8ace3f42813154dbe4b8ad6a98e6c Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Wed, 31 May 2017 12:16:20 +0300 Subject: Use mattr_accessor default: option throughout the project --- actioncable/lib/action_cable/server/base.rb | 2 +- actioncable/lib/action_cable/subscription_adapter/evented_redis.rb | 4 ++-- actioncable/lib/action_cable/subscription_adapter/redis.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'actioncable') diff --git a/actioncable/lib/action_cable/server/base.rb b/actioncable/lib/action_cable/server/base.rb index 419eccd73c..3b3a17a532 100644 --- a/actioncable/lib/action_cable/server/base.rb +++ b/actioncable/lib/action_cable/server/base.rb @@ -10,7 +10,7 @@ module ActionCable include ActionCable::Server::Broadcasting include ActionCable::Server::Connections - cattr_accessor(:config, instance_accessor: true) { ActionCable::Server::Configuration.new } + cattr_accessor :config, instance_accessor: true, default: ActionCable::Server::Configuration.new def self.logger; config.logger; end delegate :logger, to: :config diff --git a/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb b/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb index ed8f315791..ae71708240 100644 --- a/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb +++ b/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb @@ -17,11 +17,11 @@ module ActionCable # Overwrite this factory method for EventMachine Redis connections if you want to use a different Redis connection library than EM::Hiredis. # This is needed, for example, when using Makara proxies for distributed Redis. - cattr_accessor(:em_redis_connector) { ->(config) { EM::Hiredis.connect(config[:url]) } } + cattr_accessor :em_redis_connector, default: ->(config) { EM::Hiredis.connect(config[:url]) } # Overwrite this factory method for Redis connections if you want to use a different Redis connection library than Redis. # This is needed, for example, when using Makara proxies for distributed Redis. - cattr_accessor(:redis_connector) { ->(config) { ::Redis.new(url: config[:url]) } } + cattr_accessor :redis_connector, default: ->(config) { ::Redis.new(url: config[:url]) } def initialize(*) ActiveSupport::Deprecation.warn(<<-MSG.squish) diff --git a/actioncable/lib/action_cable/subscription_adapter/redis.rb b/actioncable/lib/action_cable/subscription_adapter/redis.rb index 41a6e55822..a31ed33bdb 100644 --- a/actioncable/lib/action_cable/subscription_adapter/redis.rb +++ b/actioncable/lib/action_cable/subscription_adapter/redis.rb @@ -10,7 +10,7 @@ module ActionCable # Overwrite this factory method for redis connections if you want to use a different Redis library than Redis. # This is needed, for example, when using Makara proxies for distributed Redis. - cattr_accessor(:redis_connector) { ->(config) { ::Redis.new(url: config[:url]) } } + cattr_accessor :redis_connector, default: ->(config) { ::Redis.new(url: config[:url]) } def initialize(*) super -- cgit v1.2.3 From 6673cf7071094e87d473459452a2d0e4c2ccfebe Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Sun, 11 Jun 2017 15:59:23 +0300 Subject: Use `require_relative` instead of `require` with full path --- actioncable/README.md | 2 +- actioncable/bin/test | 2 +- actioncable/test/subscription_adapter/async_test.rb | 2 +- actioncable/test/subscription_adapter/evented_redis_test.rb | 4 ++-- actioncable/test/subscription_adapter/inline_test.rb | 2 +- actioncable/test/subscription_adapter/postgresql_test.rb | 2 +- actioncable/test/subscription_adapter/redis_test.rb | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'actioncable') diff --git a/actioncable/README.md b/actioncable/README.md index d14f20d75b..6946dbefb0 100644 --- a/actioncable/README.md +++ b/actioncable/README.md @@ -409,7 +409,7 @@ application. The recommended basic setup is as follows: ```ruby # cable/config.ru -require ::File.expand_path('../config/environment', __dir__) +require_relative '../config/environment' Rails.application.eager_load! run ActionCable.server diff --git a/actioncable/bin/test b/actioncable/bin/test index a7beb14b27..470ce93f10 100755 --- a/actioncable/bin/test +++ b/actioncable/bin/test @@ -1,4 +1,4 @@ #!/usr/bin/env ruby COMPONENT_ROOT = File.expand_path("..", __dir__) -require File.expand_path("../tools/test", COMPONENT_ROOT) +require_relative "../../tools/test" diff --git a/actioncable/test/subscription_adapter/async_test.rb b/actioncable/test/subscription_adapter/async_test.rb index 7bc2e55d40..8a447c7a4f 100644 --- a/actioncable/test/subscription_adapter/async_test.rb +++ b/actioncable/test/subscription_adapter/async_test.rb @@ -1,5 +1,5 @@ require "test_helper" -require_relative "./common" +require_relative "common" class AsyncAdapterTest < ActionCable::TestCase include CommonSubscriptionAdapterTest diff --git a/actioncable/test/subscription_adapter/evented_redis_test.rb b/actioncable/test/subscription_adapter/evented_redis_test.rb index 256458bc24..5453511549 100644 --- a/actioncable/test/subscription_adapter/evented_redis_test.rb +++ b/actioncable/test/subscription_adapter/evented_redis_test.rb @@ -1,6 +1,6 @@ require "test_helper" -require_relative "./common" -require_relative "./channel_prefix" +require_relative "common" +require_relative "channel_prefix" class EventedRedisAdapterTest < ActionCable::TestCase include CommonSubscriptionAdapterTest diff --git a/actioncable/test/subscription_adapter/inline_test.rb b/actioncable/test/subscription_adapter/inline_test.rb index 52bfa00aba..eafa3df2df 100644 --- a/actioncable/test/subscription_adapter/inline_test.rb +++ b/actioncable/test/subscription_adapter/inline_test.rb @@ -1,5 +1,5 @@ require "test_helper" -require_relative "./common" +require_relative "common" class InlineAdapterTest < ActionCable::TestCase include CommonSubscriptionAdapterTest diff --git a/actioncable/test/subscription_adapter/postgresql_test.rb b/actioncable/test/subscription_adapter/postgresql_test.rb index beb6efab28..ada4c2e2bd 100644 --- a/actioncable/test/subscription_adapter/postgresql_test.rb +++ b/actioncable/test/subscription_adapter/postgresql_test.rb @@ -1,5 +1,5 @@ require "test_helper" -require_relative "./common" +require_relative "common" require "active_record" diff --git a/actioncable/test/subscription_adapter/redis_test.rb b/actioncable/test/subscription_adapter/redis_test.rb index 4df5e0cbcd..11120b3f85 100644 --- a/actioncable/test/subscription_adapter/redis_test.rb +++ b/actioncable/test/subscription_adapter/redis_test.rb @@ -1,6 +1,6 @@ require "test_helper" -require_relative "./common" -require_relative "./channel_prefix" +require_relative "common" +require_relative "channel_prefix" class RedisAdapterTest < ActionCable::TestCase include CommonSubscriptionAdapterTest -- cgit v1.2.3