job_hunter 0.2.1 → 0.3.0

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: b742f06915ea138b739dd47115c9b37749004c04
4
- data.tar.gz: eef0c4781b20c5e6439ce55f05b7f255c93e629a
3
+ metadata.gz: 231168212ece8b076df7e79a3b34d9b8ffa45ea8
4
+ data.tar.gz: 8c0e0e18d06590932ba8d7ed0e99117fa6045364
5
5
  SHA512:
6
- metadata.gz: 2f61221e0d4dd9879d366060559472fd12bb0235d950fd139984d966c6b461e68fd6578ecfddbbecb354e77e63c2653c6526dc605b80a771180a7de2436903dc
7
- data.tar.gz: da5e57f46bd755316ef41c121eb88ed0cbcd48c2abad389cb605fe3b4217d1bb2dbef7b786346cbe377e8160c523490f684311d6f93c33b44b40a6196b4fdead
6
+ metadata.gz: f2ea63d8a1a80ee2e07a38578dd937d3bc78629c4a82be2b701cc1eb269c622e511c9abd1b71c1fa62ee90c9ceae56b113f8601cf48d1b4f770c36703e922fdf
7
+ data.tar.gz: f6368c1797c64cbef76b7164aae65032d176a9286a4fb5e88b42fe62fed0029760d119100e60ec79b519148b45a0ef5ddb8322f5a0b3a1339c22a22da5975ccd
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --tty
3
+ --format documentation
data/Gemfile CHANGED
@@ -3,6 +3,6 @@ source 'https://rubygems.org'
3
3
  gem 'rake'
4
4
  gem 'delayed_job_active_record'
5
5
 
6
- gem 'rspec', '3.0.0.beta2', require: false
6
+ gem 'rspec', '3.0.0.rc1', require: false
7
7
 
8
8
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- job_hunter (0.2.1)
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.beta2)
36
- rspec-core (= 3.0.0.beta2)
37
- rspec-expectations (= 3.0.0.beta2)
38
- rspec-mocks (= 3.0.0.beta2)
39
- rspec-core (3.0.0.beta2)
40
- rspec-support (= 3.0.0.beta2)
41
- rspec-expectations (3.0.0.beta2)
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.beta2)
44
- rspec-mocks (3.0.0.beta2)
45
- rspec-support (= 3.0.0.beta2)
46
- rspec-support (3.0.0.beta2)
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.beta2)
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-13'
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'
@@ -17,7 +17,7 @@ module JobHunter
17
17
 
18
18
  def _defaults_
19
19
  { priority: @priority,
20
- run_at: @run_at.try(:call),
21
- queue: @queue }.select { |k, v| v }
20
+ run_at: @run_at.try(:call),
21
+ queue: @queue }.select { |k, v| v }
22
22
  end
23
23
  end
@@ -1,36 +1,11 @@
1
1
  module JobHunter
2
- def self.extended(klass)
3
- klass.include(InstanceMethods)
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
- Delayed::Job.where(handler: to_yaml, failed_at: nil).first
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
@@ -1,3 +1,3 @@
1
1
  module JobHunter
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -14,8 +14,7 @@ end
14
14
  describe JobHunter do
15
15
  let(:model_id) { 47 }
16
16
  let(:details) { 'Party Solver' }
17
- let(:run_at) { DateTime.parse('January 28, 2015 0800') }
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
@@ -1,10 +1,6 @@
1
1
  require 'rspec'
2
-
3
- require 'active_support/dependencies'
4
2
  require 'active_record'
5
-
6
3
  require 'delayed_job_active_record'
7
-
8
4
  require 'job_hunter'
9
5
 
10
6
  ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
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.1
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-13 00:00:00.000000000 Z
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