chewy_kiqqer 0.0.1 → 0.0.2

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: a364d1e2c036ad050b57aa91e61a72ee3319191e
4
- data.tar.gz: 9cefa2b4bdf0e56a55c6c5b532374c4735aabd24
3
+ metadata.gz: b46e354039335e662d5a2703dfefede25e6eb3ae
4
+ data.tar.gz: c274a92f28b5123db90522739df092eb0bdf0488
5
5
  SHA512:
6
- metadata.gz: 765a041ec58e3f32c1a853f686320cf5fb2d681c608f966a7781bad2c6894e67fad3b39c0bdc9009982f293aabda00e0aa460b38d5533a067a34da2c81a4d782
7
- data.tar.gz: 9df08fe3e7e40a4d275782fb7739aff7d0e01168b39af27f9f9408854ac66e2755e8efd3a1f1d5946e07940240ced3187788869f06475036f1026ddfb3832cf8
6
+ metadata.gz: 093e22e868d55e03a0a508b48aee199ee5887664a5ae09ca9decb533ad7c8ba2f7ebf0c90a03d5383cd29b7969950e8f2e22ae16aaea924d3e31a7006f8aef1a
7
+ data.tar.gz: 60a94f08eca01d4b087cdcb48da86949ade028aeaf4aa6479d79763b5a21156aef966ebc8ed3f12bba8a4784095f5c36e283fd12cd2f17c4ee13a6356135cb0c
data/README.md CHANGED
@@ -25,10 +25,13 @@ Just add the module and set it up:
25
25
  class User < ActiveRecord::Base
26
26
  include ChewyKiqqer::Mixin
27
27
 
28
- async_update_index 'users#user'
28
+ async_update_index index: 'users#user', queue: :other_than_default
29
29
  end
30
30
 
31
31
  You can also include the mixin into ActiveRecord::Base in an initializer if it should be generally available.
32
+ The queue name is optional. You can also set a default queue name for your application with:
33
+
34
+ ChewyKiqqer.default_queue = :my_queue
32
35
 
33
36
  ## Contributing
34
37
 
@@ -1,6 +1,15 @@
1
1
  require 'active_support/concern'
2
2
 
3
3
  module ChewyKiqqer
4
+
5
+ def self.default_queue=(queue)
6
+ @default_queue = queue
7
+ end
8
+
9
+ def self.default_queue
10
+ @default_queue || 'default'
11
+ end
12
+
4
13
  module Mixin
5
14
 
6
15
  extend ActiveSupport::Concern
@@ -9,15 +18,16 @@ module ChewyKiqqer
9
18
 
10
19
  attr_reader :index_name
11
20
 
12
- def async_update_index(index_name)
13
- @index_name = index_name
14
- after_save :queue_job
15
- after_destroy :queue_job
21
+ def async_update_index(index: nil, queue: ChewyKiqqer::default_queue)
22
+ @index_name = index
23
+ after_save :queue_chewy_job
24
+ after_destroy :queue_chewy_job
25
+ ChewyKiqqer::Worker.sidekiq_options queue: queue
16
26
  end
17
27
 
18
28
  end
19
29
 
20
- def queue_job
30
+ def queue_chewy_job
21
31
  ChewyKiqqer::Worker.perform_async(self.class.index_name, id)
22
32
  end
23
33
  end
@@ -1,3 +1,3 @@
1
1
  module ChewyKiqqer
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/mixin_spec.rb CHANGED
@@ -13,15 +13,26 @@ describe ChewyKiqqer::Mixin do
13
13
 
14
14
  context 'class methods' do
15
15
  it 'installs the hooks' do
16
- Gummi.should_receive(:after_save).with(:queue_job)
17
- Gummi.should_receive(:after_destroy).with(:queue_job)
18
- Gummi.async_update_index('xxx')
16
+ Gummi.should_receive(:after_save).with(:queue_chewy_job)
17
+ Gummi.should_receive(:after_destroy).with(:queue_chewy_job)
18
+ Gummi.async_update_index(index: 'xxx')
19
19
  end
20
20
 
21
21
  it 'knows the index_name' do
22
- Gummi.async_update_index('bar#foo')
22
+ Gummi.async_update_index(index: 'bar#foo')
23
23
  Gummi.index_name.should eq 'bar#foo'
24
24
  end
25
+
26
+ it 'sets the queue name' do
27
+ ChewyKiqqer::Worker.should_receive(:sidekiq_options).with(queue: :some_queue)
28
+ Gummi.async_update_index(index: 'xxx', queue: :some_queue)
29
+ end
30
+
31
+ it 'uses the default queue if none was specified' do
32
+ ChewyKiqqer::Worker.should_receive(:sidekiq_options).with(queue: :default3)
33
+ ChewyKiqqer.default_queue = :default3
34
+ Gummi.async_update_index(index: 'xxx')
35
+ end
25
36
  end
26
37
 
27
38
  context '#queue_job' do
@@ -29,9 +40,9 @@ describe ChewyKiqqer::Mixin do
29
40
  let(:record) { Gummi.new }
30
41
 
31
42
  it 'queues the job' do
32
- Gummi.async_update_index 'foo#bar'
43
+ Gummi.async_update_index index: 'foo#bar'
33
44
  ChewyKiqqer::Worker.should_receive(:perform_async).with('foo#bar', 17)
34
- record.queue_job
45
+ record.queue_chewy_job
35
46
  end
36
47
 
37
48
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chewy_kiqqer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Hahn
@@ -112,7 +112,7 @@ files:
112
112
  - lib/chewy_kiqqer/version.rb
113
113
  - lib/chewy_kiqqer/worker.rb
114
114
  - spec/mixin_spec.rb
115
- - spec/workder.spec.rb
115
+ - spec/worker.spec.rb
116
116
  homepage: ''
117
117
  licenses:
118
118
  - Apache V2
@@ -140,4 +140,4 @@ summary: Small helper gem that allows you to automatically run all chewy index u
140
140
  in sidekiq
141
141
  test_files:
142
142
  - spec/mixin_spec.rb
143
- - spec/workder.spec.rb
143
+ - spec/worker.spec.rb