perfect_retry 0.1.0 → 0.2.0

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: 11f50a4eb3fbde940a9d1dc119edeb2eeb861b34
4
- data.tar.gz: 51505ed2bc45f136f3c31980cee14f014712ffb5
3
+ metadata.gz: 5a5d8b36518c3ae65ced85419d129157159d49ff
4
+ data.tar.gz: 5d71eb684a0e7a8b15cc3e6435919fdce3e03872
5
5
  SHA512:
6
- metadata.gz: 5746dfc42dd2ed22e77f23ef3dbeae562939259d7954535ec764899ae09fff076eee2d1cbdcb95d601e43b85e1a2f95445883e9d47b0bc0b40d19e8bd5294516
7
- data.tar.gz: 705dc99d1c7cbf1248a925008ce1719a4e92fe4c3dfff399ab394681dc86cf8d47ade8118de05845f7c56c7e07d6dd13f45d8fa52a73e56eb03adcfa6b9445a4
6
+ metadata.gz: afa1392736a1f0e153dd3574ba97b112463deae81e85cf0b850c05df583918064752976b4871cbe9aa618331eb381faf4f2444a81e112f728b203d18c24bf6f5
7
+ data.tar.gz: 8f758b82c59ad5a98bc4e40afe7ab03672b8ed1a07fa51f0a44d2b0a3ca5dbc8ec84556adf2214ee13358ff718071a877b82faee6cc25e4ec8ae88b0d00eae62
data/NEWS.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.0 2015-11-09
2
+
3
+ - [enhancement] Add `dont_rescues` option.
4
+
1
5
  # 0.1.0 2015-11-06
2
6
 
3
7
  - [enhancement] Configure with block on initialize
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  [![Build Status](https://travis-ci.org/uu59/perfect_retry.svg?branch=master)](https://travis-ci.org/uu59/perfect_retry)
2
2
  [![Code Climate](https://codeclimate.com/github/uu59/perfect_retry/badges/gpa.svg)](https://codeclimate.com/github/uu59/perfect_retry)
3
3
  [![Test Coverage](https://codeclimate.com/github/uu59/perfect_retry/badges/coverage.svg)](https://codeclimate.com/github/uu59/perfect_retry/coverage)
4
+ [![Gem Version](https://badge.fury.io/rb/perfect_retry.svg)](https://badge.fury.io/rb/perfect_retry)
4
5
 
5
6
  # PerfectRetry
6
7
 
@@ -28,7 +29,12 @@ PerfectRetry.register(:timeout_handling) do |config|
28
29
  # default: [StandardError]
29
30
  config.rescues = [Timeout::Error, StandardError]
30
31
 
32
+ # Don't rescue, don't retry when these error raised.
33
+ # default: []
34
+ config.dont_rescues = [SyntaxError]
35
+
31
36
  # Sleep this seconds before next retry. `n` is a retry times (1-origin).
37
+ # Infinity retry if `nil` is set.
32
38
  # default: proc{|n| n ** 2}
33
39
  config.sleep = proc{|n| n * 5 }
34
40
 
@@ -56,6 +62,30 @@ PerfectRetry.with_retry(:timeout_handling) do
56
62
  end
57
63
  ```
58
64
 
65
+ ### Custom config without register
66
+
67
+ ```ruby
68
+ pr = PerfectRetry.new do |config|
69
+ # based on default config
70
+ config.sleep = 1
71
+ config.rescues = [Timeout::Error]
72
+ end
73
+
74
+ pr.with_retry do
75
+ open("http://example.com")
76
+ end
77
+
78
+ # Also you can extend registered config
79
+ pr = PerfectRetry.new(:some_registered) do |config|
80
+ config.ensure = proc{ puts "done" }
81
+ end
82
+
83
+ pr.with_retry do
84
+ # something to do
85
+ end
86
+ ```
87
+
88
+
59
89
  ### Manually retry
60
90
 
61
91
  ```ruby
@@ -1,7 +1,7 @@
1
1
  require "logger"
2
2
 
3
3
  class PerfectRetry
4
- class Config < Struct.new(:limit, :rescues, :logger, :sleep, :ensure)
4
+ class Config < Struct.new(:limit, :rescues, :dont_rescues, :logger, :sleep, :ensure)
5
5
  def self.create_from_hash(hash)
6
6
  config = new
7
7
  hash.each do |k, v|
@@ -1,3 +1,3 @@
1
1
  class PerfectRetry
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
data/lib/perfect_retry.rb CHANGED
@@ -9,6 +9,7 @@ class PerfectRetry
9
9
  DEFAULTS = {
10
10
  limit: 5,
11
11
  rescues: [StandardError],
12
+ dont_rescues: [],
12
13
  logger: Logger.new(STDERR),
13
14
  sleep: lambda{|n| n ** 2},
14
15
  ensure: lambda{},
@@ -51,6 +52,8 @@ class PerfectRetry
51
52
  count = 0
52
53
  begin
53
54
  retry_with_catch(count, &block)
55
+ rescue *config.dont_rescues => e
56
+ raise e
54
57
  rescue *config.rescues => e
55
58
  if should_retry?(count)
56
59
  count += 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perfect_retry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - uu59
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2015-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler