diff options
author | Pablo Carranza <pcarranza@gmail.com> | 2015-12-26 21:18:00 +0100 |
---|---|---|
committer | Pablo Carranza <pcarranza@gmail.com> | 2015-12-27 22:19:55 +0100 |
commit | 9d7060c57fee4d6c94eb9b389b3bd7558ad6cba0 (patch) | |
tree | a4acd88944be3af0f8361ea99e440b50fb231b9a | |
parent | 4647f8cb2d7e2decc088e213adaf7089eab0d2f4 (diff) | |
download | bundler-9d7060c57fee4d6c94eb9b389b3bd7558ad6cba0.tar.gz |
Add YARD documentation for new mirror classes.
-rw-r--r-- | lib/bundler/mirror.rb | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/bundler/mirror.rb b/lib/bundler/mirror.rb index 734dc09c4c..4a65f16a37 100644 --- a/lib/bundler/mirror.rb +++ b/lib/bundler/mirror.rb @@ -1,5 +1,9 @@ module Bundler class Settings + # Class used to build the mirror set and then find a mirror for a given URI + # + # @param prober [Prober object, nil] by default a TCPSocketProbe, this object + # will be used to probe the mirror address to validate that the mirror replies. class Mirrors def initialize(prober = nil) @all = Mirror.new @@ -7,6 +11,10 @@ module Bundler @mirrors = {} end + # Returns a mirror for the given uri. + # + # Depending on the uri having a valid mirror or not, it may be a + # mirror that points to the provided uri def for(uri) if @all.validate!(@prober).valid? @all @@ -40,6 +48,11 @@ module Bundler end end + # 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. class Mirror DEFAULT_FALLBACK_TIMEOUT = 0.1 @@ -91,6 +104,11 @@ module Bundler end end + # Class used to parse one configuration line + # + # Gets the configuration line and the value. + # This object provides a `update_mirror` method + # used to setup the given mirror value. class MirrorConfig attr_accessor :uri, :value @@ -120,6 +138,7 @@ module Bundler end end + # Class used for probing TCP availability for a given mirror. class TCPSocketProbe def replies?(mirror) MirrorSockets.new(mirror).any? do |socket, address, timeout| @@ -153,11 +172,17 @@ module Bundler end end + # Class used to build the list of sockets that correspond to + # a given mirror. + # + # One mirror may correspond to many different addresses, both + # because of it having many dns entries or just because + # the network interface is both ipv4 and ipv5 class MirrorSockets def initialize(mirror) @timeout = mirror.fallback_timeout @addresses = Socket.getaddrinfo(mirror.uri.host, mirror.uri.port).map do |address| - MirrorAddress.new(address[0], address[3], address[1]) + SocketAddress.new(address[0], address[3], address[1]) end end @@ -172,7 +197,11 @@ module Bundler end end - class MirrorAddress + # Socket address builder. + # + # Given a socket type, a host and a port, + # provides a method to build sockaddr string + class SocketAddress attr_reader :type, :host, :port def initialize(type, host, port) |