Skip to content
This repository has been archived by the owner on Sep 3, 2019. It is now read-only.

Commit

Permalink
Cleaned up whitespace and added utf-8 tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael van Rooijen committed May 4, 2011
1 parent 04dfb6e commit b4ecbc8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/hirefire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ module HireFire
autoload :Version, 'hirefire/version'

class << self

attr_writer :configuration

##
# This method is used to configure HireFire
#
Expand Down Expand Up @@ -50,7 +50,7 @@ def configure
def configuration
@configuration ||= HireFire::Configuration.new
end

end

end
Expand Down
2 changes: 2 additions & 0 deletions lib/hirefire/backend/delayed_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# encoding: utf-8

module HireFire
module Backend
module DelayedJob
Expand Down
2 changes: 2 additions & 0 deletions lib/hirefire/backend/resque.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# encoding: utf-8

module HireFire
module Backend
module Resque
Expand Down
2 changes: 2 additions & 0 deletions lib/hirefire/workers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# encoding: utf-8

module HireFire
module Workers
autoload :DelayedJob, 'hirefire/workers/delayed_job'
Expand Down
22 changes: 11 additions & 11 deletions spec/environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ def jobs=(amount)
config.job_worker_ratio = [
{ :jobs => 5, :workers => 5 }
]

base.jobs = 100
base.workers = 0

HireFire::Logger.expects(:message).with('Hiring more workers so we have 3 in total.').once
base.expects(:workers).with(3).once
base.hire
Expand All @@ -213,7 +213,7 @@ def jobs=(amount)
config.job_worker_ratio = [
{ :jobs => 5, :workers => 5 }
]

base.jobs = 100
base.workers = 3

Expand All @@ -229,7 +229,7 @@ def jobs=(amount)
config.job_worker_ratio = [
{ :jobs => 5, :workers => 5 }
]

base.jobs = 100
base.workers = 0

Expand Down Expand Up @@ -328,7 +328,7 @@ def jobs=(amount)
config.max_workers = 3
base.jobs = 100
base.workers = 0

HireFire::Logger.expects(:message).with('Hiring more workers so we have 3 in total.').once
base.expects(:workers).with(3).once
base.hire
Expand All @@ -341,13 +341,13 @@ def jobs=(amount)
config.job_worker_ratio = [
{ :when => lambda { |jobs| jobs < 5 }, :workers => 5 }
]

base.jobs = 100
base.workers = 0

HireFire::Logger.expects(:message).with('Hiring more workers so we have 3 in total.').once
base.expects(:workers).with(3).once
base.hire
base.hire
end
end

Expand All @@ -357,10 +357,10 @@ def jobs=(amount)
config.job_worker_ratio = [
{ :when => lambda { |jobs| jobs < 5 }, :workers => 5 }
]

base.jobs = 100
base.workers = 3

HireFire::Logger.expects(:message).with('Hiring more workers so we have 3 in total.').never
base.expects(:workers).with(3).never
base.hire
Expand All @@ -373,7 +373,7 @@ def jobs=(amount)
config.job_worker_ratio = [
{ :when => lambda { |jobs| jobs < 5 }, :workers => 5 }
]

base.jobs = 100
base.workers = 0

Expand Down
8 changes: 5 additions & 3 deletions spec/support/configuration_helper.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# encoding: utf-8

module ConfigurationHelper
def configure(&block)
HireFire.configure(&block)
end

def with_configuration(&block)
old_configuration = HireFire.configuration
HireFire.configuration = HireFire::Configuration.new
yield(HireFire.configuration)
ensure
HireFire.configuration = old_configuration
end

def with_max_workers(workers, &block)
with_configuration do |config|
config.max_workers = workers
yield
end
end

def with_min_workers(workers, &block)
with_configuration do |config|
config.min_workers = workers
Expand Down

0 comments on commit b4ecbc8

Please sign in to comment.