resque_solo 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: feb410b406d869198268c9ef1deb8ab9bdfab083
4
- data.tar.gz: 0dce7d025d84ca420bdf552d671afb85e8a547ee
3
+ metadata.gz: c1ef30a085579575c5f402c14e17dcc5ea978422
4
+ data.tar.gz: 6a836d44d8a6b97145576eb7431a3d7a46b4280d
5
5
  SHA512:
6
- metadata.gz: 981aff663802860c105b0f14ebcc1296b2a2505b8dc8a0914a82f47ad1024c16929dec8854466c4f5c0fb1334ba26073d350bca965c82dc9c984a39873bcc6b1
7
- data.tar.gz: eb8082e18db68b11ba43c88b409954e689bdc16f6d0e9757215a877b89b4f3fc0068399a21b0809c96f5c533884bb0bfbeb69bf565a8f1567042eaa449047c06
6
+ metadata.gz: feb8bebe5927a2a4d44333a01cd975f462b81d4a65383f2b3ea3a985937f37020269a1a2b13fe2fca6a1531600f715c35a85a24f118944f005a3993b1e720ed8
7
+ data.tar.gz: 0bce6bcf55e8cb0fe344257b722d724430a4ce9025f850071e9284f5801fcda1bcb8ee4bb9a9b96eb03a86e41d9a69e66e645a9bf5cd29e24f2fb3f0961f4982
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ group :test do
7
7
  gem 'pry'
8
8
  gem 'pry-byebug', platform: :mri_20
9
9
  gem 'fakeredis'
10
+ gem 'simplecov', require: false
10
11
  end
11
12
 
12
13
  gemspec
@@ -19,7 +19,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
19
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
 
21
21
 
22
- Copyright (c) 2013 Tee Parham
22
+ Copyright (c) 2013 Neighborland, Inc.
23
23
 
24
24
  MIT License
25
25
 
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # ResqueSolo
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/resque_solo.png)][gem]
4
- [![Build Status](https://api.travis-ci.org/teeparham/resque_solo.png)][build]
4
+ [![Build Status](https://api.travis-ci.org/neighborland/resque_solo.png)][build]
5
5
 
6
6
  [gem]: http://badge.fury.io/rb/resque_solo
7
- [build]: https://travis-ci.org/teeparham/resque_solo
7
+ [build]: https://travis-ci.org/neighborland/resque_solo
8
8
 
9
9
  ResqueSolo is a resque plugin to add unique jobs to resque.
10
10
 
@@ -1,13 +1,13 @@
1
1
  module Resque
2
2
  class Job
3
3
  class << self
4
- # Mark an item as queued after Resque::Job.create has called Resque.push
4
+ # Mark an item as queued
5
5
  def create_solo(queue, klass, *args)
6
- return create_without_solo(queue, klass, *args) if Resque.inline?
7
6
  item = {class: klass.to_s, args: args}
7
+ return create_without_solo(queue, klass, *args) if Resque.inline? || !ResqueSolo::Queue.is_unique?(item)
8
8
  return "EXISTED" if ResqueSolo::Queue.queued?(queue, item)
9
- # multi returns array of keys
10
9
  create_return_value = false
10
+ # redis transaction block
11
11
  Resque.redis.multi do
12
12
  create_return_value = create_without_solo(queue, klass, *args)
13
13
  ResqueSolo::Queue.mark_queued(queue, item)
@@ -22,8 +22,7 @@ module Resque
22
22
  item
23
23
  end
24
24
 
25
- # Mark all destroyed jobs as unqueued.
26
- # The original method only returns the amount of jobs destroyed, but not the jobs themselves.
25
+ # Mark destroyed jobs as unqueued
27
26
  def destroy_solo(queue, klass, *args)
28
27
  ResqueSolo::Queue.destroy(queue, klass, *args) unless Resque.inline?
29
28
  destroy_without_solo(queue, klass, *args)
@@ -75,8 +75,8 @@ module ResqueSolo
75
75
  end
76
76
 
77
77
  def const_for(item)
78
- const_get item_class(item)
78
+ Resque::Job.new(nil, nil).constantize item_class(item)
79
79
  end
80
80
  end
81
81
  end
82
- end
82
+ end
@@ -1,3 +1,3 @@
1
1
  module ResqueSolo
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = %w(tee@neighborland.com)
11
11
  spec.description = %q{Resque plugin to add unique jobs}
12
12
  spec.summary = %q{Resque plugin to add unique jobs}
13
- spec.homepage = "https://github.com/teeparham/resque_solo"
13
+ spec.homepage = "https://github.com/neighborland/resque_solo"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -1,5 +1,57 @@
1
1
  require 'test_helper'
2
2
 
3
- class QueueTest < Test::Unit::TestCase
3
+ module ResqueSolo
4
+ class QueueTest < Test::Unit::TestCase
5
+ context ".is_unique?" do
6
+ should "be false for non-unique job" do
7
+ refute Queue.is_unique?(class: 'FakeJob')
8
+ end
9
+
10
+ should "be false for invalid job class" do
11
+ refute Queue.is_unique?(class: 'InvalidJob')
12
+ end
13
+
14
+ should "be true for unique job" do
15
+ assert Queue.is_unique?(class: 'FakeUniqueJob')
16
+ end
17
+ end
18
+
19
+ context ".item_ttl" do
20
+ should "be -1 for non-unique job" do
21
+ assert_equal -1, Queue.item_ttl(class: 'FakeJob')
22
+ end
4
23
 
5
- end
24
+ should "be -1 for invalid job class" do
25
+ assert_equal -1, Queue.item_ttl(class: 'InvalidJob')
26
+ end
27
+
28
+ should "be -1 for unique job" do
29
+ assert_equal -1, Queue.item_ttl(class: 'FakeUniqueJob')
30
+ end
31
+
32
+ should "be job TTL" do
33
+ assert_equal 300, UniqueJobWithTtl.ttl
34
+ assert_equal 300, Queue.item_ttl(class: 'UniqueJobWithTtl')
35
+ end
36
+ end
37
+
38
+ context ".lock_after_execution_period" do
39
+ should "be 0 for non-unique job" do
40
+ assert_equal 0, Queue.lock_after_execution_period(class: 'FakeJob')
41
+ end
42
+
43
+ should "be 0 for invalid job class" do
44
+ assert_equal 0, Queue.lock_after_execution_period(class: 'InvalidJob')
45
+ end
46
+
47
+ should "be 0 for unique job" do
48
+ assert_equal 0, Queue.lock_after_execution_period(class: 'FakeUniqueJob')
49
+ end
50
+
51
+ should "be job lock period" do
52
+ assert_equal 150, UniqueJobWithLock.lock_after_execution_period
53
+ assert_equal 150, Queue.lock_after_execution_period(class: 'UniqueJobWithLock')
54
+ end
55
+ end
56
+ end
57
+ end
@@ -5,6 +5,12 @@ class ResqueTest < Test::Unit::TestCase
5
5
  Resque.redis.flushall
6
6
  end
7
7
 
8
+ should "be a valid plugin" do
9
+ assert_nothing_raised do
10
+ Resque::Plugin.lint(Resque::Plugins::UniqueJob)
11
+ end
12
+ end
13
+
8
14
  should "enqueue normal jobs" do
9
15
  Resque.enqueue FakeJob, "x"
10
16
  Resque.enqueue FakeJob, "x"
@@ -1,3 +1,8 @@
1
+ if ENV['SIMPLE_COV']
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ end
5
+
1
6
  require 'test/unit'
2
7
  require 'shoulda-context'
3
8
  require 'mocha/setup'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_solo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tee Parham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-09 00:00:00.000000000 Z
11
+ date: 2013-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque
@@ -79,7 +79,7 @@ files:
79
79
  - test/resque_test.rb
80
80
  - test/test_helper.rb
81
81
  - test/unique_job_test.rb
82
- homepage: https://github.com/teeparham/resque_solo
82
+ homepage: https://github.com/neighborland/resque_solo
83
83
  licenses:
84
84
  - MIT
85
85
  metadata: {}