Skip to content
Browse files

Merge pull request #1528 from tsigo/resque_init

Consolidate Resque-related initializers
  • Loading branch information...
2 parents ad3eefd + 6ddbee5 commit 923eb89c1de137e8daeb871e63530070aa70379e @randx randx committed Sep 23, 2012
View
31 config/initializers/4_resque.rb
@@ -0,0 +1,31 @@
+# Custom Redis configuration
+rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
+rails_env = ENV['RAILS_ENV'] || 'development'
+config_file = File.join(rails_root, 'config', 'resque.yml')
+
+if File.exists?(config_file)
+ resque_config = YAML.load_file(config_file)
+ Resque.redis = resque_config[rails_env]
+end
+
+# Queues
+Resque.watch_queue(PostReceive.instance_variable_get("@queue"))
+
+# Authentication
+require 'resque/server'
+class Authentication
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ account = env['warden'].authenticate!(:database_authenticatable, :rememberable, scope: :user)
+ raise "Access denied" if !account.admin?
+ @app.call(env)
+ end
+end
+
+Resque::Server.use Authentication
+
+# Mailer
+Resque::Mailer.excluded_environments = []
View
1 config/initializers/4_resque_queues.rb
@@ -1 +0,0 @@
-Resque.watch_queue(PostReceive.instance_variable_get("@queue"))
View
8 config/initializers/resque.rb
@@ -1,8 +0,0 @@
-rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
-rails_env = ENV['RAILS_ENV'] || 'development'
-config_file = File.join(rails_root, 'config', 'resque.yml')
-
-if File.exists?(config_file)
- resque_config = YAML.load_file(config_file)
- Resque.redis = resque_config[rails_env]
-end
View
14 config/initializers/resque_authentication.rb
@@ -1,14 +0,0 @@
-require 'resque/server'
-class Authentication
- def initialize(app)
- @app = app
- end
-
- def call(env)
- account = env['warden'].authenticate!(:database_authenticatable, :rememberable, scope: :user)
- raise "Access denied" if !account.admin?
- @app.call(env)
- end
-end
-
-Resque::Server.use Authentication
View
1 config/initializers/resque_mailer.rb
@@ -1 +0,0 @@
-Resque::Mailer.excluded_environments = []

0 comments on commit 923eb89

Please sign in to comment.
Something went wrong with that request. Please try again.