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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d203deefb007c887481fc2b29f63da4582422c7fc20604acd9c9b88c0092f20c
4
- data.tar.gz: 64667abb6f3c5b3ef6a1cefbfe6bb2dbb0de5e0d09ed2b76f31a2a74e591d456
3
+ metadata.gz: c38067f87c684be6a9f709ec44bd993a6ac511998f0c946747143256d88fbe7c
4
+ data.tar.gz: a2ffb08ccca6d6a9abea4b4ba962b1fad80f356ec848e468523240edea2cf56c
5
5
  SHA512:
6
- metadata.gz: a6ccf3c01e0b0fc33db703542107377e4c07088d38cd41657bcbd5ee0281098c94f4b93d07b2792e3c349b2030adb1045ea88a4cb56bd51ad4a4aeeee2eb2c2b
7
- data.tar.gz: 0bafb03fbf2c70833483f494fd12cfd0b206d38599119568be5a3e70c1f6a7882548315124d7071ef0261d834069e9d0595462468673465e54fadec6182d8ad8
6
+ metadata.gz: bd8bd03df3327dc40e163bdb594e06e1b5d35da04ec569699a5ded179515ab7e1e2757ab2e204d3bcaa53dff77601dc0924fee4e9e40b195c495f07dd91c9ae1
7
+ data.tar.gz: fcaae7e8ddfa04c0e58e7511e751feb67c699300b77d1cd52d5f94c3fae18fe872e1b10543d54480ecfe380cbcceb8f20eb708f53b700ee5b32bf8ac78d0b7ef
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ NewCops: enable
3
+ TargetRubyVersion: 2.6.0
3
4
 
4
5
  Style/StringLiterals:
5
6
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2022-11-17
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
@@ -10,3 +10,7 @@ gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
+
14
+ gem "pry"
15
+
16
+ gem "simplecov", require: false
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
@@ -1,3 +1,5 @@
1
+ ![Specs](https://github.com/goudekettingrm/easy_retry/actions/workflows/main.yml/badge.svg)
2
+
1
3
  # EasyRetry
2
4
 
3
5
  <i>Easily retry a block of code a predetermined number of times.</i>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EasyRetry
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.4"
5
5
  end
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, 'No block given' unless block_given?
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 => error
17
- Rails.logger.error "Error: #{error.message} (#{current_try}/#{max_retry})"
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 (current_try * current_try).seconds
26
+ sleep current_try * current_try
20
27
 
21
28
  current_try += 1
22
29
 
23
- raise error if current_try > max_retry
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.2
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: