job_hunter 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2b4465adfe13c33ce17ab91820f12af51f646c6
4
- data.tar.gz: 1895c7dfc3ea369904d621fce89cea593f96ff9d
3
+ metadata.gz: b742f06915ea138b739dd47115c9b37749004c04
4
+ data.tar.gz: eef0c4781b20c5e6439ce55f05b7f255c93e629a
5
5
  SHA512:
6
- metadata.gz: 424a79f337a54bb1f8f68cd6f0a8d190dd06b3b86cc8b79a925567a589596401a3ba2a222e87a26386bdf4f1c744e8494cf80f0ad75a2b076348ded39ef224d0
7
- data.tar.gz: 09e41ede15f6743e121c4b575f3dbce3a3996c4a3460e53cd5144e9c057e16925afe128bfba44b8e690260d6158097af1f8a1aa7284b13a1b0b805ef6f5e61ff
6
+ metadata.gz: 2f61221e0d4dd9879d366060559472fd12bb0235d950fd139984d966c6b461e68fd6578ecfddbbecb354e77e63c2653c6526dc605b80a771180a7de2436903dc
7
+ data.tar.gz: da5e57f46bd755316ef41c121eb88ed0cbcd48c2abad389cb605fe3b4217d1bb2dbef7b786346cbe377e8160c523490f684311d6f93c33b44b40a6196b4fdead
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- job_hunter (0.2.0)
4
+ job_hunter (0.2.1)
5
5
  delayed_job_active_record (>= 3.0, < 5.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -51,6 +51,8 @@ Adding an index to `handler` in the `delayed_jobs` table is recommended if you p
51
51
 
52
52
  All of these methods will return a `Delayed::Job` if they find, create, or destroy a job and `nil` otherwise.
53
53
 
54
+ `find` will not return failed jobs (all attempts exhausted). `find_or_create` will likewise create a new job if there is an identical failed job.
55
+
54
56
  The `create` and `find_or_create` methods accept the same options hash as `Delayed::Job.enqueue`. Options passed in to these methods (`run_at`, `queue`, and `priority`) will override the defauls set in your custom job class. Options passed in to `find_or_create` will not affect a job already enqueued.
55
57
 
56
58
  These class methods have corresponding instance methods:
data/job_hunter.gemspec CHANGED
@@ -7,7 +7,7 @@ require 'job_hunter/version'
7
7
  Gem::Specification.new do |gem|
8
8
  gem.name = 'job_hunter'
9
9
  gem.version = JobHunter::VERSION
10
- gem.date = '2014-05-09'
10
+ gem.date = '2014-05-13'
11
11
  gem.authors = ['Ryan Moser']
12
12
  gem.email = 'ryanpmoser@gmail.com'
13
13
  gem.homepage = 'https://github.com/moserrya/job_hunter'
@@ -22,14 +22,15 @@ module JobHunter
22
22
  def new_with_options(*args)
23
23
  options = args.extract_options!
24
24
  job = new(*args)
25
- job.define_singleton_method :_options_,
26
- -> { self.class._defaults_.merge(options) }
25
+ job.define_singleton_method(:_options_) do
26
+ self.class._defaults_.merge(options)
27
+ end
27
28
  job
28
29
  end
29
30
 
30
31
  module InstanceMethods
31
32
  def find
32
- Delayed::Job.where(handler: to_yaml).first
33
+ Delayed::Job.where(handler: to_yaml, failed_at: nil).first
33
34
  end
34
35
 
35
36
  def create
@@ -37,7 +38,7 @@ module JobHunter
37
38
  end
38
39
 
39
40
  def find_or_create
40
- find || create
41
+ find or create
41
42
  end
42
43
 
43
44
  def destroy
@@ -1,3 +1,3 @@
1
1
  module JobHunter
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -46,6 +46,11 @@ describe JobHunter do
46
46
  it 'finds the job given the same arguments' do
47
47
  expect(KustomJob.find(model_id, details)).to eq(@job)
48
48
  end
49
+
50
+ it 'does not find failed jobs' do
51
+ @job.touch(:failed_at)
52
+ expect(KustomJob.find(model_id, details)).to be_nil
53
+ end
49
54
  end
50
55
 
51
56
  context '.find_or_create' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job_hunter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-09 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: delayed_job_active_record