retry_unsafe_method 1.0.0 → 1.1.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: 1378c34387ccd8cd8eed38c959a0fefcf5860168
4
- data.tar.gz: 052ef0487a7ff2c333aae872fa7e0f682b9b239e
3
+ metadata.gz: 4409e6614374c70d00b65bcd7295fc1566f900a7
4
+ data.tar.gz: 8227b9dd81535ee0ba1fec8e670b2b9f3a564e56
5
5
  SHA512:
6
- metadata.gz: bbfe99896d058a1fc3fcb9c47aa3dfb7568b862dd8d3c8b449dba54d545d994a8d9ec6ff277422c0992f715874599d69fc1ddda0fe99d0bc7f56b625640726fe
7
- data.tar.gz: cee5c1827a9b61cd97d5083d48f22df613194dbd06a780a21acda8b9d841d7bc411a6ab5f9bc3b1d6f84c7232c95986041f5f60461f674a0324459b04317c266
6
+ metadata.gz: 326413ba145238c5fd6454a44fe0c9fb8446b3e26f7793f3cf296cb014045113b3f09298586437080ea6300bc848680016ba34e12546ffc81e622813d8a717e5
7
+ data.tar.gz: 4cbd2389020f77edbd6a9a7ed15f859f0521bd200878b62febc0ea638e2e84a9b2c35d610a6ec63b0d4712651f7f339e939c5cab51f1b19b16d47da752844dd1
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  /Gemfile.lock
2
2
  /.rspec
3
+ /coverage/
@@ -2,9 +2,14 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
- - 2.0.0
6
- - 2.1.8
7
- - 2.2.4
8
- - 2.3.0
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
+ - jruby
9
9
 
10
10
  before_install: gem install bundler -v 1.8.9 --no-ri --no-rdoc
11
+ script: bundle exec rspec spec
12
+
13
+ addons:
14
+ code_climate:
15
+ repo_token: 89a115773b9fcb5f81b919fee61c24162269c61447389e14bffde1153cd0d00d
data/Gemfile CHANGED
@@ -2,3 +2,11 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in retry_unsafe_method.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem 'codeclimate-test-reporter', require: nil
8
+
9
+ platform :ruby_18, :ruby_19 do
10
+ gem 'simplecov', '>= 0.10', '< 0.12', require: nil
11
+ end
12
+ end
data/README.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # RetryUnsafeMethod
2
-
3
2
  Allow easily make methods retriable
4
3
 
4
+ [![Version ](http://img.shields.io/gem/v/retry_unsafe_method.svg) ](https://rubygems.org/gems/retry_unsafe_method)
5
+ [![Travis CI](http://img.shields.io/travis/senid231/retry_unsafe_method.svg)](https://travis-ci.org/senid231/retry_unsafe_method)
6
+ [![CodeClimate](https://codeclimate.com/github/senid231/retry_unsafe_method/badges/gpa.svg)](https://codeclimate.com/github/senid231/retry_unsafe_method/badges)
7
+ [![Coverage](https://codeclimate.com/github/senid231/retry_unsafe_method/badges/coverage.svg)](https://codeclimate.com/github/senid231/retry_unsafe_method/badges)
8
+
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile:
@@ -29,8 +33,16 @@ and add after method definition
29
33
 
30
34
  or
31
35
 
36
+ `retry_unsafe_method <method_name>, <retries_qty>, *<exceptions>`, <options>
37
+
38
+ or
39
+
32
40
  `retry_unsafe_method <method_name>, <retries_qty>, &<block>`
33
41
 
42
+ or
43
+
44
+ `retry_unsafe_method <method_name>, <retries_qty>, <options>, &<block>`
45
+
34
46
  ```ruby
35
47
  require 'retry_unsafe_method'
36
48
 
@@ -46,9 +58,15 @@ class A
46
58
 
47
59
  retry_unsafe_method :some_method, 2, SomeError
48
60
  # or
61
+ retry_unsafe_method :some_method, 2, SomeError, wait: 5
62
+ # or
49
63
  retry_unsafe_method :some_method, 2 do |e|
50
64
  e.is_a?(SomeError)
51
65
  end
66
+ # or
67
+ retry_unsafe_method :some_method, 2, wait: 5 do |e|
68
+ e.is_a?(SomeError)
69
+ end
52
70
 
53
71
  end
54
72
  ```
@@ -8,6 +8,10 @@ module RetryUnsafeMethod
8
8
  module ClassMethods
9
9
 
10
10
  def retry_unsafe_method(method_name, retry_count, *exceptions, &block)
11
+ options = exceptions.last.is_a?(Hash) ? exceptions.pop : {}
12
+
13
+ wait = options.delete(:wait)
14
+ wait = nil if wait && (!wait.is_a?(Numeric) || wait <= 0)
11
15
 
12
16
  unless method_defined?(method_name) || private_method_defined?(method_name)
13
17
  raise StandardError.new("method #{method_name} is not defined")
@@ -34,6 +38,7 @@ module RetryUnsafeMethod
34
38
 
35
39
  if instance_variable_get(ivar) < retry_count
36
40
  instance_variable_set(ivar, instance_variable_get(ivar) + 1)
41
+ sleep(wait) if wait
37
42
  retry
38
43
  else
39
44
  remove_instance_variable(ivar)
@@ -1,3 +1,3 @@
1
1
  module RetryUnsafeMethod
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retry_unsafe_method
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Talakevich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.4.8
105
+ rubygems_version: 2.6.6
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Allow to retry unsafe methods.