exp_retry 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 689b4850be81414c693f20cc05417570e1306fcf
4
- data.tar.gz: 3f193047aec30cd9478757d0185ce7bcdb3307bb
3
+ metadata.gz: 5936c444eeb797c31e32202090c0f5828dc1de27
4
+ data.tar.gz: 9d8881e4467bfd72fa97384642de3c5e674202bc
5
5
  SHA512:
6
- metadata.gz: d3e9fdd91d93ad81e9754e939a8318e71fc10ebf73f0adc03192e8f239d78c6a8c0c62872e937b63b2beb39f8946df05fd69bc6b50a8bc7023e18c625aaf7f4c
7
- data.tar.gz: 6d4bdcd5cf4ab99f5b4433804b376840b29ee61f3afcbfc848ae73fcc03cad5cebe8382ea18c81503a7f01230268173d99967512dd628a8d05fa1bce0249dd5d
6
+ metadata.gz: 2dc986e4bfbda307a4722fbc448402aa9005fae0f659a45a92b830d451196e9fa001ea9ea780336fb850d57a93012e4ef5a62c094d36e35f8d8242e76950156d
7
+ data.tar.gz: b44bbc1f2a869fe9fe4de7a10c862bf638338cb647fa3ee949e3e7d757b924f8d36f71b8d945f888bf951a8de992030d8d8fcb8c8ab3a627841d9dedde7bd753
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exp_retry (0.0.7)
4
+ exp_retry (0.0.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/Readme.md CHANGED
@@ -52,3 +52,12 @@ ExpRetry.new(retries: 5).call do
52
52
  something_unreliable # will retry 5 times
53
53
  end
54
54
  ```
55
+
56
+ There is also a helper method to simplify calling on a new instance:
57
+
58
+ ```ruby
59
+ ExpRetry.for(retries: 5, exception: [SpecificError, AnotherError]) do
60
+ something_generic # errors will surface immediately
61
+ something_specific # errors will trigger up to 5 retries
62
+ end
63
+ ```
data/exp-retry.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'exp_retry'
3
- s.version = '0.0.7'
3
+ s.version = '0.0.8'
4
4
  s.date = '2018-10-17'
5
5
  s.summary = 'Exponential backoff retry'
6
6
  s.description = 'A simple exponential backoff retry wrapper.'
data/lib/exp_retry.rb CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  # Exponential backoff retry wrapper
4
4
  class ExpRetry
5
+ def self.for(retries: 3, exception: StandardError)
6
+ new(retries: retries, exception: exception).call { yield }
7
+ end
8
+
5
9
  def initialize(retries: 3, exception: StandardError)
6
10
  @retries = retries
7
11
  @exception = exception
@@ -4,9 +4,13 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe ExpRetry do
6
6
  it 'should allow normal execution' do
7
- r = ExpRetry.new.call do
8
- 'Something'
9
- end
7
+ r = ExpRetry.new.call { 'Something' }
8
+
9
+ expect(r).to eql('Something')
10
+ end
11
+
12
+ it 'should allow normal execution using for' do
13
+ r = ExpRetry.for { 'Something' }
10
14
 
11
15
  expect(r).to eql('Something')
12
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exp_retry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander