easy_retry 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/CHANGELOG.md +9 -1
- data/Gemfile +4 -0
- data/Gemfile.lock +72 -0
- data/README.md +2 -0
- data/lib/easy_retry/version.rb +1 -1
- data/lib/easy_retry.rb +16 -6
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c38067f87c684be6a9f709ec44bd993a6ac511998f0c946747143256d88fbe7c
|
4
|
+
data.tar.gz: a2ffb08ccca6d6a9abea4b4ba962b1fad80f356ec848e468523240edea2cf56c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd8bd03df3327dc40e163bdb594e06e1b5d35da04ec569699a5ded179515ab7e1e2757ab2e204d3bcaa53dff77601dc0924fee4e9e40b195c495f07dd91c9ae1
|
7
|
+
data.tar.gz: fcaae7e8ddfa04c0e58e7511e751feb67c699300b77d1cd52d5f94c3fae18fe872e1b10543d54480ecfe380cbcceb8f20eb708f53b700ee5b32bf8ac78d0b7ef
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [1.0.4] - 2022-11-17
|
4
|
+
|
5
|
+
- Bugfix for EasyRetry to work in Rails _and_ non-Rails projects
|
6
|
+
|
7
|
+
## [1.0.2] - 2022-11-17
|
8
|
+
|
9
|
+
- Improve the setup of the project
|
10
|
+
|
11
|
+
## [1.0.0] - 2022-11-16
|
4
12
|
|
5
13
|
- Initial release
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
easy_retry (1.0.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
coderay (1.1.3)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
docile (1.4.0)
|
13
|
+
json (2.6.2)
|
14
|
+
method_source (1.0.0)
|
15
|
+
parallel (1.22.1)
|
16
|
+
parser (3.1.2.1)
|
17
|
+
ast (~> 2.4.1)
|
18
|
+
pry (0.14.1)
|
19
|
+
coderay (~> 1.1)
|
20
|
+
method_source (~> 1.0)
|
21
|
+
rainbow (3.1.1)
|
22
|
+
rake (13.0.6)
|
23
|
+
regexp_parser (2.6.1)
|
24
|
+
rexml (3.2.5)
|
25
|
+
rspec (3.12.0)
|
26
|
+
rspec-core (~> 3.12.0)
|
27
|
+
rspec-expectations (~> 3.12.0)
|
28
|
+
rspec-mocks (~> 3.12.0)
|
29
|
+
rspec-core (3.12.0)
|
30
|
+
rspec-support (~> 3.12.0)
|
31
|
+
rspec-expectations (3.12.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.12.0)
|
34
|
+
rspec-mocks (3.12.0)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.12.0)
|
37
|
+
rspec-support (3.12.0)
|
38
|
+
rubocop (1.39.0)
|
39
|
+
json (~> 2.3)
|
40
|
+
parallel (~> 1.10)
|
41
|
+
parser (>= 3.1.2.1)
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
43
|
+
regexp_parser (>= 1.8, < 3.0)
|
44
|
+
rexml (>= 3.2.5, < 4.0)
|
45
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
46
|
+
ruby-progressbar (~> 1.7)
|
47
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
48
|
+
rubocop-ast (1.23.0)
|
49
|
+
parser (>= 3.1.1.0)
|
50
|
+
ruby-progressbar (1.11.0)
|
51
|
+
simplecov (0.21.2)
|
52
|
+
docile (~> 1.1)
|
53
|
+
simplecov-html (~> 0.11)
|
54
|
+
simplecov_json_formatter (~> 0.1)
|
55
|
+
simplecov-html (0.12.3)
|
56
|
+
simplecov_json_formatter (0.1.4)
|
57
|
+
unicode-display_width (2.3.0)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
x86_64-darwin-21
|
61
|
+
x86_64-linux
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
easy_retry!
|
65
|
+
pry
|
66
|
+
rake (~> 13.0)
|
67
|
+
rspec (~> 3.0)
|
68
|
+
rubocop (~> 1.21)
|
69
|
+
simplecov
|
70
|
+
|
71
|
+
BUNDLED WITH
|
72
|
+
2.3.7
|
data/README.md
CHANGED
data/lib/easy_retry/version.rb
CHANGED
data/lib/easy_retry.rb
CHANGED
@@ -2,27 +2,37 @@
|
|
2
2
|
|
3
3
|
require_relative "easy_retry/version"
|
4
4
|
|
5
|
+
# Extend the Numeric class with a #tries method
|
5
6
|
class Numeric
|
7
|
+
# rubocop:disable Metrics/MethodLength
|
6
8
|
def tries(rescue_from: [StandardError])
|
7
|
-
raise ArgumentError,
|
9
|
+
raise ArgumentError, "No block given" unless block_given?
|
8
10
|
|
9
11
|
max_retry = self
|
10
12
|
current_try = 1
|
13
|
+
result = nil
|
11
14
|
|
12
15
|
loop do
|
13
|
-
yield(current_try)
|
16
|
+
result = yield(current_try)
|
14
17
|
|
15
18
|
break
|
16
|
-
rescue *rescue_from =>
|
17
|
-
|
19
|
+
rescue *rescue_from => e
|
20
|
+
if defined?(Rails)
|
21
|
+
Rails.logger.error "Error: #{e.message} (#{current_try}/#{max_retry})"
|
22
|
+
else
|
23
|
+
puts "Error: #{e.message} (#{current_try}/#{max_retry})"
|
24
|
+
end
|
18
25
|
|
19
|
-
sleep
|
26
|
+
sleep current_try * current_try
|
20
27
|
|
21
28
|
current_try += 1
|
22
29
|
|
23
|
-
raise
|
30
|
+
raise e if current_try > max_retry
|
24
31
|
end
|
32
|
+
|
33
|
+
result
|
25
34
|
end
|
35
|
+
# rubocop:enable Metrics/MethodLength
|
26
36
|
|
27
37
|
alias try tries
|
28
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Goudeketting, Peter Duijnstee
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- CHANGELOG.md
|
23
23
|
- CODE_OF_CONDUCT.md
|
24
24
|
- Gemfile
|
25
|
+
- Gemfile.lock
|
25
26
|
- LICENSE.txt
|
26
27
|
- README.md
|
27
28
|
- Rakefile
|
@@ -35,6 +36,7 @@ metadata:
|
|
35
36
|
homepage_uri: https://github.com/GoudekettingRM/easy_retry
|
36
37
|
source_code_uri: https://github.com/GoudekettingRM/easy_retry
|
37
38
|
changelog_uri: https://github.com/GoudekettingRM/easy_retry/blob/main/CHANGELOG.md
|
39
|
+
rubygems_mfa_required: 'true'
|
38
40
|
post_install_message:
|
39
41
|
rdoc_options: []
|
40
42
|
require_paths:
|