class RakeUp::Utilities::PortCheck
Attributes
error[R]
host[R]
port[R]
Public Class Methods
new(host, port)
click to toggle source
# File lib/rakeup/utilities/port_check.rb, line 9 def initialize(host, port) @host = host @port = port end
Public Instance Methods
closed?()
click to toggle source
# File lib/rakeup/utilities/port_check.rb, line 18 def closed? @status == false end
open?()
click to toggle source
# File lib/rakeup/utilities/port_check.rb, line 14 def open? @status == true end
run()
click to toggle source
# File lib/rakeup/utilities/port_check.rb, line 22 def run @status = run_check end
to_s()
click to toggle source
# File lib/rakeup/utilities/port_check.rb, line 26 def to_s if open? "Found process listening on #{host}:#{port}" else "Unable to connect to process on #{host}:#{port}: #{error}" end end
Private Instance Methods
run_check()
click to toggle source
# File lib/rakeup/utilities/port_check.rb, line 35 def run_check begin Timeout::timeout(1) do begin s = TCPSocket.new(host, port) s.close return true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH => error @error = error return false end end rescue Timeout::Error => error @error = error return false end end