retryable 3.0.4 → 3.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ab358b3281332a22c7a8995598640d74e4c275c3
4
- data.tar.gz: 1af4d17e2c3c0e3171a98a594273b3c1098be0d1
2
+ SHA256:
3
+ metadata.gz: 4adf6498d39c3a76bb6c3ea4c2ef8bd479d620b65c969cc43c970ae1dc1e8dd7
4
+ data.tar.gz: d60ff44f63519d2df8a70ca8729e5db2cda03e2b9ba2bf9af42dae66df9f65d5
5
5
  SHA512:
6
- metadata.gz: 790c0d7cca9fcec2f1bdcb36ded2451e50af933cb6d181842918a8bf8d3f714bd54716ad63714a218be3825ae8e9d09d16b0b2b1ab8e61a6d75d62553952303b
7
- data.tar.gz: 208cdf97146fb043b88b9c046bf0edba12095dc0b3bbd6808702e7620f6457521f7a2cc8ad4a2bd9c0a5e646f1f277f5cbb3ba672278ea56fb8b61dd1e374e7c
6
+ metadata.gz: 24fc7de390a5996451a2c9d0296811b031ce21e38a3c4374d4a002e3e12d6278c07f31a84dd86efcf9006fd2ff2f7ef40e40da791f2d98dedb56ee2b0c7b3006
7
+ data.tar.gz: '09360b246ca4c6868fc40807f1fc4978933f3aae138237efdb396e51e52a36fd2c8e1a44310365336cc9d43c08df62726d9d390739e3fdcce23640abdb0b2733'
@@ -1,3 +1,9 @@
1
+ ## Retryable 3.0.5 ##
2
+
3
+ Instead of :infinite magic constant from now on you can just use Ruby's native infinity data type e.g. Float::INFINITY.
4
+ See https://github.com/nfedyashev/retryable/commit/16f60bb09560c9470266dca8cd47c934594a67c5
5
+ This version is backwards compatible with older versions, no changes needed in your code.
6
+
1
7
  ## Retryable 3.0.4 ##
2
8
 
3
9
  Fixed typo in exception message given invalid :matching argument type https://github.com/nfedyashev/retryable/pull/29
data/README.md CHANGED
@@ -50,9 +50,11 @@ end
50
50
 
51
51
  Try the block forever.
52
52
  ```ruby
53
- Retryable.retryable(tries: :infinite) do
53
+ # For ruby versions prior to 1.9.2 use :infinite symbol instead
54
+ Retryable.retryable(tries: Float::INFINITY) do
54
55
  # code here
55
56
  end
57
+
56
58
  ```
57
59
 
58
60
  Do something, retry up to four times for either `ArgumentError` or
@@ -261,11 +263,12 @@ versions:
261
263
 
262
264
  * Ruby 1.9.3
263
265
  * Ruby 2.0.0
264
- * Ruby 2.1.2
265
- * Ruby 2.2.0
266
- * Ruby 2.3.1
267
- * Ruby 2.4.0
268
- * Ruby 2.5.0
266
+ * Ruby 2.1.10
267
+ * Ruby 2.2.10
268
+ * Ruby 2.3.8
269
+ * Ruby 2.4.5
270
+ * Ruby 2.5.3
271
+ * Ruby 2.6.1
269
272
 
270
273
  *NOTE: if you need `retryable` to be running on Ruby 1.8 use gem versions prior to 3.0.0 release*
271
274
 
@@ -75,7 +75,9 @@ module Retryable
75
75
  rescue *on_exception => exception
76
76
  raise unless configuration.enabled?
77
77
  raise unless matches?(exception.message, matching)
78
- raise if tries != :infinite && retries + 1 >= tries
78
+
79
+ infinite_retries = :infinite || tries.respond_to?(:infinite?) && tries.infinite?
80
+ raise if tries != infinite_retries && retries + 1 >= tries
79
81
 
80
82
  # Interrupt Exception could be raised while sleeping
81
83
  begin
@@ -15,7 +15,7 @@ module Retryable
15
15
 
16
16
  # @return [Integer]
17
17
  def patch
18
- 4
18
+ 5
19
19
  end
20
20
 
21
21
  # @return [Hash]
@@ -21,6 +21,22 @@ RSpec.describe Retryable do
21
21
  end
22
22
  end
23
23
 
24
+ context 'when configured locally' do
25
+ it 'does not affect the original global config' do
26
+ new_sleep = 2
27
+ original_sleep = described_class.configuration.send(:sleep)
28
+
29
+ expect(original_sleep).not_to eq(new_sleep)
30
+
31
+ counter(tries: 2, sleep: new_sleep) do |tries, ex|
32
+ raise StandardError if tries < 1
33
+ end
34
+
35
+ actual = described_class.configuration.send(:sleep)
36
+ expect(actual).to eq(original_sleep)
37
+ end
38
+ end
39
+
24
40
  context 'when configured globally with custom sleep parameter' do
25
41
  it 'passes retry count and exception on retry' do
26
42
  expect(Kernel).to receive(:sleep).once.with(3)
@@ -78,14 +78,29 @@ RSpec.describe Retryable do
78
78
  expect(counter.count).to eq(3)
79
79
  end
80
80
 
81
- it 'retries infinitely' do
82
- expect do
83
- Timeout.timeout(3) do
84
- counter(tries: :infinite, sleep: 0.1) { raise StandardError }
85
- end
86
- end.to raise_error Timeout::Error
81
+ context 'infinite retries' do
82
+ example 'with magic constant' do
83
+ expect do
84
+ Timeout.timeout(3) do
85
+ counter(tries: :infinite, sleep: 0.1) { raise StandardError }
86
+ end
87
+ end.to raise_error Timeout::Error
88
+
89
+ expect(counter.count).to be > 10
90
+ end
87
91
 
88
- expect(counter.count).to be > 10
92
+ example 'with native infinity data type' do
93
+ expect do
94
+ require 'bigdecimal'
95
+
96
+ tries = [Float::INFINITY, BigDecimal::INFINITY, BigDecimal("1.0") / BigDecimal("0.0")]
97
+ Timeout.timeout(3) do
98
+ counter(tries: tries.sample, sleep: 0.1) { raise StandardError }
99
+ end
100
+ end.to raise_error Timeout::Error
101
+
102
+ expect(counter.count).to be > 10
103
+ end
89
104
  end
90
105
 
91
106
  it 'executes exponential backoff scheme for :sleep option' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retryable
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Fedyashev
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-02-20 00:00:00.000000000 Z
13
+ date: 2019-11-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -70,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: 1.3.6
72
72
  requirements: []
73
- rubyforge_project:
74
- rubygems_version: 2.4.5.2
73
+ rubygems_version: 3.0.3
75
74
  signing_key:
76
75
  specification_version: 4
77
76
  summary: Retrying code blocks in Ruby