diff options
Diffstat (limited to 'lib/bundler/retry.rb')
-rw-r--r-- | lib/bundler/retry.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb index ea4d7577..585888f8 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) |