resque-pause 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md ADDED
@@ -0,0 +1,26 @@
1
+ Changelog
2
+ =========
3
+
4
+ ### 0.0.4
5
+
6
+ * improvement on job reserve to prevent fork worker when queue is paused
7
+ * bug fix for the gem work with resque-restriction gem, and other which re-implements job reserve method
8
+ * changing the require for load resque-web integration to
9
+
10
+ ```ruby
11
+ require 'resque-pause/server'
12
+ ```
13
+
14
+ ### 0.0.3
15
+
16
+ * bug fix on re-enqueue the job
17
+ * improvement on resque-web integration urls
18
+
19
+ ### 0.0.2
20
+
21
+ * updating documentation
22
+ * generating a good package for rubygems
23
+
24
+ ### 0.0.1
25
+
26
+ * version was removed from rubygems, bad package
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resque-pause (0.0.3)
4
+ resque-pause (0.0.4)
5
5
  resque (>= 1.9.10)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -40,7 +40,7 @@ Resque-Web integration
40
40
  You have to load ResquePause to enable the Pause tab.
41
41
 
42
42
  ```ruby
43
- require 'resque_pause'
43
+ require 'resque-pause/server'
44
44
  ```
45
45
 
46
46
  Customise & Extend
data/lib/resque-pause.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'resque'
2
2
  require File.expand_path(File.join('resque_pause_helper'), File.dirname(__FILE__))
3
- require File.expand_path(File.join('resque', 'plugins', 'pause'), File.dirname(__FILE__))
3
+ require File.expand_path(File.join('resque-pause', 'plugins', 'pause'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('resque-pause', 'job'), File.dirname(__FILE__))
@@ -0,0 +1,13 @@
1
+ module Resque
2
+ class Job
3
+ class <<self
4
+ alias_method :origin_before_pause_reserve, :reserve
5
+
6
+ def reserve(queue)
7
+ return nil if ResquePauseHelper.paused?(queue)
8
+ origin_before_pause_reserve(queue)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
File without changes
@@ -1,3 +1,7 @@
1
+ require 'resque'
2
+ require 'resque/server'
3
+ require File.expand_path(File.join('../','resque_pause_helper'), File.dirname(__FILE__))
4
+
1
5
  # Extends Resque Web Based UI.
2
6
  # Structure has been borrowed from ResqueScheduler.
3
7
  module ResquePause
data/lib/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Resque
2
2
  module Plugins
3
3
  module Pause
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
6
6
  end
7
7
  end
@@ -13,10 +13,11 @@ describe Resque::Plugins::Pause do
13
13
  expect { Resque::Plugin.lint(Resque::Plugins::Pause) }.to_not raise_error
14
14
  end
15
15
 
16
- it "should use at least resque version 1.8.0" do
16
+ it "should use at least resque version 1.9.10" do
17
17
  major, minor, patch = Resque::Version.split('.')
18
18
  major.to_i.should == 1
19
- minor.to_i.should >= 8
19
+ minor.to_i.should >= 9
20
+ patch.to_i.should >= 10 if minor.to_i == 9
20
21
  end
21
22
 
22
23
  it "should execute the job when queue is not paused" do
@@ -27,21 +28,33 @@ describe Resque::Plugins::Pause do
27
28
  end
28
29
 
29
30
  it "should not execute the job when queue is paused" do
31
+ Resque.enqueue(PauseJob)
32
+ Resque.size('test').should == 1
33
+
34
+ job = Resque.reserve('test')
35
+ ResquePauseHelper.pause('test')
36
+ job.perform
37
+
38
+ Resque.size('test').should == 1
39
+ end
40
+
41
+ it "should not reserve the job when queue is paused" do
30
42
  ResquePauseHelper.pause('test')
31
43
  Resque.enqueue(PauseJob)
32
44
  PauseJob.should_not_receive(:perform)
33
45
 
34
- Resque.reserve('test').perform
46
+ Resque.reserve('test').should be_nil
35
47
  end
36
48
 
37
49
  it "should not change queued jobs when queue is paused" do
38
- ResquePauseHelper.pause('test')
39
50
  Resque.enqueue(PauseJob, 1)
40
51
  Resque.enqueue(PauseJob, 2)
41
52
  Resque.enqueue(PauseJob, 3)
42
53
  jobs = Resque.redis.lrange('queue:test', 0, 2)
43
54
 
44
- Resque.reserve('test').perform
55
+ job = Resque.reserve('test')
56
+ ResquePauseHelper.pause('test')
57
+ job.perform
45
58
 
46
59
  remaining_jobs = Resque.redis.lrange('queue:test', 0, 2)
47
60
  jobs.should == remaining_jobs
@@ -50,8 +63,9 @@ describe Resque::Plugins::Pause do
50
63
  it "should back to execute the job when queue is unpaused" do
51
64
  Resque.enqueue(PauseJob)
52
65
 
66
+ job = Resque.reserve('test')
53
67
  ResquePauseHelper.pause('test')
54
- Resque.reserve('test').perform
68
+ job.perform
55
69
  Resque.size('test').should == 1
56
70
 
57
71
  ResquePauseHelper.unpause('test')
@@ -67,7 +67,7 @@ describe ResquePause::Server do
67
67
 
68
68
  it "should return static files" do
69
69
  get "/pause/public/pause.js"
70
- last_response.body.should == File.read(File.expand_path('../lib/resque_pause/server/public/pause.js', File.dirname(__FILE__)))
70
+ last_response.body.should == File.read(File.expand_path('../lib/resque-pause/server/public/pause.js', File.dirname(__FILE__)))
71
71
  end
72
72
 
73
73
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wandenberg Peixoto
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-06-27 00:00:00 -03:00
17
+ date: 2011-06-30 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -92,22 +92,23 @@ extra_rdoc_files: []
92
92
 
93
93
  files:
94
94
  - .gitignore
95
+ - Changelog.md
95
96
  - Gemfile
96
97
  - Gemfile.lock
97
98
  - README.md
98
99
  - Rakefile
99
100
  - lib/resque-pause.rb
100
- - lib/resque/plugins/pause.rb
101
- - lib/resque_pause.rb
102
- - lib/resque_pause/server.rb
103
- - lib/resque_pause/server/public/pause.js
104
- - lib/resque_pause/server/views/pause.erb
101
+ - lib/resque-pause/job.rb
102
+ - lib/resque-pause/plugins/pause.rb
103
+ - lib/resque-pause/server.rb
104
+ - lib/resque-pause/server/public/pause.js
105
+ - lib/resque-pause/server/views/pause.erb
105
106
  - lib/resque_pause_helper.rb
106
107
  - lib/version.rb
107
108
  - resque-pause.gemspec
108
109
  - spec/redis-test.conf
110
+ - spec/resque-pause/plugins/pause_spec.rb
109
111
  - spec/resque-web_spec.rb
110
- - spec/resque/plugins/pause_spec.rb
111
112
  - spec/resque_pause_helper_spec.rb
112
113
  - spec/spec_helper.rb
113
114
  has_rdoc: true
data/lib/resque_pause.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'resque'
2
- require 'resque/server'
3
- require File.expand_path(File.join('resque_pause_helper'), File.dirname(__FILE__))
4
- require File.expand_path(File.join('resque_pause', 'server'), File.dirname(__FILE__))