Sha256: c7eabf7effc9f102cb5c6369191a90cbc1d9b280aff6709c6d08941c9a24b28a
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
module Capistrano class ServerDefinition include Comparable attr_reader :host attr_reader :user attr_reader :port attr_reader :options def initialize(string, options={}) @user, @host, @port = string.match(/^(?:([^;,:=]+)@|)(.*?)(?::(\d+)|)$/)[1,3] @options = options.dup user_opt, port_opt = @options.delete(:user), @options.delete(:port) @user ||= user_opt @port ||= port_opt @port = @port.to_i if @port end def <=>(server) [host, port, user] <=> [server.host, server.port, server.user] end # Redefined, so that Array#uniq will work to remove duplicate server # definitions, based solely on their host names. def eql?(server) host == server.host && user == server.user && port == server.port end alias :== :eql? # Redefined, so that Array#uniq will work to remove duplicate server # definitions, based on their connection information. def hash @hash ||= [host, user, port].hash end def to_s @to_s ||= begin s = host s = "#{user}@#{s}" if user s = "#{s}:#{port}" if port && port != 22 s end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
capistrano-2.1.0 | lib/capistrano/server_definition.rb |
capistrano-2.0.0 | lib/capistrano/server_definition.rb |
capistrano-2.2.0 | lib/capistrano/server_definition.rb |