retriable 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 03ab323e10afdc5d56ba1cb8dafe474b384ebab4
4
+ data.tar.gz: b8018f10039fd5add022bd21bc89e3df94c742bf
5
+ SHA512:
6
+ metadata.gz: eb6d13ae6aef5945c071c28d122b2018c6faadc8a4567542a3b687e12905cd335c7542627b3be8d3d4b386189d31f9c0af0d3d214dc8d87047e0708d4606327b
7
+ data.tar.gz: 3446c5920eb959cb60bd7a5cf4de8ace6df8480fbe80b82b526676557f5e0316780544b8986fb022a44a6d679a7a515931c236e67805d335fbf47938bf831735
@@ -1,11 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.2
5
4
  - 1.9.3
6
5
  - 2.0.0
7
- - jruby-18mode # JRuby in 1.8 mode
8
6
  - jruby-19mode # JRuby in 1.9 mode
9
- - rbx-18mode
10
- - rbx-19mode
11
- - ree
7
+ - rbx-19mode
@@ -1,3 +1,6 @@
1
+ ## 1.4.1
2
+ * Fixes non kernel mode bug. Remove DSL class, move `#retriable` into Retriable module. Thanks @mkrogemann.
3
+
1
4
  ## 1.4.0
2
5
  * By default, retriable doesn't monkey patch `Kernel`. If you want this functionality,
3
6
  you can `require 'retriable/core_ext/kernel'.
@@ -1,5 +1,17 @@
1
1
  require 'retriable/retry'
2
- require 'retriable/dsl'
3
2
 
4
3
  module Retriable
4
+ extend self
5
+
6
+ def retriable(opts = {}, &block)
7
+ raise LocalJumpError unless block_given?
8
+
9
+ Retry.new do |r|
10
+ r.tries = opts[:tries] if opts[:tries]
11
+ r.on = opts[:on] if opts[:on]
12
+ r.interval = opts[:interval] if opts[:interval]
13
+ r.timeout = opts[:timeout] if opts[:timeout]
14
+ r.on_retry = opts[:on_retry] if opts[:on_retry]
15
+ end.perform(&block)
16
+ end
5
17
  end
@@ -1,6 +1,6 @@
1
1
  require 'retriable'
2
2
 
3
3
  module Kernel
4
- include Retriable::DSL
4
+ include Retriable
5
5
  private :retriable
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module Retriable
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
@@ -1,6 +1,6 @@
1
- # encoding: utf-8
2
-
3
- $:.push File.expand_path("../lib", __FILE__)
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require "retriable/version"
5
5
 
6
6
  Gem::Specification.new do |s|
@@ -22,5 +22,5 @@ Gem::Specification.new do |s|
22
22
  s.require_paths = ["lib"]
23
23
 
24
24
  s.add_development_dependency 'rake'
25
- s.add_development_dependency 'minitest'
25
+ s.add_development_dependency 'minitest', '>= 5.0'
26
26
  end
@@ -1,34 +1,33 @@
1
1
  require 'retriable'
2
- require 'retriable/core_ext/kernel'
3
2
  require 'minitest/autorun'
4
3
 
5
4
  class RetriableTest < Minitest::Test
6
5
  def test_raise_no_block
7
6
  assert_raises LocalJumpError do
8
- retriable :on => StandardError
7
+ Retriable.retriable :on => StandardError
9
8
  end
10
9
  end
11
10
 
12
11
  def test_without_arguments
13
12
  i = 0
14
13
 
15
- retriable do
14
+ Retriable.retriable do
16
15
  i += 1
17
16
  raise StandardError.new
18
17
  end
19
- rescue StandardError
18
+ rescue StandardError
20
19
  assert_equal 3, i
21
20
  end
22
21
 
23
22
  def test_with_one_exception_and_two_tries
24
23
  i = 0
25
24
 
26
- retriable :on => EOFError, :tries => 2 do
25
+ Retriable.retriable :on => EOFError, :tries => 2 do
27
26
  i += 1
28
27
  raise EOFError.new
29
28
  end
30
29
 
31
- rescue EOFError
30
+ rescue EOFError
32
31
  assert_equal i, 2
33
32
  end
34
33
 
@@ -40,7 +39,7 @@ class RetriableTest < Minitest::Test
40
39
  assert_equal i, tries
41
40
  end
42
41
 
43
- retriable :on => [EOFError, ArgumentError], :on_retry => on_retry, :tries => 5, :sleep => 0.2 do |h|
42
+ Retriable.retriable :on => [EOFError, ArgumentError], :on_retry => on_retry, :tries => 5, :sleep => 0.2 do |h|
44
43
  i += 1
45
44
  raise ArgumentError.new
46
45
  end
@@ -57,10 +56,29 @@ class RetriableTest < Minitest::Test
57
56
  attempts
58
57
  end
59
58
 
60
- retriable :on => EOFError, :interval => sleeper do |h|
59
+ Retriable.retriable :on => EOFError, :interval => sleeper do |h|
61
60
  raise EOFError.new
62
61
  end
63
- rescue
62
+ rescue
64
63
  assert_equal was_called, true
65
64
  end
65
+
66
+ def test_kernel_ext
67
+ assert_raises NoMethodError do
68
+ retriable do
69
+ puts 'should raise NoMethodError'
70
+ end
71
+ end
72
+
73
+ require 'retriable/core_ext/kernel'
74
+ i = 0
75
+
76
+ retriable do
77
+ i += 1
78
+ raise StandardError.new
79
+ end
80
+
81
+ rescue StandardError
82
+ assert_equal 3, i
83
+ end
66
84
  end
metadata CHANGED
@@ -1,48 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retriable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
5
- prerelease:
4
+ version: 1.4.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jack Chu
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2013-09-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: minitest
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '5.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '5.0'
46
41
  description: Retriable is an simple DSL to retry a code block if an exception should
47
42
  be raised. This is especially useful when interacting external api/services or file
48
43
  system calls.
@@ -61,7 +56,6 @@ files:
61
56
  - Rakefile
62
57
  - lib/retriable.rb
63
58
  - lib/retriable/core_ext/kernel.rb
64
- - lib/retriable/dsl.rb
65
59
  - lib/retriable/retry.rb
66
60
  - lib/retriable/version.rb
67
61
  - retriable.gemspec
@@ -69,33 +63,26 @@ files:
69
63
  homepage: http://github.com/kamui/retriable
70
64
  licenses:
71
65
  - MIT
66
+ metadata: {}
72
67
  post_install_message:
73
68
  rdoc_options: []
74
69
  require_paths:
75
70
  - lib
76
71
  required_ruby_version: !ruby/object:Gem::Requirement
77
- none: false
78
72
  requirements:
79
- - - ! '>='
73
+ - - '>='
80
74
  - !ruby/object:Gem::Version
81
75
  version: '0'
82
- segments:
83
- - 0
84
- hash: -2391393966112040014
85
76
  required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
77
  requirements:
88
- - - ! '>='
78
+ - - '>='
89
79
  - !ruby/object:Gem::Version
90
80
  version: '0'
91
- segments:
92
- - 0
93
- hash: -2391393966112040014
94
81
  requirements: []
95
82
  rubyforge_project: retriable
96
- rubygems_version: 1.8.25
83
+ rubygems_version: 2.0.7
97
84
  signing_key:
98
- specification_version: 3
85
+ specification_version: 4
99
86
  summary: Retriable is an simple DSL to retry a code block if an exception should be
100
87
  raised.
101
88
  test_files:
@@ -1,17 +0,0 @@
1
- require 'retriable/retry'
2
-
3
- module Retriable
4
- module DSL
5
- def retriable(opts = {}, &block)
6
- raise LocalJumpError unless block_given?
7
-
8
- Retry.new do |r|
9
- r.tries = opts[:tries] if opts[:tries]
10
- r.on = opts[:on] if opts[:on]
11
- r.interval = opts[:interval] if opts[:interval]
12
- r.timeout = opts[:timeout] if opts[:timeout]
13
- r.on_retry = opts[:on_retry] if opts[:on_retry]
14
- end.perform(&block)
15
- end
16
- end
17
- end