attempt 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +3 -0
- data/README.md +6 -0
- data/attempt.gemspec +11 -5
- data/lib/attempt.rb +1 -1
- data/spec/attempt_spec.rb +24 -22
- data.tar.gz.sig +0 -0
- metadata +21 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc6bbb832eed33acf584990eca716d23081ee12b3a507e6e47d0b8298adae3fa
|
4
|
+
data.tar.gz: 590719816eb1bea8e4e59607f997936eec9303efb5a7507ee11558023f3e2fb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe34c159cc36940f05dc8c2108a0b1be600d8c57eacfa4f9d258f2d735fbf21e0524863f3d45568c7074d9ef9825bfe972d1bea102330e0846910dd415478b0
|
7
|
+
data.tar.gz: 61b00a2d427952342b5cf76b2a000691c30a4f341b27a8c150059b4a465701df29904bfd2c5759de97f236156116353f0a97de4695f05ee6f6d6ceee2e8ec98c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Ruby](https://github.com/djberg96/attempt/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/attempt/actions/workflows/ruby.yml)
|
2
|
+
|
1
3
|
## Description
|
2
4
|
A thin wrapper for begin + rescue + sleep + retry.
|
3
5
|
|
@@ -60,6 +62,10 @@ Replace the timeout library with a self selecting pipe if possible.
|
|
60
62
|
## Acknowledgements
|
61
63
|
This library is partially based on Mark Fowler's 'Attempt' Perl module.
|
62
64
|
|
65
|
+
## See Also
|
66
|
+
If you're looking for a heavier but more robust solution designed for remote
|
67
|
+
services, please take a look at gems like "circuitbox" or "faulty".
|
68
|
+
|
63
69
|
## Warranty
|
64
70
|
This package is provided "as is" and without any express or
|
65
71
|
implied warranties, including, without limitation, the implied
|
data/attempt.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'attempt'
|
5
|
-
spec.version = '0.6.
|
5
|
+
spec.version = '0.6.3'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.license = 'Apache-2.0'
|
8
8
|
spec.email = 'djberg96@gmail.com'
|
@@ -13,13 +13,19 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.cert_chain = Dir['certs/*']
|
14
14
|
|
15
15
|
spec.metadata = {
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
16
|
+
'homepage_uri' => 'https://github.com/djberg96/attempt',
|
17
|
+
'documentation_uri' => 'https://github.com/djberg96/attempt/wiki',
|
18
|
+
'changelog_uri' => 'https://github.com/djberg96/attempt/blob/main/CHANGES.md',
|
19
|
+
'source_code_uri' => 'https://github.com/djberg96/attempt/blob/main/lib/attempt.rb',
|
20
|
+
'bug_tracker_uri' => 'https://github.com/djberg96/attempt/issues',
|
21
|
+
'wiki_uri' => 'https://github.com/djberg96/attempt/wiki',
|
22
|
+
'rubygems_mfa_required' => 'true',
|
23
|
+
'github_repo' => 'https://github.com/djberg96/attempt'
|
20
24
|
}
|
21
25
|
|
22
26
|
spec.add_development_dependency('rake')
|
27
|
+
spec.add_development_dependency('rubocop')
|
28
|
+
|
23
29
|
spec.add_dependency('structured_warnings', '~> 0.4.0')
|
24
30
|
spec.add_dependency('safe_timeout', '~> 0.0.5')
|
25
31
|
spec.add_dependency('rspec', '~> 3.9')
|
data/lib/attempt.rb
CHANGED
@@ -12,7 +12,7 @@ require 'structured_warnings'
|
|
12
12
|
# running the same method before actually failing.
|
13
13
|
class Attempt
|
14
14
|
# The version of the attempt library.
|
15
|
-
VERSION = '0.6.
|
15
|
+
VERSION = '0.6.3'
|
16
16
|
|
17
17
|
# Warning raised if an attempt fails before the maximum number of tries
|
18
18
|
# has been reached.
|
data/spec/attempt_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#####################################################################
|
2
4
|
# attempt_spec.rb
|
3
5
|
#
|
@@ -19,49 +21,49 @@ RSpec.describe Attempt do
|
|
19
21
|
@tries = 2
|
20
22
|
@interval = 0.1
|
21
23
|
@timeout = 0.1
|
22
|
-
|
24
|
+
@value = 0
|
25
|
+
end
|
26
|
+
|
27
|
+
after do
|
28
|
+
@value = 0
|
29
|
+
end
|
30
|
+
|
31
|
+
after(:all) do
|
32
|
+
$stderr = STDERR
|
23
33
|
end
|
24
34
|
|
25
|
-
example
|
26
|
-
expect(Attempt::VERSION).to eq('0.6.
|
35
|
+
example 'version constant is set to expected value' do
|
36
|
+
expect(Attempt::VERSION).to eq('0.6.3')
|
27
37
|
expect(Attempt::VERSION).to be_frozen
|
28
38
|
end
|
29
39
|
|
30
|
-
example
|
40
|
+
example 'attempt works as expected without arguments' do
|
31
41
|
expect{ attempt{ 2 + 2 } }.not_to raise_error
|
32
42
|
end
|
33
43
|
|
34
|
-
example
|
35
|
-
expect{ attempt(tries: @tries){
|
36
|
-
expect(
|
44
|
+
example 'attempt retries the number of times specified' do
|
45
|
+
expect{ attempt(tries: @tries){ @value += 1; raise if @value < 2 } }.not_to raise_error
|
46
|
+
expect(@value).to eq(2)
|
37
47
|
end
|
38
48
|
|
39
|
-
example
|
49
|
+
example 'attempt retries the number of times specified with interval' do
|
40
50
|
expect{
|
41
|
-
attempt(tries: @tries, interval: @interval){
|
51
|
+
attempt(tries: @tries, interval: @interval){ @value += 1; raise if @value < 2 }
|
42
52
|
}.not_to raise_error
|
43
|
-
expect(
|
53
|
+
expect(@value).to eq(2)
|
44
54
|
end
|
45
55
|
|
46
|
-
example
|
56
|
+
example 'attempt retries the number of times specified with interval and timeout' do
|
47
57
|
expect{
|
48
|
-
attempt(tries: @tries, interval: @interval, timeout: @timeout){
|
58
|
+
attempt(tries: @tries, interval: @interval, timeout: @timeout){ @value += 1; raise if @value < 2 }
|
49
59
|
}.not_to raise_error
|
50
60
|
end
|
51
61
|
|
52
|
-
example
|
62
|
+
example 'attempt raises a timeout error if timeout value is exceeded' do
|
53
63
|
expect{ attempt(tries: 1, interval: 1, timeout: @timeout){ sleep 5 } }.to raise_error(Timeout::Error)
|
54
64
|
end
|
55
65
|
|
56
|
-
example
|
66
|
+
example 'attempt raises exception as expected' do
|
57
67
|
expect{ attempt(tries: 2, interval: 2){ raise } }.to raise_error(RuntimeError)
|
58
68
|
end
|
59
|
-
|
60
|
-
after do
|
61
|
-
$after = 0
|
62
|
-
end
|
63
|
-
|
64
|
-
after(:all) do
|
65
|
-
$stderr = STDERR
|
66
|
-
end
|
67
69
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attempt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
36
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2024-06-26 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rake
|
@@ -51,6 +51,20 @@ dependencies:
|
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rubocop
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
54
68
|
- !ruby/object:Gem::Dependency
|
55
69
|
name: structured_warnings
|
56
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,10 +132,14 @@ homepage: https://github.com/djberg96/attempt
|
|
118
132
|
licenses:
|
119
133
|
- Apache-2.0
|
120
134
|
metadata:
|
135
|
+
homepage_uri: https://github.com/djberg96/attempt
|
136
|
+
documentation_uri: https://github.com/djberg96/attempt/wiki
|
121
137
|
changelog_uri: https://github.com/djberg96/attempt/blob/main/CHANGES.md
|
122
138
|
source_code_uri: https://github.com/djberg96/attempt/blob/main/lib/attempt.rb
|
123
139
|
bug_tracker_uri: https://github.com/djberg96/attempt/issues
|
124
140
|
wiki_uri: https://github.com/djberg96/attempt/wiki
|
141
|
+
rubygems_mfa_required: 'true'
|
142
|
+
github_repo: https://github.com/djberg96/attempt
|
125
143
|
post_install_message:
|
126
144
|
rdoc_options: []
|
127
145
|
require_paths:
|
@@ -137,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
155
|
- !ruby/object:Gem::Version
|
138
156
|
version: '0'
|
139
157
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
158
|
+
rubygems_version: 3.4.10
|
141
159
|
signing_key:
|
142
160
|
specification_version: 4
|
143
161
|
summary: A thin wrapper for begin + rescue + sleep + retry
|
metadata.gz.sig
CHANGED
Binary file
|