resque-status 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,8 +1,6 @@
1
1
  source :rubygems
2
2
 
3
- gem 'redisk', '>= 0.2.1'
4
3
  gem 'resque', '~>1.19'
5
- gem 'uuid', '~>2.3'
6
4
 
7
5
  group :test do
8
6
  gem 'mocha', '~>0.9.8'
@@ -2,42 +2,34 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  git (1.2.5)
5
- jeweler (1.8.3)
5
+ jeweler (1.8.4)
6
6
  bundler (~> 1.0)
7
7
  git (>= 1.2.5)
8
8
  rake
9
9
  rdoc
10
- json (1.6.5)
11
- macaddr (1.5.0)
12
- systemu (>= 2.4.0)
10
+ json (1.7.5)
13
11
  mocha (0.9.12)
14
- multi_json (1.0.4)
12
+ multi_json (1.3.6)
15
13
  rack (1.4.1)
16
14
  rack-protection (1.2.0)
17
15
  rack
18
16
  rake (0.9.2.2)
19
17
  rdoc (3.12)
20
18
  json (~> 1.4)
21
- redis (2.2.2)
22
- redis-namespace (1.0.3)
23
- redis (< 3.0.0)
24
- redisk (0.2.2)
25
- redis (>= 0.1.1)
26
- redis-namespace (>= 0.1.0)
27
- resque (1.19.0)
19
+ redis (3.0.2)
20
+ redis-namespace (1.2.1)
21
+ redis (~> 3.0.0)
22
+ resque (1.23.0)
28
23
  multi_json (~> 1.0)
29
- redis-namespace (~> 1.0.2)
24
+ redis-namespace (~> 1.0)
30
25
  sinatra (>= 0.9.2)
31
26
  vegas (~> 0.1.2)
32
27
  shoulda (2.10.3)
33
- sinatra (1.3.2)
28
+ sinatra (1.3.3)
34
29
  rack (~> 1.3, >= 1.3.6)
35
30
  rack-protection (~> 1.2)
36
31
  tilt (~> 1.3, >= 1.3.3)
37
- systemu (2.4.2)
38
32
  tilt (1.3.3)
39
- uuid (2.3.5)
40
- macaddr (~> 1.0)
41
33
  vegas (0.1.11)
42
34
  rack (>= 1.0.0)
43
35
 
@@ -47,7 +39,5 @@ PLATFORMS
47
39
  DEPENDENCIES
48
40
  jeweler
49
41
  mocha (~> 0.9.8)
50
- redisk (>= 0.2.1)
51
42
  resque (~> 1.19)
52
43
  shoulda (~> 2.10.2)
53
- uuid (~> 2.3)
@@ -119,7 +119,7 @@ A Status is actually just a hash, so inside a job you can do:
119
119
 
120
120
  Also, all the status setting methods take any number of hash arguments. So you could do:
121
121
 
122
- complete('filename' => '/myfilename')
122
+ completed('filename' => '/myfilename')
123
123
 
124
124
  === Kill! Kill! Kill!
125
125
 
@@ -28,7 +28,7 @@ module Resque
28
28
  # This job would iterate num times updating the status as it goes. At the end
29
29
  # we update the status telling anyone listening to this job that its complete.
30
30
  module Status
31
- VERSION = '0.3.3'
31
+ VERSION = '0.4.0'
32
32
 
33
33
  autoload :Hash, 'resque/plugins/status/hash'
34
34
 
@@ -76,7 +76,11 @@ module Resque
76
76
  # job_id = ExampleJob.create(:num => 100)
77
77
  #
78
78
  def create(options = {})
79
- self.enqueue(self, options)
79
+ if Resque.inline?
80
+ self.perform(nil, options)
81
+ else
82
+ self.enqueue(self, options)
83
+ end
80
84
  end
81
85
 
82
86
  # Adds a job of type <tt>klass<tt> to the queue with <tt>options<tt>.
@@ -84,15 +88,34 @@ module Resque
84
88
  # Returns the UUID of the job if the job was queued, or nil if the job was
85
89
  # rejected by a before_enqueue hook.
86
90
  def enqueue(klass, options = {})
91
+ self.enqueue_to(Resque.queue_from_class(klass) || queue, klass, options)
92
+ end
93
+
94
+ # Adds a job of type <tt>klass<tt> to a specified queue with <tt>options<tt>.
95
+ #
96
+ # Returns the UUID of the job if the job was queued, or nil if the job was
97
+ # rejected by a before_enqueue hook.
98
+ def enqueue_to(queue, klass, options = {})
87
99
  uuid = Resque::Plugins::Status::Hash.generate_uuid
88
- if Resque.enqueue(klass, uuid, options)
89
- Resque::Plugins::Status::Hash.create uuid, :options => options
100
+ Resque::Plugins::Status::Hash.create uuid, :options => options
101
+
102
+ if Resque.enqueue_to(queue, klass, uuid, options)
90
103
  uuid
91
104
  else
105
+ Resque::Plugins::Status::Hash.remove(uuid)
92
106
  nil
93
107
  end
94
108
  end
95
109
 
110
+ # Removes a job of type <tt>klass<tt> from the queue.
111
+ #
112
+ # The initially given options are retrieved from the status hash.
113
+ # (Resque needs the options to find the correct queue entry)
114
+ def dequeue(klass, uuid)
115
+ status = Resque::Plugins::Status::Hash.get(uuid)
116
+ Resque.dequeue(klass, uuid, status.options)
117
+ end
118
+
96
119
  # This is the method called by Resque::Worker when processing jobs. It
97
120
  # creates a new instance of the job class and populates it with the uuid and
98
121
  # options.
@@ -101,7 +124,11 @@ module Resque
101
124
  def perform(uuid=nil, options = {})
102
125
  uuid ||= Resque::Plugins::Status::Hash.generate_uuid
103
126
  instance = new(uuid, options)
104
- instance.safe_perform!
127
+ if Resque.inline?
128
+ instance.perform
129
+ else
130
+ instance.safe_perform!
131
+ end
105
132
  instance
106
133
  end
107
134
 
@@ -109,7 +136,7 @@ module Resque
109
136
  # This is needed to be used with resque scheduler
110
137
  # http://github.com/bvandenbos/resque-scheduler
111
138
  def scheduled(queue, klass, *args)
112
- create(*args)
139
+ self.enqueue_to(queue, self, *args)
113
140
  end
114
141
  end
115
142
 
@@ -126,7 +153,7 @@ module Resque
126
153
  def safe_perform!
127
154
  set_status({'status' => 'working'})
128
155
  perform
129
- if status.failed?
156
+ if status && status.failed?
130
157
  on_failure(status.message) if respond_to?(:on_failure)
131
158
  return
132
159
  elsif status && !status.completed?
@@ -134,11 +161,9 @@ module Resque
134
161
  end
135
162
  on_success if respond_to?(:on_success)
136
163
  rescue Killed
137
- logger.info "Job #{self} Killed at #{Time.now}"
138
164
  Resque::Plugins::Status::Hash.killed(uuid)
139
165
  on_killed if respond_to?(:on_killed)
140
166
  rescue => e
141
- logger.error e
142
167
  failed("The task failed because of an error: #{e}")
143
168
  if respond_to?(:on_failure)
144
169
  on_failure(e)
@@ -147,11 +172,6 @@ module Resque
147
172
  end
148
173
  end
149
174
 
150
- # Returns a Redisk::Logger object scoped to this paticular job/uuid
151
- def logger
152
- @logger ||= Resque::Plugins::Status::Hash.logger(uuid)
153
- end
154
-
155
175
  # Set the jobs status. Can take an array of strings or hashes that are merged
156
176
  # (in order) into a final status hash.
157
177
  def status=(new_status)
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module Resque
2
4
  module Plugins
3
5
  module Status
@@ -24,7 +26,17 @@ module Resque
24
26
  val ? Resque::Plugins::Status::Hash.new(uuid, decode(val)) : nil
25
27
  end
26
28
 
27
- # set a status by UUID. <tt>messages</tt> can be any number of stirngs or hashes
29
+ # Get multiple statuses by UUID. Returns array of Resque::Plugins::Status::Hash
30
+ def self.mget(uuids)
31
+ status_keys = uuids.map{|u| status_key(u)}
32
+ vals = redis.mget(*status_keys)
33
+
34
+ uuids.zip(vals).map do |uuid, val|
35
+ val ? Resque::Plugins::Status::Hash.new(uuid, decode(val)) : nil
36
+ end
37
+ end
38
+
39
+ # set a status by UUID. <tt>messages</tt> can be any number of strings or hashes
28
40
  # that are merged in order to create a single status.
29
41
  def self.set(uuid, *messages)
30
42
  val = Resque::Plugins::Status::Hash.new(uuid, *messages)
@@ -42,7 +54,7 @@ module Resque
42
54
  remove(id)
43
55
  end
44
56
  end
45
-
57
+
46
58
  def self.clear_completed(range_start = nil, range_end = nil)
47
59
  status_ids(range_start, range_end).select do |id|
48
60
  get(id).completed?
@@ -50,20 +62,19 @@ module Resque
50
62
  remove(id)
51
63
  end
52
64
  end
53
-
65
+
66
+ def self.clear_failed(range_start = nil, range_end = nil)
67
+ status_ids(range_start, range_end).select do |id|
68
+ get(id).failed?
69
+ end.each do |id|
70
+ remove(id)
71
+ end
72
+ end
73
+
54
74
  def self.remove(uuid)
55
75
  redis.del(status_key(uuid))
56
76
  redis.zrem(set_key, uuid)
57
77
  end
58
- # returns a Redisk::Logger scoped to the UUID. Any options passed are passed
59
- # to the logger initialization.
60
- #
61
- # Ensures that Redisk is logging to the same Redis connection as Resque.
62
- def self.logger(uuid, options = {})
63
- require 'redisk' unless defined?(Redisk)
64
- Redisk.redis = redis
65
- Redisk::Logger.new(logger_key(uuid), options)
66
- end
67
78
 
68
79
  def self.count
69
80
  redis.zcard(set_key)
@@ -155,13 +166,8 @@ module Resque
155
166
  "_kill"
156
167
  end
157
168
 
158
- def self.logger_key(uuid)
159
- "_log:#{uuid}"
160
- end
161
-
162
169
  def self.generate_uuid
163
- require 'uuid' unless defined?(UUID)
164
- UUID.generate(:compact)
170
+ SecureRandom.hex.to_s
165
171
  end
166
172
 
167
173
  def self.hash_accessor(name, options = {})
@@ -26,7 +26,7 @@
26
26
  z-index: 10;
27
27
  color: #333;
28
28
  }
29
-
29
+
30
30
  .status-holder {
31
31
  background: #F7F7F7;
32
32
  border: 1px solid #E5E5E5;
@@ -95,4 +95,4 @@
95
95
  color: #B84F16;
96
96
  font-weight: bold;
97
97
  }
98
- </style>
98
+ </style>
@@ -8,6 +8,9 @@
8
8
  <form method="POST" action="<%= u(:statuses) %>/clear/completed" class='clear-failed'>
9
9
  <input type='submit' name='' value='Clear Completed Statuses' onclick='return confirm("Are you absolutely sure? This cannot be undone.");' />
10
10
  </form>
11
+ <form method="POST" action="<%= u(:statuses) %>/clear/failed" class='clear-failed'>
12
+ <input type='submit' name='' value='Clear Failed Statuses' onclick='return confirm("Are you absolutely sure? This cannot be undone.");' />
13
+ </form>
11
14
  <%end%>
12
15
  <p class='intro'>These are recent jobs created with the Resque::Plugins::Status class</p>
13
16
  <table>
@@ -26,7 +29,7 @@
26
29
  <td><a href="<%= u(:statuses) %>/<%= status.uuid %>"><%= status.uuid %></a></td>
27
30
  <td><%= status.name %></td>
28
31
  <td class="status status-<%= status.status %>"><%= status.status %></td>
29
- <td class="time"><%= status.time %></td>
32
+ <td class="time"><%= status.time.strftime("%Y/%m/%d %H:%M:%S %z") %></td>
30
33
  <td class="progress">
31
34
  <div class="progress-bar" style="width:<%= status.pct_complete %>%">&nbsp;</div>
32
35
  <div class="progress-pct"><%= status.pct_complete ? "#{status.pct_complete}%" : '' %></div>
@@ -42,6 +42,11 @@ module Resque
42
42
  redirect u(:statuses)
43
43
  end
44
44
 
45
+ app.post '/statuses/clear/failed' do
46
+ Resque::Plugins::Status::Hash.clear_failed
47
+ redirect u(:statuses)
48
+ end
49
+
45
50
  app.get "/statuses.poll" do
46
51
  content_type "text/plain"
47
52
  @polling = true
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "resque-status"
8
- s.version = "0.3.3"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Quint"]
12
- s.date = "2012-04-09"
12
+ s.date = "2012-10-21"
13
13
  s.description = "resque-status is an extension to the resque queue system that provides simple trackable jobs. It provides a Resque::Plugins::Status::Hash class which can set/get the statuses of jobs and a Resque::Plugins::Status class that when included provides easily trackable/killable jobs."
14
14
  s.email = "aaron@quirkey.com"
15
15
  s.extra_rdoc_files = [
@@ -43,27 +43,21 @@ Gem::Specification.new do |s|
43
43
  s.homepage = "http://github.com/quirkey/resque-status"
44
44
  s.require_paths = ["lib"]
45
45
  s.rubyforge_project = "quirkey"
46
- s.rubygems_version = "1.8.16"
46
+ s.rubygems_version = "1.8.23"
47
47
  s.summary = "resque-status is an extension to the resque queue system that provides simple trackable jobs."
48
48
 
49
49
  if s.respond_to? :specification_version then
50
50
  s.specification_version = 3
51
51
 
52
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<redisk>, [">= 0.2.1"])
54
53
  s.add_runtime_dependency(%q<resque>, ["~> 1.19"])
55
- s.add_runtime_dependency(%q<uuid>, ["~> 2.3"])
56
54
  s.add_development_dependency(%q<jeweler>, [">= 0"])
57
55
  else
58
- s.add_dependency(%q<redisk>, [">= 0.2.1"])
59
56
  s.add_dependency(%q<resque>, ["~> 1.19"])
60
- s.add_dependency(%q<uuid>, ["~> 2.3"])
61
57
  s.add_dependency(%q<jeweler>, [">= 0"])
62
58
  end
63
59
  else
64
- s.add_dependency(%q<redisk>, [">= 0.2.1"])
65
60
  s.add_dependency(%q<resque>, ["~> 1.19"])
66
- s.add_dependency(%q<uuid>, ["~> 2.3"])
67
61
  s.add_dependency(%q<jeweler>, [">= 0"])
68
62
  end
69
63
  end
@@ -4,7 +4,6 @@ $TESTING = true
4
4
  require 'test/unit'
5
5
  require 'rubygems'
6
6
  require 'shoulda'
7
- require 'redisk'
8
7
  require 'mocha'
9
8
 
10
9
  require 'resque-status'
@@ -38,15 +37,14 @@ at_exit do
38
37
 
39
38
  pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
40
39
  puts "Killing test redis server..."
41
- `rm -f #{dir}/dump.rdb`
42
40
  Process.kill("KILL", pid.to_i)
41
+ `rm -f #{dir}/dump.rdb`
43
42
  exit exit_code
44
43
  end
45
44
 
46
45
  puts "Starting redis for testing at localhost:9736..."
47
46
  `redis-server #{dir}/redis-test.conf`
48
47
  Resque.redis = 'localhost:9736/1'
49
- Redisk.redis = 'localhost:9736/1'
50
48
 
51
49
  #### Fixtures
52
50
 
@@ -8,28 +8,45 @@ class TestResquePluginsStatus < Test::Unit::TestCase
8
8
  end
9
9
 
10
10
  context ".create" do
11
- setup do
12
- @uuid = WorkingJob.create('num' => 100)
13
- end
11
+ context "not inline" do
12
+ setup do
13
+ @uuid = WorkingJob.create('num' => 100)
14
+ end
14
15
 
15
- should "add the job to the queue" do
16
- assert_equal 1, Resque.size(:statused)
17
- end
16
+ should "add the job to the queue" do
17
+ assert_equal 1, Resque.size(:statused)
18
+ end
18
19
 
19
- should "set the queued object to the current class" do
20
- job = Resque.pop(:statused)
21
- assert_equal @uuid, job['args'].first
22
- assert_equal "WorkingJob", job['class']
23
- end
20
+ should "set the queued object to the current class" do
21
+ job = Resque.pop(:statused)
22
+ assert_equal @uuid, job['args'].first
23
+ assert_equal "WorkingJob", job['class']
24
+ end
24
25
 
25
- should "add the uuid to the statuses" do
26
- assert_contains Resque::Plugins::Status::Hash.status_ids, @uuid
27
- end
26
+ should "add the uuid to the statuses" do
27
+ assert_contains Resque::Plugins::Status::Hash.status_ids, @uuid
28
+ end
28
29
 
29
- should "return a UUID" do
30
- assert_match(/^\w{32}$/, @uuid)
30
+ should "return a UUID" do
31
+ assert_match(/^\w{32}$/, @uuid)
32
+ end
31
33
  end
32
34
 
35
+ context "inline" do
36
+ setup do
37
+ Resque.stubs(:inline?).returns(true)
38
+ end
39
+
40
+ should "not queue a job" do
41
+ @uuid = WorkingJob.create('num' => 100)
42
+ assert_equal 0, Resque.size(:statused)
43
+ end
44
+
45
+ should "call perform" do
46
+ WorkingJob.any_instance.expects(:perform).once
47
+ @uuid = WorkingJob.create('num' => 100)
48
+ end
49
+ end
33
50
  end
34
51
 
35
52
  context ".create with a failing before_enqueue hook" do
@@ -59,17 +76,23 @@ class TestResquePluginsStatus < Test::Unit::TestCase
59
76
  end
60
77
 
61
78
  should "create the job with the provided arguments" do
62
-
63
- job = Resque.pop(:statused)
64
-
79
+ job = Resque.pop(:queue_name)
65
80
  assert_equal @job_args, job['args'].last
66
81
  end
67
82
  end
68
83
 
69
84
  context ".enqueue" do
70
- setup do
85
+ should "delegate to enqueue_to, filling in the queue from the class" do
71
86
  @uuid = BasicJob.enqueue(WorkingJob, :num => 100)
72
87
  @payload = Resque.pop(:statused)
88
+ assert_equal "WorkingJob", @payload['class']
89
+ end
90
+ end
91
+
92
+ context ".enqueue_to" do
93
+ setup do
94
+ @uuid = BasicJob.enqueue_to(:new_queue, WorkingJob, :num => 100)
95
+ @payload = Resque.pop(:new_queue)
73
96
  end
74
97
 
75
98
  should "add the job with the specific class to the queue" do
@@ -90,6 +113,23 @@ class TestResquePluginsStatus < Test::Unit::TestCase
90
113
 
91
114
  end
92
115
 
116
+ context ".dequeue" do
117
+ setup do
118
+ @uuid1 = BasicJob.enqueue(WorkingJob, :num => 100)
119
+ @uuid2 = BasicJob.enqueue(WorkingJob, :num => 100)
120
+ end
121
+
122
+ should "dequeue the job with the uuid from the correct queue" do
123
+ size = Resque.size(:statused)
124
+ BasicJob.dequeue(WorkingJob, @uuid2)
125
+ assert_equal size-1, Resque.size(:statused)
126
+ end
127
+ should "not dequeue any jobs with different uuids for same class name" do
128
+ BasicJob.dequeue(WorkingJob, @uuid2)
129
+ assert_equal @uuid1, Resque.pop(:statused)['args'].first
130
+ end
131
+ end
132
+
93
133
  context ".perform" do
94
134
  setup do
95
135
  @uuid = WorkingJob.create(:num => 100)
@@ -183,8 +223,7 @@ class TestResquePluginsStatus < Test::Unit::TestCase
183
223
  @performed = KillableJob.perform(*@payload1['args'])
184
224
  @performed = KillableJob.perform(*@payload2['args'])
185
225
 
186
- @status1 = Resque::Plugins::Status::Hash.get(@uuid1)
187
- @status2 = Resque::Plugins::Status::Hash.get(@uuid2)
226
+ @status1, @status2 = Resque::Plugins::Status::Hash.mget([@uuid1, @uuid2])
188
227
  end
189
228
 
190
229
  should "set the status to killed" do
@@ -225,8 +264,7 @@ class TestResquePluginsStatus < Test::Unit::TestCase
225
264
  @performed = KillableJob.perform(*@payload1['args'])
226
265
  @performed = KillableJob.perform(*@payload2['args'])
227
266
 
228
- @status1 = Resque::Plugins::Status::Hash.get(@uuid1)
229
- @status2 = Resque::Plugins::Status::Hash.get(@uuid2)
267
+ @status1, @status2 = Resque::Plugins::Status::Hash.mget([@uuid1, @uuid2])
230
268
  end
231
269
 
232
270
  should "set the status to killed" do
@@ -18,8 +18,8 @@ class TestResquePluginsStatusHash < Test::Unit::TestCase
18
18
  assert_equal 'my status', status.message
19
19
  end
20
20
 
21
- should "return false if the status is not set" do
22
- assert !Resque::Plugins::Status::Hash.get('whu')
21
+ should "return nil if the status is not set" do
22
+ assert_nil Resque::Plugins::Status::Hash.get('invalid_uuid')
23
23
  end
24
24
 
25
25
  should "decode encoded json" do
@@ -27,6 +27,30 @@ class TestResquePluginsStatusHash < Test::Unit::TestCase
27
27
  end
28
28
  end
29
29
 
30
+ context ".mget" do
31
+ should "return statuses as array of Resque::Plugins::Status::Hash for the uuids" do
32
+ uuid2 = Resque::Plugins::Status::Hash.create(Resque::Plugins::Status::Hash.generate_uuid)
33
+ Resque::Plugins::Status::Hash.set(uuid2, "my status2")
34
+ statuses = Resque::Plugins::Status::Hash.mget([@uuid, uuid2])
35
+ assert_equal 2, statuses.size
36
+ assert statuses.all?{|s| s.is_a?(Resque::Plugins::Status::Hash) }
37
+ assert_equal ['my status', 'my status2'], statuses.map(&:message)
38
+ end
39
+
40
+ should "return nil if a status is not set" do
41
+ statuses = Resque::Plugins::Status::Hash.mget(['invalid_uuid', @uuid])
42
+ assert_equal 2, statuses.size
43
+ assert_nil statuses[0]
44
+ assert statuses[1].is_a?(Resque::Plugins::Status::Hash)
45
+ assert_equal 'my status', statuses[1].message
46
+ end
47
+
48
+ should "decode encoded json" do
49
+ assert_equal ['json'],
50
+ Resque::Plugins::Status::Hash.mget([@uuid_with_json]).map{|h| h['im']}
51
+ end
52
+ end
53
+
30
54
  context ".set" do
31
55
 
32
56
  should "set the status for the uuid" do
@@ -100,22 +124,39 @@ class TestResquePluginsStatusHash < Test::Unit::TestCase
100
124
  @not_completed_status_id = Resque::Plugins::Status::Hash.create(Resque::Plugins::Status::Hash.generate_uuid)
101
125
  Resque::Plugins::Status::Hash.clear_completed
102
126
  end
103
-
127
+
104
128
  should "clear completed status" do
105
129
  assert_nil Resque::Plugins::Status::Hash.get(@completed_status_id)
106
130
  end
107
-
131
+
108
132
  should "not clear not-completed status" do
109
133
  status = Resque::Plugins::Status::Hash.get(@not_completed_status_id)
110
134
  assert status.is_a?(Resque::Plugins::Status::Hash)
111
135
  end
112
136
  end
113
-
137
+
138
+ context ".clear_failed" do
139
+ setup do
140
+ @failed_status_id = Resque::Plugins::Status::Hash.create(Resque::Plugins::Status::Hash.generate_uuid, {'status' => "failed"})
141
+ @not_failed_status_id = Resque::Plugins::Status::Hash.create(Resque::Plugins::Status::Hash.generate_uuid)
142
+ Resque::Plugins::Status::Hash.clear_failed
143
+ end
144
+
145
+ should "clear failed status" do
146
+ assert_nil Resque::Plugins::Status::Hash.get(@failed_status_id)
147
+ end
148
+
149
+ should "not clear not-failed status" do
150
+ status = Resque::Plugins::Status::Hash.get(@not_failed_status_id)
151
+ assert status.is_a?(Resque::Plugins::Status::Hash)
152
+ end
153
+ end
154
+
114
155
  context ".remove" do
115
156
  setup do
116
157
  Resque::Plugins::Status::Hash.remove(@uuid)
117
158
  end
118
-
159
+
119
160
  should "clear specify status" do
120
161
  assert_nil Resque::Plugins::Status::Hash.get(@uuid)
121
162
  end
@@ -149,32 +190,6 @@ class TestResquePluginsStatusHash < Test::Unit::TestCase
149
190
  end
150
191
 
151
192
  end
152
-
153
- # context ".count" do
154
- #
155
- # should "return a count of statuses" do
156
- # statuses = Resque::Plugins::Status::Hash.statuses
157
- # assert_equal 2, statuses.size
158
- # assert_equal statuses.size, Resque::Plugins::Status::Hash.count
159
- # end
160
- #
161
- # end
162
-
163
- context ".logger" do
164
- setup do
165
- @logger = Resque::Plugins::Status::Hash.logger(@uuid)
166
- end
167
-
168
- should "return a redisk logger" do
169
- assert @logger.is_a?(Redisk::Logger)
170
- end
171
-
172
- should "scope the logger to a key" do
173
- assert_match(/#{@uuid}/, @logger.name)
174
- end
175
-
176
- end
177
-
178
193
  end
179
194
 
180
195
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-09 00:00:00.000000000 Z
12
+ date: 2012-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: redisk
16
- requirement: &70186170509920 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 0.2.1
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70186170509920
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: resque
27
- requirement: &70186170509260 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ~>
@@ -32,21 +21,15 @@ dependencies:
32
21
  version: '1.19'
33
22
  type: :runtime
34
23
  prerelease: false
35
- version_requirements: *70186170509260
36
- - !ruby/object:Gem::Dependency
37
- name: uuid
38
- requirement: &70186170508780 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
39
25
  none: false
40
26
  requirements:
41
27
  - - ~>
42
28
  - !ruby/object:Gem::Version
43
- version: '2.3'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *70186170508780
29
+ version: '1.19'
47
30
  - !ruby/object:Gem::Dependency
48
31
  name: jeweler
49
- requirement: &70186170508220 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
50
33
  none: false
51
34
  requirements:
52
35
  - - ! '>='
@@ -54,7 +37,12 @@ dependencies:
54
37
  version: '0'
55
38
  type: :development
56
39
  prerelease: false
57
- version_requirements: *70186170508220
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
58
46
  description: resque-status is an extension to the resque queue system that provides
59
47
  simple trackable jobs. It provides a Resque::Plugins::Status::Hash class which can
60
48
  set/get the statuses of jobs and a Resque::Plugins::Status class that when included
@@ -108,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
96
  version: '0'
109
97
  requirements: []
110
98
  rubyforge_project: quirkey
111
- rubygems_version: 1.8.16
99
+ rubygems_version: 1.8.23
112
100
  signing_key:
113
101
  specification_version: 3
114
102
  summary: resque-status is an extension to the resque queue system that provides simple