diff options
author | Jon Moss <me@jonathanmoss.me> | 2016-01-15 19:03:05 -0500 |
---|---|---|
committer | Jon Moss <me@jonathanmoss.me> | 2016-01-18 18:59:30 -0500 |
commit | 6aeaed4c1a370084e82c6712a32422a58dac8b8c (patch) | |
tree | 0284579e3fe07f57e7f7b9f16d627f63ab8c7eaa | |
parent | 75489642c8dcb4c75ccc14b909113a2828d6acb8 (diff) | |
download | rails-6aeaed4c1a370084e82c6712a32422a58dac8b8c.tar.gz rails-6aeaed4c1a370084e82c6712a32422a58dac8b8c.tar.bz2 rails-6aeaed4c1a370084e82c6712a32422a58dac8b8c.zip |
All Redis deps are now optional, Postgres --> PostgreSQL adapter
-rw-r--r-- | Gemfile.lock | 6 | ||||
-rw-r--r-- | actioncable/actioncable.gemspec | 6 | ||||
-rw-r--r-- | actioncable/lib/action_cable/storage_adapter.rb | 2 | ||||
-rw-r--r-- | actioncable/lib/action_cable/storage_adapter/postgresql.rb (renamed from actioncable/lib/action_cable/storage_adapter/postgres.rb) | 8 | ||||
-rw-r--r-- | actioncable/lib/action_cable/storage_adapter/redis.rb | 8 | ||||
-rw-r--r-- | actioncable/test/channel/stream_test.rb | 1 | ||||
-rw-r--r-- | actioncable/test/test_helper.rb | 1 |
7 files changed, 17 insertions, 15 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index bcedeff385..390b2a18f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,9 +32,7 @@ PATH actioncable (5.0.0.beta1) actionpack (= 5.0.0.beta1) coffee-rails (~> 4.1.0) - em-hiredis (~> 0.3.0) faye-websocket (~> 0.10.0) - redis (~> 3.0) websocket-driver (~> 0.6.1) actionmailer (5.0.0.beta1) actionpack (= 5.0.0.beta1) @@ -140,9 +138,6 @@ GEM delayed_job_active_record (4.1.0) activerecord (>= 3.0, < 5) delayed_job (>= 3.0, < 5) - em-hiredis (0.3.0) - eventmachine (~> 1.0) - hiredis (~> 0.5.0) erubis (2.7.0) eventmachine (1.0.9.1) execjs (2.6.0) @@ -154,7 +149,6 @@ GEM ffi (1.9.10-x86-mingw32) globalid (0.3.6) activesupport (>= 4.1.0) - hiredis (0.5.2) hitimes (1.2.3) hitimes (1.2.3-x86-mingw32) i18n (0.7.0) diff --git a/actioncable/actioncable.gemspec b/actioncable/actioncable.gemspec index 2ab8b4785a..847fcc71c3 100644 --- a/actioncable/actioncable.gemspec +++ b/actioncable/actioncable.gemspec @@ -23,10 +23,10 @@ Gem::Specification.new do |s| s.add_dependency 'coffee-rails', '~> 4.1.0' s.add_dependency 'faye-websocket', '~> 0.10.0' s.add_dependency 'websocket-driver', '~> 0.6.1' - s.add_dependency 'em-hiredis', '~> 0.3.0' - s.add_dependency 'redis', '~> 3.0' - s.add_development_dependency 'puma' + s.add_development_dependency 'em-hiredis', '~> 0.3.0' s.add_development_dependency 'mocha' s.add_development_dependency 'pg' + s.add_development_dependency 'puma' + s.add_development_dependency 'redis', '~> 3.0' end diff --git a/actioncable/lib/action_cable/storage_adapter.rb b/actioncable/lib/action_cable/storage_adapter.rb index f1c395eb3a..a4fe12c770 100644 --- a/actioncable/lib/action_cable/storage_adapter.rb +++ b/actioncable/lib/action_cable/storage_adapter.rb @@ -1,7 +1,7 @@ module ActionCable module StorageAdapter autoload :Base, 'action_cable/storage_adapter/base' - autoload :Postgres, 'action_cable/storage_adapter/postgres' + autoload :PostgreSQL, 'action_cable/storage_adapter/postgresql' autoload :Redis, 'action_cable/storage_adapter/redis' end end diff --git a/actioncable/lib/action_cable/storage_adapter/postgres.rb b/actioncable/lib/action_cable/storage_adapter/postgresql.rb index 5d874533be..1d8460e2ea 100644 --- a/actioncable/lib/action_cable/storage_adapter/postgres.rb +++ b/actioncable/lib/action_cable/storage_adapter/postgresql.rb @@ -1,8 +1,14 @@ require 'thread' +begin + require 'pg' +rescue Gem::LoadError => e + raise Gem::LoadError, "You are trying to use the PostgreSQL ActionCable adapter, but do not have the proper gems installed. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActionCable)." +end + module ActionCable module StorageAdapter - class Postgres < Base + class PostgreSQL < Base # The storage instance used for broadcasting. Not intended for direct user use. def broadcast(channel, payload) with_connection do |pg_conn| diff --git a/actioncable/lib/action_cable/storage_adapter/redis.rb b/actioncable/lib/action_cable/storage_adapter/redis.rb index 3e0ede057a..62a3971ec7 100644 --- a/actioncable/lib/action_cable/storage_adapter/redis.rb +++ b/actioncable/lib/action_cable/storage_adapter/redis.rb @@ -1,5 +1,9 @@ -require 'em-hiredis' -require 'redis' +begin + require 'em-hiredis' + require 'redis' +rescue Gem::LoadError => e + raise Gem::LoadError, "You are trying to use the Redis ActionCable adapter, but do not have the proper gems installed. Add `gem 'em-hiredis'` and `gem 'redis'` to your Gemfile (and ensure its version is at the minimum required by ActionCable)." +end module ActionCable module StorageAdapter diff --git a/actioncable/test/channel/stream_test.rb b/actioncable/test/channel/stream_test.rb index f0b463d149..8424310ca2 100644 --- a/actioncable/test/channel/stream_test.rb +++ b/actioncable/test/channel/stream_test.rb @@ -62,7 +62,6 @@ class ActionCable::Channel::StreamTest < ActionCable::TestCase test "subscription confirmation should only be sent out once" do EM.run do connection = TestConnection.new - connection.stubs(:pubsub).returns EM::Hiredis.connect.pubsub channel = ChatChannel.new connection, "test_channel" channel.send_confirmation diff --git a/actioncable/test/test_helper.rb b/actioncable/test/test_helper.rb index 325305939f..65b45e0c89 100644 --- a/actioncable/test/test_helper.rb +++ b/actioncable/test/test_helper.rb @@ -5,7 +5,6 @@ require 'active_support/testing/autorun' require 'puma' -require 'em-hiredis' require 'mocha/setup' |