resque-director 1.0.0 → 1.0.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -10,12 +10,17 @@ module Resque
10
10
  end
11
11
  end
12
12
 
13
- module ClassMethods
14
-
13
+ module ClassMethods
15
14
  def push(queue, item)
16
- if item.respond_to?(:[]=)
17
- timestamp = {'resdirecttime' => Time.now.utc.to_i}
18
- item[:args] = item[:args].push(timestamp)
15
+ begin
16
+ if item.respond_to?(:[]=)
17
+ job_class = constantize(item[:class] || item['class'])
18
+ if job_class && job_class.ancestors.include?(Resque::Plugins::Director)
19
+ timestamp = {'resdirecttime' => Time.now.utc.to_i}
20
+ item[:args] = item[:args].push(timestamp)
21
+ end
22
+ end
23
+ rescue
19
24
  end
20
25
  push_without_lifecycle queue, item
21
26
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{resque-director}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Nolan Frausto}]
@@ -1,5 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class TestNonDirectedJob
4
+ @queue = :non_direct
5
+ def self.perform
6
+ end
7
+ end
8
+
3
9
  describe Resque::Plugins::Director::Lifecycle do
4
10
  subject { Resque::Plugins::Director::Lifecycle }
5
11
 
@@ -16,5 +22,17 @@ describe Resque::Plugins::Director::Lifecycle do
16
22
  Resque.enqueue(TestJob, "arg1")
17
23
  Resque.pop("test").should == {"args"=>["arg1", {'resdirecttime' => time_stamp}], "class"=>"TestJob"}
18
24
  end
25
+
26
+ it "should not add job timestamps to non directed jobs" do
27
+ Resque.enqueue(TestNonDirectedJob, "arg1")
28
+ Resque.pop("non_direct").should == {"args"=>["arg1"], "class"=>"TestNonDirectedJob"}
29
+ end
30
+
31
+ it "should not add job timestamps that throw exceptions to direction logic" do
32
+ TestNonDirectedJob.stub(:ancestors).and_throw(:Exception)
33
+ Resque.enqueue(TestNonDirectedJob, "arg1")
34
+
35
+ Resque.pop("non_direct").should == {"args"=>["arg1"], "class"=>"TestNonDirectedJob"}
36
+ end
19
37
  end
20
38
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-director
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nolan Frausto