summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Metcalfe <git@patrickmetcalfe.com>2015-04-22 20:21:46 -0500
committerPatrick Metcalfe <git@patrickmetcalfe.com>2015-04-22 20:21:46 -0500
commitd81498ccca48dd7492c7948b8b2902a16c87e7cd (patch)
tree5214c323a4ce0634ee48a098269aa47a013c6e10
parentcd36aa6bfbf8e1fc4425b4099186812459c62a27 (diff)
downloadbundler-d81498ccca48dd7492c7948b8b2902a16c87e7cd.tar.gz
focuses retry on what its good at
-rw-r--r--lib/bundler/retry.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb
index ea4d7577d9..585888f8e1 100644
--- a/lib/bundler/retry.rb
+++ b/lib/bundler/retry.rb
@@ -1,23 +1,24 @@
module Bundler
# General purpose class for retrying code that may fail
class Retry
- DEFAULT_ATTEMPTS = 2
attr_accessor :name, :total_runs, :current_run
class << self
- attr_accessor :attempts
+ def default_attempts
+ default_retries + 1
+ end
+ alias_method :attempts, :default_attempts
+
+ def default_retries
+ Bundler.settings[:retry]
+ end
end
- def initialize(name, exceptions = nil, attempts = nil)
+ def initialize(name, exceptions = nil, retries = self.class.default_retries)
@name = name
- attempts ||= default_attempts
+ @retries = retries
@exceptions = Array(exceptions) || []
- @total_runs = attempts.next # will run once, then upto attempts.times
- end
-
- def default_attempts
- return Integer(self.class.attempts) if self.class.attempts
- DEFAULT_ATTEMPTS
+ @total_runs = @retries + 1 # will run once, then upto attempts.times
end
def attempt(&block)