Class: Bundler::Settings::Mirror
- Inherits:
-
Object
- Object
- Bundler::Settings::Mirror
- Defined in:
- lib/bundler/mirror.rb
Overview
A mirror
Contains both the uri that should be used as a mirror and the
fallback timeout which will be used for probing if the mirror
replies on time or not.
Constant Summary collapse
- DEFAULT_FALLBACK_TIMEOUT =
0.1
Instance Attribute Summary collapse
-
#fallback_timeout ⇒ Object
Returns the value of attribute fallback_timeout.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(uri = nil, fallback_timeout = 0) ⇒ Mirror
constructor
A new instance of Mirror.
- #valid? ⇒ Boolean
- #validate!(probe = nil) ⇒ Object
Constructor Details
#initialize(uri = nil, fallback_timeout = 0) ⇒ Mirror
Returns a new instance of Mirror.
67 68 69 70 71 |
# File 'lib/bundler/mirror.rb', line 67 def initialize(uri = nil, fallback_timeout = 0) self.uri = uri self.fallback_timeout = fallback_timeout @valid = nil end |
Instance Attribute Details
#fallback_timeout ⇒ Object
Returns the value of attribute fallback_timeout.
65 66 67 |
# File 'lib/bundler/mirror.rb', line 65 def fallback_timeout @fallback_timeout end |
#uri ⇒ Object
Returns the value of attribute uri.
65 66 67 |
# File 'lib/bundler/mirror.rb', line 65 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
94 95 96 |
# File 'lib/bundler/mirror.rb', line 94 def ==(other) !other.nil? && uri == other.uri && fallback_timeout == other.fallback_timeout end |
#valid? ⇒ Boolean
98 99 100 101 102 |
# File 'lib/bundler/mirror.rb', line 98 def valid? return false if @uri.nil? return @valid unless @valid.nil? false end |
#validate!(probe = nil) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/bundler/mirror.rb', line 104 def validate!(probe = nil) @valid = false if uri.nil? if @valid.nil? @valid = fallback_timeout == 0 || (probe || TCPSocketProbe.new).replies?(self) end self end |