Retry Gem
Get Version
0.1.0
What
Benjamin Franklin said, “The definition of insanity is doing the same thing over and over and expecting different results.” Sometimes, though, a retry is exactly what you need. You may need to call something that is not reliable. Maybe it is a network connection that might be down temporarily. How often have you built retry logic around a bit of code that just might fail on occasion? This ruby gem takes care of that situation nicely.
Installing
sudo gem install retry
Demonstration of usage
require 'retry' 10.tries do raise 'network connection failed' if rand() < 0.7 puts 'success' end
Output:
> ruby tries.rb > Try 1 failed: network connection failed > Try 2 failed: network connection failed > success
License
This code is free to use under the terms of the MIT license.
Contact
Comments are welcome. Send an email to Haakon Sorensen.
Dr Nic, 1st June 2007
Theme extended from Paul Battley