try-until 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/try_until/repeatedly.rb +5 -5
- data/lib/try_until/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTQ3ZDA3YmRlZDlhMjYwNjhmYjJhMWU4ZTI3ZDJlODdjMmIzOTA1NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2U0ZWI4N2M5MWZlMDY2MmYxZmI4OTY1YzM0YTc3ZjJlZjBjNDc1ZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmFlNWRhNjlmN2E1NTQ4ZDIwN2JlMjc4NjU0N2MxOGY0YTc4OTNiOGQ5ZGMw
|
10
|
+
Mzg1NzdlYjAwZmE5N2I3M2ZkMGJlOTMzNDdmZGMxOWZkMTA5Y2YzNmY5YTNk
|
11
|
+
NmIwMTQ5NzBhZWU3NzdlZGY1ZGU2NTEwNzZkNmUyZDMxNjZlNDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDY4ZmE2YmIzM2FhZWNkMjc5NzNlZTYxNzRlMjU2MzI4OGZhNGNhMzRlNjM1
|
14
|
+
MDIyYTk1MmJmYTU5MjcxZDc2NzRjMjg5NTkyNTRiYWU1OTdhMDFkOGE2OTcx
|
15
|
+
MmRjNmZlMDFkMGEwNmYwODkzMjgwY2Y5MjZhMjVjNTM4ZGE5Mzg=
|
data/lib/try_until/repeatedly.rb
CHANGED
@@ -62,9 +62,9 @@ module TryUntil
|
|
62
62
|
# of error is among the ones defined in @rescues.
|
63
63
|
def execute
|
64
64
|
Kernel.sleep(@delay) if @delay > 0
|
65
|
-
count =
|
65
|
+
count = 1
|
66
66
|
condition_met = false
|
67
|
-
while count
|
67
|
+
while count <= @attempts
|
68
68
|
begin
|
69
69
|
result = @probe.sample
|
70
70
|
if @stop_when.call(result)
|
@@ -75,11 +75,11 @@ module TryUntil
|
|
75
75
|
log_outcome(count, 'CONDITION_NOT_MET')
|
76
76
|
rescue *@rescues => exception
|
77
77
|
log_outcome(count, exception.class)
|
78
|
-
raise exception, "During final attempt (#{@attempts} configured) target returned #{exception}" if count
|
78
|
+
raise exception, "During final attempt (#{@attempts} configured) target returned #{exception}" if count == @attempts
|
79
79
|
ensure
|
80
80
|
unless condition_met
|
81
|
+
Kernel.sleep @interval if @interval > 0 && count < @attempts
|
81
82
|
count += 1
|
82
|
-
Kernel.sleep @interval if @interval > 0
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -93,7 +93,7 @@ module TryUntil
|
|
93
93
|
|
94
94
|
private
|
95
95
|
def log_outcome(count, outcome)
|
96
|
-
@log_to.printf("#{Time.new}|attempt ##{count
|
96
|
+
@log_to.printf("#{Time.new}|attempt ##{count}|outcome: #{outcome}|#{@attempts - count} attempts left\n")
|
97
97
|
end
|
98
98
|
|
99
99
|
def defaults
|
data/lib/try_until/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: try-until
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Krogemann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|