class RakeUp::Status

Attributes

host[R]
pid[R]
port[R]

Public Class Methods

new(pid, host, port) click to toggle source
# File lib/rakeup/status.rb, line 7
def initialize(pid, host, port)
  @pid = pid
  @host = host
  @port = port
  @process_check = Utilities::ProcessCheck.new(pid)
  @port_check = Utilities::PortCheck.new(host, port)
end

Public Instance Methods

check() click to toggle source
# File lib/rakeup/status.rb, line 15
def check
  @process_check.run if pid
  @port_check.run
end
host_and_port() click to toggle source
# File lib/rakeup/status.rb, line 32
def host_and_port
  "#{host}:#{port}"
end
listening?() click to toggle source
# File lib/rakeup/status.rb, line 24
def listening?
  @port_check.open?
end
running?() click to toggle source
# File lib/rakeup/status.rb, line 20
def running?
  pid && @process_check.running?
end
to_s() click to toggle source
# File lib/rakeup/status.rb, line 36
def to_s
  if up?
    "Found server listening on #{host_and_port} (pid #{pid})"
  else
    if pid
      [@process_check.to_s, @port_check.to_s].join("\n")
    else
      @port_check.to_s
    end
  end
end
up?() click to toggle source
# File lib/rakeup/status.rb, line 28
def up?
  running? && listening?
end