Permalink
Browse files

1.2, bugfix release.

  • Loading branch information...
1 parent f40eed0 commit 6cab093be435d1ec0147cadf142ae3ff216aa306 @carlo committed Jan 22, 2009
Showing with 12 additions and 5 deletions.
  1. +6 −0 README.markdown
  2. +5 −4 lib/retryable.rb
  3. +1 −1 retryable.gemspec
View
@@ -47,6 +47,12 @@ First, [make sure GitHub is a gem source](http://gems.github.com/). Then, instal
* Unit tests
+## Changelog
+
+* 1.2: FIX -- block would run twice when `:tries` was set to `0`. (Thanks for the
+ heads-up to [Tuker](http://github.com/tuker).)
+
+
## Thanks
Many thanks to [Chu Yeow for this nifty piece of code](http://blog.codefront.net/2008/01/14/retrying-code-blocks-in-ruby-on-exceptions-whatever/). Look, I liked it
View
@@ -4,15 +4,16 @@
def retryable( options = {}, &block )
opts = { :tries => 1, :on => Exception }.merge(options)
-
- retry_exception, retries = [ opts[:on] ].flatten, opts[:tries]
+
+ return nil if opts[:tries] == 0
+
+ retry_exception, tries = [ opts[:on] ].flatten, opts[:tries]
begin
return yield
rescue *retry_exception
- retry if (retries -= 1) > 0
+ retry if (tries -= 1) > 0
end
yield
end
-
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "retryable"
- s.version = "1.1"
+ s.version = "1.2"
s.authors = [ "Carlo Zottmann", "Chu Yeow" ]
s.email = "carlo@zottmann.org"
s.homepage = "http://github.com/carlo/retryable"

0 comments on commit 6cab093

Please sign in to comment.