job_hunter 0.2.1 → 0.3.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.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +13 -13
- data/README.md +12 -1
- data/job_hunter.gemspec +1 -1
- data/lib/job_hunter/defaults.rb +2 -2
- data/lib/job_hunter/dj_wrappers.rb +22 -28
- data/lib/job_hunter/version.rb +1 -1
- data/spec/job_hunter_spec.rb +1 -2
- data/spec/spec_helper.rb +0 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 231168212ece8b076df7e79a3b34d9b8ffa45ea8
|
4
|
+
data.tar.gz: 8c0e0e18d06590932ba8d7ed0e99117fa6045364
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ea63d8a1a80ee2e07a38578dd937d3bc78629c4a82be2b701cc1eb269c622e511c9abd1b71c1fa62ee90c9ceae56b113f8601cf48d1b4f770c36703e922fdf
|
7
|
+
data.tar.gz: f6368c1797c64cbef76b7164aae65032d176a9286a4fb5e88b42fe62fed0029760d119100e60ec79b519148b45a0ef5ddb8322f5a0b3a1339c22a22da5975ccd
|
data/.rspec
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
job_hunter (0.
|
4
|
+
job_hunter (0.3.0)
|
5
5
|
delayed_job_active_record (>= 3.0, < 5.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -32,18 +32,18 @@ GEM
|
|
32
32
|
json (1.8.1)
|
33
33
|
minitest (5.3.3)
|
34
34
|
rake (10.3.1)
|
35
|
-
rspec (3.0.0.
|
36
|
-
rspec-core (= 3.0.0.
|
37
|
-
rspec-expectations (= 3.0.0.
|
38
|
-
rspec-mocks (= 3.0.0.
|
39
|
-
rspec-core (3.0.0.
|
40
|
-
rspec-support (= 3.0.0.
|
41
|
-
rspec-expectations (3.0.0.
|
35
|
+
rspec (3.0.0.rc1)
|
36
|
+
rspec-core (= 3.0.0.rc1)
|
37
|
+
rspec-expectations (= 3.0.0.rc1)
|
38
|
+
rspec-mocks (= 3.0.0.rc1)
|
39
|
+
rspec-core (3.0.0.rc1)
|
40
|
+
rspec-support (= 3.0.0.rc1)
|
41
|
+
rspec-expectations (3.0.0.rc1)
|
42
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (= 3.0.0.
|
44
|
-
rspec-mocks (3.0.0.
|
45
|
-
rspec-support (= 3.0.0.
|
46
|
-
rspec-support (3.0.0.
|
43
|
+
rspec-support (= 3.0.0.rc1)
|
44
|
+
rspec-mocks (3.0.0.rc1)
|
45
|
+
rspec-support (= 3.0.0.rc1)
|
46
|
+
rspec-support (3.0.0.rc1)
|
47
47
|
sqlite3 (1.3.9)
|
48
48
|
thread_safe (0.3.3)
|
49
49
|
tzinfo (1.1.0)
|
@@ -56,5 +56,5 @@ DEPENDENCIES
|
|
56
56
|
delayed_job_active_record
|
57
57
|
job_hunter!
|
58
58
|
rake
|
59
|
-
rspec (= 3.0.0.
|
59
|
+
rspec (= 3.0.0.rc1)
|
60
60
|
sqlite3 (~> 1)
|
data/README.md
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
JobHunter
|
2
2
|
==========
|
3
3
|
|
4
|
-
JobHunter is a library that cuts down on boilerplate when creating and finding [Delayed::Job](https://github.com/collectiveidea/delayed_job) custom jobs.
|
4
|
+
JobHunter is a library that cuts down on boilerplate when creating and finding [Delayed::Job](https://github.com/collectiveidea/delayed_job) custom jobs. It replaces this:
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
Delayed::Job.enqueue(MyCustomJob.new(data, other_data), priority: 100, run_at: 5.hours.from_now)
|
8
|
+
```
|
9
|
+
|
10
|
+
With this:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
MyCustomJob.create(data, other_data)
|
14
|
+
```
|
15
|
+
|
5
16
|
|
6
17
|
Installation
|
7
18
|
-------
|
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-
|
10
|
+
gem.date = '2014-05-20'
|
11
11
|
gem.authors = ['Ryan Moser']
|
12
12
|
gem.email = 'ryanpmoser@gmail.com'
|
13
13
|
gem.homepage = 'https://github.com/moserrya/job_hunter'
|
data/lib/job_hunter/defaults.rb
CHANGED
@@ -1,36 +1,11 @@
|
|
1
1
|
module JobHunter
|
2
|
-
def self.extended(
|
3
|
-
|
4
|
-
end
|
5
|
-
|
6
|
-
def create(*args)
|
7
|
-
new_with_options(*args).create
|
8
|
-
end
|
9
|
-
|
10
|
-
def find(*args)
|
11
|
-
new_with_options(*args).find
|
12
|
-
end
|
13
|
-
|
14
|
-
def find_or_create(*args)
|
15
|
-
new_with_options(*args).find_or_create
|
16
|
-
end
|
17
|
-
|
18
|
-
def destroy(*args)
|
19
|
-
new_with_options(*args).destroy
|
20
|
-
end
|
21
|
-
|
22
|
-
def new_with_options(*args)
|
23
|
-
options = args.extract_options!
|
24
|
-
job = new(*args)
|
25
|
-
job.define_singleton_method(:_options_) do
|
26
|
-
self.class._defaults_.merge(options)
|
27
|
-
end
|
28
|
-
job
|
2
|
+
def self.extended(base_class)
|
3
|
+
base_class.include(InstanceMethods)
|
29
4
|
end
|
30
5
|
|
31
6
|
module InstanceMethods
|
32
7
|
def find
|
33
|
-
|
8
|
+
scope.first
|
34
9
|
end
|
35
10
|
|
36
11
|
def create
|
@@ -45,9 +20,28 @@ module JobHunter
|
|
45
20
|
find.try(:destroy)
|
46
21
|
end
|
47
22
|
|
23
|
+
def scope
|
24
|
+
Delayed::Job.where(handler: to_yaml, failed_at: nil)
|
25
|
+
end
|
26
|
+
|
48
27
|
private
|
49
28
|
def _options_
|
50
29
|
{}
|
51
30
|
end
|
52
31
|
end
|
32
|
+
|
33
|
+
InstanceMethods.public_instance_methods.each do |method_sym|
|
34
|
+
define_method(method_sym) do |*args|
|
35
|
+
new_with_options(*args).send method_sym
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def new_with_options(*args)
|
40
|
+
options = args.extract_options!
|
41
|
+
job = new(*args)
|
42
|
+
job.define_singleton_method(:_options_) do
|
43
|
+
self.class._defaults_.merge(options)
|
44
|
+
end
|
45
|
+
job
|
46
|
+
end
|
53
47
|
end
|
data/lib/job_hunter/version.rb
CHANGED
data/spec/job_hunter_spec.rb
CHANGED
@@ -14,8 +14,7 @@ end
|
|
14
14
|
describe JobHunter do
|
15
15
|
let(:model_id) { 47 }
|
16
16
|
let(:details) { 'Party Solver' }
|
17
|
-
let(:
|
18
|
-
let(:options) { { run_at: run_at } }
|
17
|
+
let(:options) { { priority: 7 } }
|
19
18
|
|
20
19
|
context '.create' do
|
21
20
|
it 'enqueues Delayed Jobs' do
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: delayed_job_active_record
|
@@ -80,6 +80,7 @@ extensions: []
|
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
82
|
- ".gitignore"
|
83
|
+
- ".rspec"
|
83
84
|
- Gemfile
|
84
85
|
- Gemfile.lock
|
85
86
|
- LICENSE
|