1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Move timeout up to Fog from Fog::Mock.

This commit is contained in:
Christopher Meiklejohn 2011-07-11 18:06:47 -04:00
parent 74c4689691
commit 49d8a92a63
5 changed files with 16 additions and 12 deletions

View file

@ -31,4 +31,5 @@ require 'fog/core/service'
require 'fog/core/ssh'
require 'fog/core/scp'
require 'fog/core/time'
require 'fog/core/timeout'
require 'fog/core/wait_for'

View file

@ -21,16 +21,6 @@ module Fog
@delay
end
@timeout = 600
def self.timeout
@timeout
end
def self.timeout=(new_timeout)
raise ArgumentError, "timeout must be non-negative" unless new_timeout >= 0
@timeout = new_timeout
end
def self.delay=(new_delay)
raise ArgumentError, "delay must be non-negative" unless new_delay >= 0
@delay = new_delay

View file

@ -42,7 +42,7 @@ module Fog
attributes.to_json
end
def wait_for(timeout=Fog::Mock.timeout, interval=1, &block)
def wait_for(timeout=Fog.timeout, interval=1, &block)
reload
retries = 3
Fog.wait_for(timeout, interval) do

13
lib/fog/core/timeout.rb Normal file
View file

@ -0,0 +1,13 @@
module Fog
@timeout = 600
def self.timeout
@timeout
end
def self.timeout=(new_timeout)
raise ArgumentError, "timeout must be non-negative" unless new_timeout >= 0
@timeout = new_timeout
end
end

View file

@ -1,6 +1,6 @@
module Fog
def self.wait_for(timeout=Fog::Mock.timeout, interval=1, &block)
def self.wait_for(timeout=Fog.timeout, interval=1, &block)
duration = 0
start = Time.now
until yield || duration > timeout