Project

tryout

0.0
No commit activity in last 3 years
No release in over 3 years
Allows you to do dirty stuff without messing up your code base.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.2.2
>= 2.0.0
~> 0.8.3
 Project Readme

Tryout Build Status

Allows you to do dirty stuff without messing up your code base.

Background

I've found myself using begin/rescue/retry through HTTP requests frequently, due timeout, weird stuff caused by a messed up third-party service, or even due internet connectivity lost.

How to use

value = Tryout.try { RestClient.get('http://www.google.com') }.retry(3)

if/unless: call any method on the result of the try block.

value = Tryout.try { RestClient.get('http://www.google.com') }.retry(3, :if => :empty?)
value = Tryout.try { RestClient.get('http://www.google.com') }.retry(3, :unless => :present?)

block: the result of the try block will be passed as argument for the second one. Is up to you when the result is considered invalid.

value = Tryout.try { RestClient.get('http://www.google.com') }.retry(3) do |invalid|
  # Invalidate when response have length lesser than 100
  invalid.length < 100
end

License

Tryout is released under the MIT license. Please read the LICENSE file.