unique_job 0.4.0 → 0.4.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
  SHA256:
3
- metadata.gz: 4cbff20f17ded63e7824299a196e4b46da0314658cfdebfb79566847905e7720
4
- data.tar.gz: 1c7778662c1ab6f3e2e00ed4dec04886bc72159f09ec3a3e9a244168e19802f7
3
+ metadata.gz: e9d6d855680edc62ab346669253c4673b6876f6661641a6b8be4228da95790b6
4
+ data.tar.gz: a50467a6416a3e8d38982a8cf183aaa93def34e8a0a6f647a43b954a8a6d4860
5
5
  SHA512:
6
- metadata.gz: 5ac698df69e9a40d980066ce2d37bc58af82da710ba82b7c91a99a7965651c1ea5b717c410b34e8bc0d6668543172814a63fcd714609d34eb39bfb44497da8d9
7
- data.tar.gz: 9acb300b369ada327e4946af6bb4f1c11e2a23398e75209427310a8478ee8c7844ce56e805256ccafe93e6b5dedce33c0cfdc74bfce15a2fef3839223cb7f328
6
+ metadata.gz: 2a63e1bea71e94f76e050cf68442cb7503259a25995ea66501da6946c82a2a9dcdcd4cd2190d778fa16829c46e34051023cadb695b473d843baae984cf32b7a3
7
+ data.tar.gz: c7e82bd747e21a6bdbf1b12a479eb35b9f102f3466d8d87ebc7eba8e03951ace19219cb482ea86ed9762fec27c306a579609d7004a41be1bf7e05aca6132bdc6
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ -fd
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
- gem "minitest", "~> 5.0"
7
+ gem "rspec"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unique_job (0.4.0)
4
+ unique_job (0.4.1)
5
5
  redis
6
6
  sidekiq (> 6.0, < 7.0)
7
7
 
@@ -9,10 +9,23 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  connection_pool (2.2.3)
12
- minitest (5.14.2)
12
+ diff-lcs (1.4.4)
13
13
  rack (2.2.3)
14
14
  rake (12.3.3)
15
15
  redis (4.2.2)
16
+ rspec (3.10.0)
17
+ rspec-core (~> 3.10.0)
18
+ rspec-expectations (~> 3.10.0)
19
+ rspec-mocks (~> 3.10.0)
20
+ rspec-core (3.10.1)
21
+ rspec-support (~> 3.10.0)
22
+ rspec-expectations (3.10.1)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-mocks (3.10.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-support (3.10.3)
16
29
  sidekiq (6.1.2)
17
30
  connection_pool (>= 2.2.2)
18
31
  rack (~> 2.0)
@@ -22,8 +35,8 @@ PLATFORMS
22
35
  ruby
23
36
 
24
37
  DEPENDENCIES
25
- minitest (~> 5.0)
26
38
  rake (~> 12.0)
39
+ rspec
27
40
  unique_job!
28
41
 
29
42
  BUNDLED WITH
@@ -10,10 +10,7 @@ module UniqueJob
10
10
  unique_key = worker.unique_key(*args)
11
11
  logger.debug { "[UniqueJob] Calculate unique key worker=#{worker.class} key=#{unique_key}" }
12
12
 
13
- if unique_key.nil? || unique_key.to_s.empty?
14
- logger.warn { "[UniqueJob] Don't check a job with a blank key worker=#{worker.class} key=#{unique_key}" }
15
- yield
16
- elsif check_uniqueness(worker, unique_key.to_s)
13
+ if check_uniqueness(worker, unique_key)
17
14
  yield
18
15
  else
19
16
  logger.debug { "[UniqueJob] Duplicate job skipped worker=#{worker.class} key=#{unique_key}" }
@@ -25,13 +22,18 @@ module UniqueJob
25
22
  end
26
23
  end
27
24
 
28
- def check_uniqueness(worker, unique_key)
25
+ def check_uniqueness(worker, key)
26
+ if key.nil? || key.to_s.empty?
27
+ logger.warn { "[UniqueJob] Don't check a job with a blank key worker=#{worker.class} key=#{key}" }
28
+ return false
29
+ end
30
+
29
31
  history = job_history(worker)
30
32
 
31
- if history.exists?(unique_key)
33
+ if history.exists?(key)
32
34
  false
33
35
  else
34
- history.add(unique_key)
36
+ history.add(key)
35
37
  true
36
38
  end
37
39
  end
@@ -1,3 +1,3 @@
1
1
  module UniqueJob
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unique_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ts-3156
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-25 00:00:00.000000000 Z
11
+ date: 2021-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -52,6 +52,7 @@ extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
54
  - ".gitignore"
55
+ - ".rspec"
55
56
  - ".ruby-version"
56
57
  - ".travis.yml"
57
58
  - CODE_OF_CONDUCT.md