Skip to content
Browse files

Remove constants and fix testing load paths.

  • Loading branch information...
1 parent e1e7218 commit c46956d43561c6bf9d1f2c73e6d93717e8c1e226 @nbibler nbibler committed May 3, 2011
View
3 hirefire.gemspec
@@ -1,6 +1,7 @@
# encoding: utf-8
-require File.expand_path(File.dirname(__FILE__) + '/lib/hirefire')
+$:.push File.expand_path('../lib', __FILE__)
+require 'hirefire/version'
Gem::Specification.new do |gem|
View
62 lib/hirefire.rb
@@ -1,60 +1,12 @@
# encoding: utf-8
module HireFire
-
- ##
- # HireFire constants
- LIB_PATH = File.dirname(__FILE__)
- HIREFIRE_PATH = File.join(LIB_PATH, 'hirefire')
- ENVIRONMENT_PATH = File.join(HIREFIRE_PATH, 'environment')
- BACKEND_PATH = File.join(HIREFIRE_PATH, 'backend')
- WORKERS_PATH = File.join(HIREFIRE_PATH, 'workers')
-
- ##
- # HireFire namespace
- autoload :Configuration, File.join(HIREFIRE_PATH, 'configuration')
- autoload :Environment, File.join(HIREFIRE_PATH, 'environment')
- autoload :Initializer, File.join(HIREFIRE_PATH, 'initializer')
- autoload :Backend, File.join(HIREFIRE_PATH, 'backend')
- autoload :Logger, File.join(HIREFIRE_PATH, 'logger')
- autoload :Version, File.join(HIREFIRE_PATH, 'version')
-
- ##
- # HireFire::Environment namespace
- module Environment
- autoload :Base, File.join(ENVIRONMENT_PATH, 'base')
- autoload :Heroku, File.join(ENVIRONMENT_PATH, 'heroku')
- autoload :Local, File.join(ENVIRONMENT_PATH, 'local')
- autoload :Noop, File.join(ENVIRONMENT_PATH, 'noop')
- end
-
- ##
- # HireFire::Workers namespace
- module Workers
- autoload :DelayedJob, File.join(WORKERS_PATH, 'delayed_job')
- autoload :Resque, File.join(WORKERS_PATH, 'resque')
- end
-
- ##
- # HireFire::Backend namespace
- module Backend
- DELAYED_JOB_PATH = File.join(BACKEND_PATH, 'delayed_job')
- RESQUE_PATH = File.join(BACKEND_PATH, 'resque')
-
- ##
- # HireFire::Backend::DelayedJob namespace
- module DelayedJob
- autoload :ActiveRecord, File.join(DELAYED_JOB_PATH, 'active_record')
- autoload :ActiveRecord2, File.join(DELAYED_JOB_PATH, 'active_record_2')
- autoload :Mongoid, File.join(DELAYED_JOB_PATH, 'mongoid')
- end
-
- ##
- # HireFire::Backend::Resque namespace
- module Resque
- autoload :Redis, File.join(RESQUE_PATH, 'redis')
- end
- end
+ autoload :Configuration, 'hirefire/configuration'
+ autoload :Environment, 'hirefire/environment'
+ autoload :Initializer, 'hirefire/initializer'
+ autoload :Backend, 'hirefire/backend'
+ autoload :Logger, 'hirefire/logger'
+ autoload :Version, 'hirefire/version'
class << self
@@ -112,7 +64,7 @@ def configuration
# and the desired mapper (ActiveRecord, Mongoid or Redis)
if defined?(Rails)
if defined?(Rails::Railtie)
- require File.join(HireFire::HIREFIRE_PATH, 'railtie')
+ require 'hirefire/railtie'
else
HireFire::Initializer.initialize!
end
View
2 lib/hirefire/backend.rb
@@ -2,6 +2,8 @@
module HireFire
module Backend
+ autoload :DelayedJob, 'hirefire/backend/delayed_job'
+ autoload :Resque, 'hirefire/backend/resque'
##
# Load the correct module (ActiveRecord, Mongoid or Redis)
View
9 lib/hirefire/backend/delayed_job.rb
@@ -0,0 +1,9 @@
+module HireFire
+ module Backend
+ module DelayedJob
+ autoload :ActiveRecord, 'hirefire/backend/delayed_job/active_record'
+ autoload :ActiveRecord2, 'hirefire/backend/delayed_job/active_record_2'
+ autoload :Mongoid, 'hirefire/backend/delayed_job/mongoid'
+ end
+ end
+end
View
7 lib/hirefire/backend/resque.rb
@@ -0,0 +1,7 @@
+module HireFire
+ module Backend
+ module Resque
+ autoload :Redis, 'hirefire/backend/resque/redis'
+ end
+ end
+end
View
4 lib/hirefire/environment.rb
@@ -2,6 +2,10 @@
module HireFire
module Environment
+ autoload :Base, 'hirefire/environment/base'
+ autoload :Heroku, 'hirefire/environment/heroku'
+ autoload :Local, 'hirefire/environment/local'
+ autoload :Noop, 'hirefire/environment/noop'
##
# This module gets included in either:
View
4 lib/hirefire/initializer.rb
@@ -46,7 +46,7 @@ def self.initialize!
##
# Load Delayed Job extensions, this will patch Delayed::Worker
# to implement the necessary hooks to invoke HireFire from
- require File.join(HireFire::WORKERS_PATH, 'delayed_job')
+ require 'hirefire/workers/delayed_job'
end
##
@@ -65,7 +65,7 @@ def self.initialize!
##
# Load Resque extensions, this will patch Resque, Resque::Job and Resque::Worker
# to implement the necessary hooks to invoke HireFire from
- require File.join(HireFire::WORKERS_PATH, 'resque')
+ require 'hirefire/workers/resque'
end
end
View
2 lib/hirefire/railtie.rb
@@ -32,7 +32,7 @@ class Railtie < Rails::Railtie
# If Resque is loaded, then we load the Resque rake task
# that'll allow Heroku to start up Resque as a worker
if defined?(::Resque)
- require File.join(WORKERS_PATH, 'resque', 'tasks.rb')
+ require 'hirefire/workers/resque/tasks'
end
end
View
6 lib/hirefire/workers.rb
@@ -0,0 +1,6 @@
+module HireFire
+ module Workers
+ autoload :DelayedJob, 'hirefire/workers/delayed_job'
+ autoload :Resque, 'hirefire/workers/resque'
+ end
+end
View
12 spec/spec_helper.rb
@@ -1,12 +1,8 @@
# encoding: utf-8
+$:.unshift(File.expand_path('../', __FILE__))
+$:.unshift(File.expand_path('../../lib', __FILE__))
-##
-# Path to the lib directory
-LIB_PATH = File.expand_path('../../lib', __FILE__)
-
-##
-# Load the HireFire Ruby library
-require File.join(LIB_PATH, 'hirefire')
+require 'hirefire'
module ConfigurationHelper
@@ -41,4 +37,4 @@ def with_min_workers(workers, &block)
RSpec.configure do |config|
config.mock_with :mocha
config.include ConfigurationHelper
-end
+end

0 comments on commit c46956d

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