try-until 0.4.1 → 0.4.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmU5N2NkZTJlMjgxODcyZTZkZjM4YzM1MDQyMWY2NGE2M2YzNjZmZg==
4
+ OTQ3ZDA3YmRlZDlhMjYwNjhmYjJhMWU4ZTI3ZDJlODdjMmIzOTA1NA==
5
5
  data.tar.gz: !binary |-
6
- NjljNDU1NmFkZjgyNjFhNmVmZGFkNDFkNTUzZjdiYjcxYzJmYWEzNg==
6
+ N2U0ZWI4N2M5MWZlMDY2MmYxZmI4OTY1YzM0YTc3ZjJlZjBjNDc1ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ODgzMDIxMzY3ZWY3Mzc1OWI5MTdjYTQ3OWZlZjI0NGNjZmIzY2QzM2QwOWVm
10
- ZWY5MDIyYTBiM2I3MWU4OTdiNTIyMDc3ZGQwY2E4OTczYjhiYWE0ZjExY2Rm
11
- MzA2NzhkYmNiODlmMmVlNGNlNjhkY2Q4YWJhYjVhMTBiMjNhMTk=
9
+ NmFlNWRhNjlmN2E1NTQ4ZDIwN2JlMjc4NjU0N2MxOGY0YTc4OTNiOGQ5ZGMw
10
+ Mzg1NzdlYjAwZmE5N2I3M2ZkMGJlOTMzNDdmZGMxOWZkMTA5Y2YzNmY5YTNk
11
+ NmIwMTQ5NzBhZWU3NzdlZGY1ZGU2NTEwNzZkNmUyZDMxNjZlNDI=
12
12
  data.tar.gz: !binary |-
13
- YzgzZDBhNGM3MzBkMGFjYmVmNzM5NTg1MThhMzhmNjRhMDg4YjlmMmIwODIx
14
- ZWM2ZmY2YTRjZGM1M2U2NDFkZjMyNzVlMzU0M2QzZTdiZDE1ZWZlZTQ0Yjk1
15
- NWNkZWU3Zjg2NmIyZDJkYzdlMTFhN2VjOTM1NDdkZjVhMjY0OWM=
13
+ NDY4ZmE2YmIzM2FhZWNkMjc5NzNlZTYxNzRlMjU2MzI4OGZhNGNhMzRlNjM1
14
+ MDIyYTk1MmJmYTU5MjcxZDc2NzRjMjg5NTkyNTRiYWU1OTdhMDFkOGE2OTcx
15
+ MmRjNmZlMDFkMGEwNmYwODkzMjgwY2Y5MjZhMjVjNTM4ZGE5Mzg=
@@ -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 = 0
65
+ count = 1
66
66
  condition_met = false
67
- while count < @attempts
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 + 1 == @attempts
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 + 1}|outcome: #{outcome}|#{@attempts - count - 1} attempts left\n")
96
+ @log_to.printf("#{Time.new}|attempt ##{count}|outcome: #{outcome}|#{@attempts - count} attempts left\n")
97
97
  end
98
98
 
99
99
  def defaults
@@ -1,3 +1,3 @@
1
1
  module TryUntil
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
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.1
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-24 00:00:00.000000000 Z
11
+ date: 2013-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec