rector 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,8 +41,8 @@ module Rector
41
41
  redis.srem(WORKER_LIST_SET, worker_id)
42
42
  end
43
43
 
44
- def workers_working?
45
- redis.scard(WORKER_LIST_SET).to_i > 0
44
+ def num_workers_working
45
+ redis.scard(WORKER_LIST_SET).to_i
46
46
  end
47
47
 
48
48
  def cleanup
@@ -35,11 +35,15 @@ module Rector
35
35
  end
36
36
 
37
37
  def join
38
- while @backend.workers_working?
38
+ while num_workers_working > 0
39
39
  sleep 5
40
40
  end
41
41
  end
42
42
 
43
+ def num_workers_working
44
+ @backend.num_workers_working
45
+ end
46
+
43
47
  def data
44
48
  @data ||= @backend.read_job_data_to_hash
45
49
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rector"
6
- s.version = "0.0.4"
6
+ s.version = "0.0.5"
7
7
  s.authors = ["Andy Lindeman"]
8
8
  s.email = ["alindeman@gmail.com"]
9
9
  s.homepage = "https://github.com/alindeman/rector"
@@ -96,10 +96,10 @@ describe Rector::Backends::Redis do
96
96
 
97
97
  it "knows if workers are still working" do
98
98
  redis.stubs(:scard).with("#{job_id}:__workers__").returns("1")
99
- subject.workers_working?.should be_true
99
+ subject.num_workers_working.should == 1
100
100
 
101
101
  redis.stubs(:scard).with("#{job_id}:__workers__").returns("0")
102
- subject.workers_working?.should be_false
102
+ subject.num_workers_working.should == 0
103
103
  end
104
104
  end
105
105
 
@@ -13,7 +13,7 @@ describe Rector::Job do
13
13
  end
14
14
 
15
15
  it "waits for workers to complete" do
16
- backend.expects(:workers_working?).at_least_once.returns(true).then.returns(false)
16
+ backend.expects(:num_workers_working).at_least_once.returns(1).then.returns(0)
17
17
  subject.stubs(:sleep)
18
18
 
19
19
  Timeout.timeout(2) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70106573554300 !ruby/object:Gem::Requirement
16
+ requirement: &70230987700940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70106573554300
24
+ version_requirements: *70230987700940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: redis-namespace
27
- requirement: &70106573553660 !ruby/object:Gem::Requirement
27
+ requirement: &70230987700300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70106573553660
35
+ version_requirements: *70230987700300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70106573552980 !ruby/object:Gem::Requirement
38
+ requirement: &70230987699880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70106573552980
46
+ version_requirements: *70230987699880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70106573552480 !ruby/object:Gem::Requirement
49
+ requirement: &70230987699380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.8.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70106573552480
57
+ version_requirements: *70230987699380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &70106573551980 !ruby/object:Gem::Requirement
60
+ requirement: &70230987698840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.10.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70106573551980
68
+ version_requirements: *70230987698840
69
69
  description: ! " Rector allows coordination of a number of jobs spawned with a
70
70
  mechanism\n like Resque (though any job manager will do). If you are able to
71
71
  parallelize\n the processing of a task, yet all these tasks are generating metrics,\n
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: 992020878605361290
111
+ hash: 2563052189374622646
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: 992020878605361290
120
+ hash: 2563052189374622646
121
121
  requirements: []
122
122
  rubyforge_project:
123
123
  rubygems_version: 1.8.14