Class: RakeUp::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/rakeup/status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid, host, port) ⇒ Status

Returns a new instance of Status.



7
8
9
10
11
12
13
# 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

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/rakeup/status.rb', line 5

def host
  @host
end

#pidObject (readonly)

Returns the value of attribute pid.



5
6
7
# File 'lib/rakeup/status.rb', line 5

def pid
  @pid
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/rakeup/status.rb', line 5

def port
  @port
end

Instance Method Details

#checkObject



15
16
17
18
# File 'lib/rakeup/status.rb', line 15

def check
  @process_check.run if pid
  @port_check.run
end

#host_and_portObject



32
33
34
# File 'lib/rakeup/status.rb', line 32

def host_and_port
  "#{host}:#{port}"
end

#listening?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/rakeup/status.rb', line 24

def listening?
  @port_check.open?
end

#running?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rakeup/status.rb', line 20

def running?
  pid && @process_check.running?
end

#to_sObject



36
37
38
39
40
41
42
43
44
45
46
# 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?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rakeup/status.rb', line 28

def up?
  running? && listening?
end