Project

try-eager

0.0
No commit activity in last 3 years
No release in over 3 years
You can use this gem to wait for async activity to become active.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.5
>= 0
 Project Readme

try-eager

Try to run proc repeatedly until options[:until] returns true. Ruby >= 2.0.0 is required.

Installation

Add this line to your application's Gemfile:

gem 'try-eager'

And then execute:

$ bundle

Or install it yourself as:

$ gem install try-eager

Usage

require 'try/eager'

# wait for mail to receive and raise TimeoutError when Mail not found in 10 seconds
mail = Try.eager until: ->(m) { m.to_addrs.any? {|a| a.include?('sunaot') } do
  Mail.last
end

# wait for mail to receive with max retry 3 times (no timeout)
mail = Try.(3.times, until: ->(m) { m.body.include?('sunaot') }) do
  Mail.last
end

# you may also set timeout sec and interval sec
Try.eager until: ->(args) { false },
          timeout: 2,
	  interval: 0.5 do
  puts :hello
end

Contributing

  1. Fork it ( http://github.com/sunaot/try-eager/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request