retry 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.txt CHANGED
@@ -9,10 +9,10 @@ The Retry gem easily allows you to wrap a block of text in a "retry" so that it
9
9
 
10
10
  Usage is relatively simple:
11
11
 
12
- 10.tries('doing work') do
12
+ 10.tries do
13
13
  # unreliable code goes here...
14
14
  raise 'network connection failed' if rand() < 0.7
15
15
  puts 'success'
16
16
  end
17
17
 
18
-
18
+ For further options, see Fixnum#tries
data/Rakefile CHANGED
@@ -2,12 +2,15 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/clean'
4
4
  require 'rake/testtask'
5
+ require 'spec/rake/spectask'
5
6
  require 'rake/packagetask'
6
7
  require 'rake/gempackagetask'
7
8
  require 'rake/rdoctask'
8
9
  require 'rake/contrib/rubyforgepublisher'
9
10
  require 'fileutils'
10
11
  require 'hoe'
12
+
13
+
11
14
  include FileUtils
12
15
  require File.join(File.dirname(__FILE__), 'lib', 'retry', 'version')
13
16
 
@@ -91,3 +94,7 @@ task :check_version do
91
94
  end
92
95
  end
93
96
 
97
+ desc "Run All Specs"
98
+ Spec::Rake::SpecTask.new('spec') do |t|
99
+ t.spec_files = FileList['spec/**/*.rb']
100
+ end
data/lib/retry.rb CHANGED
@@ -2,7 +2,12 @@ require 'retry/version'
2
2
 
3
3
 
4
4
  class Fixnum
5
- def tries(message) # :yields:
5
+
6
+ =begin rdoc
7
+ - message => allows you to provide some context to the error messages that get printed out.
8
+ - output_stream => allows you to specify to which output stream you want any errors to be written. Defaults to $stderr
9
+ =end
10
+ def tries(message = nil, output_stream = $stderr) # :yields:
6
11
  current_try_num = 1
7
12
  begin
8
13
  yield current_try_num
@@ -10,7 +15,8 @@ class Fixnum
10
15
  if current_try_num >= self
11
16
  raise
12
17
  else
13
- puts "Try #{current_try_num} failed (#{message}): #{e}"
18
+ m = message ? " (#{message})" : ''
19
+ output_stream.puts "Try #{current_try_num} failed#{m}: #{e}"
14
20
  current_try_num = current_try_num.next
15
21
  retry
16
22
  end
data/lib/retry/version.rb CHANGED
@@ -2,7 +2,7 @@ module Retry #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/website/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
6
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
7
  <title>
8
- retry
8
+ Retry Gem
9
9
  </title>
10
10
  <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
11
  <style>
@@ -30,15 +30,15 @@
30
30
  <body>
31
31
  <div id="main">
32
32
 
33
- <h1>retry</h1>
33
+ <h1>Retry Gem</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/retry"; return false'>
35
35
  Get Version
36
- <a href="http://rubyforge.org/projects/retry" class="numbers">0.0.1</a>
36
+ <a href="http://rubyforge.org/projects/retry" class="numbers">0.0.2</a>
37
37
  </div>
38
- <h1>&#x2192; &#8216;retry&#8217;</h1>
38
+ <h2>What</h2>
39
39
 
40
40
 
41
- <h2>What</h2>
41
+ <p>Benjamin Franklin said, &#8220;The definition of insanity is doing the same thing over and over and expecting different results.&#8221; Sometimes, though, a retry is exactly what you need. You may need to call something that is not reliable. Maybe it is a network connection that might be down temporarily. How often have you built retry logic around a bit of code that just might fail on occasion? This ruby gem takes care of that situation nicely.</p>
42
42
 
43
43
 
44
44
  <h2>Installing</h2>
@@ -46,20 +46,29 @@
46
46
 
47
47
  <pre syntax="ruby">sudo gem install retry</pre>
48
48
 
49
- <h2>The basics</h2>
50
-
51
-
52
49
  <h2>Demonstration of usage</h2>
53
50
 
54
51
 
55
- <h2>Forum</h2>
52
+ <pre syntax="ruby">
53
+ require 'retry'
54
+
55
+ 10.tries do
56
+ raise 'network connection failed' if rand() &lt; 0.7
57
+ puts 'success'
58
+ end
59
+ </pre>
56
60
 
61
+ <p>Output:</p>
57
62
 
58
- <p><a href="http://groups.google.com/group/retry">http://groups.google.com/group/retry</a></p>
59
63
 
64
+ <pre syntax="ruby">
60
65
 
61
- <p><span class="caps">TODO</span> &#8211; create Google Group &#8211; retry</p>
66
+ &gt; ruby tries.rb
67
+ &gt; Try 1 failed: network connection failed
68
+ &gt; Try 2 failed: network connection failed
69
+ &gt; success
62
70
 
71
+ </pre>
63
72
 
64
73
  <h2>License</h2>
65
74
 
data/website/index.txt CHANGED
@@ -1,27 +1,35 @@
1
- h1. retry
2
-
3
- h1. &#x2192; 'retry'
1
+ h1. Retry Gem
4
2
 
5
3
 
6
4
  h2. What
7
5
 
6
+ Benjamin Franklin said, "The definition of insanity is doing the same thing over and over and expecting different results." Sometimes, though, a retry is exactly what you need. You may need to call something that is not reliable. Maybe it is a network connection that might be down temporarily. How often have you built retry logic around a bit of code that just might fail on occasion? This ruby gem takes care of that situation nicely.
8
7
 
9
8
  h2. Installing
10
9
 
11
10
  <pre syntax="ruby">sudo gem install retry</pre>
12
11
 
13
- h2. The basics
14
-
15
-
16
12
  h2. Demonstration of usage
17
13
 
14
+ <pre syntax="ruby">
15
+ require 'retry'
16
+
17
+ 10.tries do
18
+ raise 'network connection failed' if rand() < 0.7
19
+ puts 'success'
20
+ end
21
+ </pre>
18
22
 
23
+ Output:
19
24
 
20
- h2. Forum
25
+ <pre syntax="ruby">
21
26
 
22
- "http://groups.google.com/group/retry":http://groups.google.com/group/retry
27
+ > ruby tries.rb
28
+ > Try 1 failed: network connection failed
29
+ > Try 2 failed: network connection failed
30
+ > success
23
31
 
24
- TODO - create Google Group - retry
32
+ </pre>
25
33
 
26
34
  h2. License
27
35
 
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: retry
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
6
+ version: 0.0.2
7
7
  date: 2007-06-01 00:00:00 +01:00
8
8
  summary: easily retry blocks of code
9
9
  require_paths: