job_boss 0.7.14 → 0.7.15

Sign up to get free protection for your applications and to get access to all the features.
data/bin/job_boss CHANGED
@@ -27,7 +27,7 @@ Daemons.run_proc('job_boss', daemons_options) do
27
27
  boss = JobBoss::Boss.new
28
28
 
29
29
  if File.exist?('config/environment.rb')
30
- boss.logger.info "Requiring 'config/environment.rb'"
30
+ # boss.logger.info "Requiring 'config/environment.rb'"
31
31
  require 'config/environment'
32
32
  end
33
33
 
data/job_boss.gemspec CHANGED
@@ -4,7 +4,7 @@ $:.unshift lib unless $:.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "job_boss"
7
- s.version = '0.7.14'
7
+ s.version = '0.7.15'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Brian Underwood"]
10
10
  s.email = ["ml+job_boss@semi-sentient.com"]
data/lib/job_boss/boss.rb CHANGED
@@ -106,7 +106,7 @@ module JobBoss
106
106
 
107
107
  # Waits until there is at least one available employee and then returns count
108
108
  def wait_for_available_employees
109
- until (employee_count = available_employees) > 0 && Job.pending.count > 0
109
+ until (employee_count = available_employees) > 0
110
110
  sleep(config.sleep_interval)
111
111
  end
112
112
 
data/lib/job_boss/job.rb CHANGED
@@ -177,7 +177,7 @@ module JobBoss
177
177
  # sleep_interval specifies polling period
178
178
  def wait_for_jobs(jobs = nil, sleep_interval = 0.5)
179
179
  at_exit do
180
- Job.not_completed.find(jobs).each(&:cancel)
180
+ Job.not_completed.where('id in (?)', jobs).cancel
181
181
  end
182
182
 
183
183
  jobs = get_jobs(jobs)
data/test/test_helper.rb CHANGED
@@ -16,7 +16,8 @@ class ActiveSupport::TestCase
16
16
  teardown :stop_daemon
17
17
 
18
18
  def setup_paths
19
- @job_boss_bin_path = File.expand_path('../../bin/job_boss', __FILE__)
19
+ @job_boss_path = File.expand_path('../..')
20
+ @job_boss_bin_path = File.expand_path(File.join(@job_boss_path, 'bin/job_boss'), __FILE__)
20
21
  @app_root_path = File.expand_path('../app_root', __FILE__)
21
22
  @db_path = File.join(@app_root_path, 'db')
22
23
  @log_path = File.join(@app_root_path, 'log', 'job_boss.log')
@@ -25,7 +26,14 @@ class ActiveSupport::TestCase
25
26
 
26
27
  def clean_app_environment
27
28
  Dir.glob(File.join(@db_path, '*')).each {|path| File.unlink(path) }
28
- Dir.glob(File.join(@app_root_path, 'log', '*')).each {|path| File.unlink(path) }
29
+
30
+ log_files = Dir.glob(File.join(@app_root_path, 'log', '*'))
31
+ log_files.each do |path|
32
+ # File.open('test/' + File.basename(path), 'w') {|f| f << '' }
33
+
34
+ File.open(File.join(@job_boss_path, 'test', File.basename(path)), 'a') {|f| f << File.read(path) }
35
+ File.unlink(path)
36
+ end
29
37
  end
30
38
 
31
39
  def assert_pid_running(pid, message="")
@@ -89,6 +97,19 @@ class ActiveSupport::TestCase
89
97
  sleep(wait_interval)
90
98
  job.reload
91
99
  end
100
+ # wait_until(30) do
101
+ # job.reload
102
+ # job.assigned?
103
+ # end
104
+ end
105
+
106
+ def wait_until(timeout, wait_interval = 0.5)
107
+ require 'timeout'
108
+ Timeout::timeout(5) do
109
+ until yield
110
+ sleep(wait_interval)
111
+ end
112
+ end
92
113
  end
93
114
 
94
115
  def stop_daemon
@@ -7,9 +7,9 @@ class DaemonTest < ActiveSupport::TestCase
7
7
  wait_for_file(@log_path)
8
8
 
9
9
  log_output = File.read(@log_path)
10
- assert log_output.match("INFO -- : Started ActiveRecord connection in 'development' environment from database YAML: #{@db_yaml_path}")
11
- assert log_output.match('INFO -- : Job Boss started')
12
- assert log_output.match('INFO -- : Employee limit: 4')
10
+ assert_match "INFO -- : Started ActiveRecord connection in 'development' environment from database YAML: #{@db_yaml_path}", log_output
11
+ assert_match 'INFO -- : Job Boss started', log_output
12
+ assert_match 'INFO -- : Employee limit: 4', log_output
13
13
 
14
14
 
15
15
  stop_daemon
@@ -7,7 +7,7 @@ Dir.chdir('test/app_root')
7
7
  Dir.glob('app/jobs/*_jobs.rb').each {|lib| require lib }
8
8
  Dir.glob('app/models/*.rb').each {|lib| require lib }
9
9
 
10
- class DaemonTest < ActiveSupport::TestCase
10
+ class JobTest < ActiveSupport::TestCase
11
11
  test "job queuing" do
12
12
  start_daemon(:application_root => @app_root_path)
13
13
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job_boss
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 14
10
- version: 0.7.14
9
+ - 15
10
+ version: 0.7.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Underwood
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-01 00:00:00 -04:00
18
+ date: 2011-04-02 00:00:00 -04:00
19
19
  default_executable: job_boss
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency