rrrretry 0.0.1 → 1.0.0

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: 36154b4211fda80e983eef71cbfa30daadfcd53c
4
+ data.tar.gz: 0159cb8dd37a17e7173a28eb1340d712ea231653
5
+ SHA512:
6
+ metadata.gz: b55c11cdea1a3cb5d52ae208e8ffb9d1cbfa4def375778f560dd44d668391a2d15a93f520d2eae4c1998c8f90883799fc5021708a4c46eaccc175020a9a90bbf
7
+ data.tar.gz: 5302070acba04dfbbe63b611bda8f4ba62ee72d64e5d357ede85c48225252b366d44d0275ac6278eed2a08006c722f7422975006a205591a9a7c9f1179194406
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+
3
+ pkg/
data/Gemfile CHANGED
@@ -1,7 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- group :development, :test do
4
- gem 'rake'
5
- gem 'jeweler', '>=1.5.2'
6
- end
7
-
3
+ gemspec
@@ -1,20 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rrrretry (1.0.0)
5
+
1
6
  GEM
2
7
  remote: http://rubygems.org/
3
8
  specs:
4
- git (1.2.5)
5
- jeweler (1.8.4)
6
- bundler (~> 1.0)
7
- git (>= 1.2.5)
8
- rake
9
- rdoc
10
- json (1.7.6)
11
- rake (10.0.3)
12
- rdoc (3.12)
13
- json (~> 1.4)
9
+ rake (10.1.0)
14
10
 
15
11
  PLATFORMS
16
12
  ruby
17
13
 
18
14
  DEPENDENCIES
19
- jeweler (>= 1.5.2)
20
15
  rake
16
+ rrrretry!
data/README.md CHANGED
@@ -6,7 +6,9 @@ Because `retry` was already taken.
6
6
 
7
7
  In your `Gemfile` add:
8
8
 
9
- gem 'rrrretry'
9
+ ```ruby
10
+ gem 'rrrretry'
11
+ ```
10
12
 
11
13
  Then run `bundle install`.
12
14
 
@@ -76,5 +78,5 @@ Yes. Do as I say, not as I do.
76
78
 
77
79
  ## License
78
80
 
79
- MIT YO. See MIT-LICENSE for more info
81
+ MIT YO. See [MIT-LICENSE](https://github.com/schneems/rrrretry/blob/master/MIT-LICENSE) for more info.
80
82
 
data/Rakefile CHANGED
@@ -20,19 +20,3 @@ Rake::TestTask.new(:test) do |t|
20
20
  t.pattern = 'test/**/*_test.rb'
21
21
  t.verbose = false
22
22
  end
23
-
24
-
25
-
26
- require 'jeweler'
27
- Jeweler::Tasks.new do |gem|
28
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
29
- gem.name = "rrrretry"
30
- gem.homepage = "http://github.com/schneems/rrrretry"
31
- gem.license = "MIT"
32
- gem.summary = %Q{re-run your code}
33
- gem.description = %Q{did i stutter?}
34
- gem.email = "richard.schneeman@gmail.com"
35
- gem.authors = ["schneems"]
36
- # dependencies defined in Gemfile
37
- end
38
- Jeweler::RubygemsDotOrgTasks.new
@@ -25,11 +25,23 @@ module Enumerable
25
25
  # array.each.retry(Exception, SignalException) { |i| i.call }
26
26
  # # => 1
27
27
  def retry(*exceptions, &block)
28
- exceptions << StandardError if exceptions.empty?
29
- enum ||= self.to_enum
30
- yield enum.next
31
- rescue *exceptions => e
32
- last_exception = e and retry unless e.is_a? StopIteration
33
- raise last_exception unless last_exception.nil?
28
+ exceptions << StandardError if exceptions.empty?
29
+ enum = self.to_enum
30
+ last_exception = nil
31
+
32
+ while true do
33
+ begin
34
+ value = enum.next
35
+ rescue StopIteration => e
36
+ raise last_exception if last_exception
37
+ return false
38
+ end
39
+
40
+ begin
41
+ return yield value
42
+ rescue *exceptions => e
43
+ last_exception = e
44
+ end
45
+ end
34
46
  end
35
- end
47
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "rrrretry"
5
+ gem.version = "1.0.0"
6
+ gem.authors = ["Richard Schneeman"]
7
+ gem.email = ["richard.schneeman+rubygems@gmail.com"]
8
+ gem.description = %q{ Retries code when an exception is raised an arbitrary number of times }
9
+ gem.summary = %q{ Did I stutter? }
10
+ gem.homepage = "https://github.com/schneems/rrrretry"
11
+ gem.license = "MIT"
12
+
13
+ gem.files = `git ls-files`.split($/)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.require_paths = ["lib"]
17
+
18
+ gem.add_development_dependency "rake"
19
+ end
@@ -30,4 +30,18 @@ class Rrrrretry_test < Test::Unit::TestCase
30
30
  assert_equal 1, result
31
31
  GenericEnumerable.new([]).retry {} # ensure no errors
32
32
  end
33
- end
33
+
34
+ def test_raising_stop_iteration
35
+ assert_raise(StopIteration) do
36
+ 2.times.retry do
37
+ raise StopIteration
38
+ end
39
+ end
40
+
41
+ assert_raise(StopIteration) do
42
+ 1.times.retry do
43
+ raise StopIteration
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,4 +1,4 @@
1
1
  require 'test/unit'
2
2
 
3
3
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
- require 'rrrretry'
4
+ require 'rrrretry'
metadata CHANGED
@@ -1,55 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrrretry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
- - schneems
7
+ - Richard Schneeman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-22 00:00:00.000000000 Z
11
+ date: 2013-12-02 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
- - !ruby/object:Gem::Dependency
31
- name: jeweler
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 1.5.2
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: 1.5.2
46
- description: did i stutter?
47
- email: richard.schneeman@gmail.com
27
+ description: ' Retries code when an exception is raised an arbitrary number of times '
28
+ email:
29
+ - richard.schneeman+rubygems@gmail.com
48
30
  executables: []
49
31
  extensions: []
50
- extra_rdoc_files:
51
- - README.md
32
+ extra_rdoc_files: []
52
33
  files:
34
+ - .gitignore
53
35
  - Gemfile
54
36
  - Gemfile.lock
55
37
  - MIT-LICENSE
@@ -57,34 +39,34 @@ files:
57
39
  - Rakefile
58
40
  - VERSION
59
41
  - lib/rrrretry.rb
42
+ - rrrretry.gemspec
60
43
  - test/rrrretry_test.rb
61
44
  - test/test_helper.rb
62
- homepage: http://github.com/schneems/rrrretry
45
+ homepage: https://github.com/schneems/rrrretry
63
46
  licenses:
64
47
  - MIT
48
+ metadata: {}
65
49
  post_install_message:
66
50
  rdoc_options: []
67
51
  require_paths:
68
52
  - lib
69
53
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
54
  requirements:
72
- - - ! '>='
55
+ - - '>='
73
56
  - !ruby/object:Gem::Version
74
57
  version: '0'
75
- segments:
76
- - 0
77
- hash: 3391354679544867714
78
58
  required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
59
  requirements:
81
- - - ! '>='
60
+ - - '>='
82
61
  - !ruby/object:Gem::Version
83
62
  version: '0'
84
63
  requirements: []
85
64
  rubyforge_project:
86
- rubygems_version: 1.8.24
65
+ rubygems_version: 2.0.3
87
66
  signing_key:
88
- specification_version: 3
89
- summary: re-run your code
90
- test_files: []
67
+ specification_version: 4
68
+ summary: Did I stutter?
69
+ test_files:
70
+ - test/rrrretry_test.rb
71
+ - test/test_helper.rb
72
+ has_rdoc: