Class: RakeUp::Status
- Inherits:
-
Object
- Object
- RakeUp::Status
- Defined in:
- lib/rakeup/status.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #check ⇒ Object
- #host_and_port ⇒ Object
-
#initialize(pid, host, port) ⇒ Status
constructor
A new instance of Status.
- #listening? ⇒ Boolean
- #running? ⇒ Boolean
- #to_s ⇒ Object
- #up? ⇒ Boolean
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
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/rakeup/status.rb', line 5 def host @host end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
5 6 7 |
# File 'lib/rakeup/status.rb', line 5 def pid @pid end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/rakeup/status.rb', line 5 def port @port end |
Instance Method Details
#check ⇒ Object
15 16 17 18 |
# File 'lib/rakeup/status.rb', line 15 def check @process_check.run if pid @port_check.run end |
#host_and_port ⇒ Object
32 33 34 |
# File 'lib/rakeup/status.rb', line 32 def host_and_port "#{host}:#{port}" end |
#listening? ⇒ Boolean
24 25 26 |
# File 'lib/rakeup/status.rb', line 24 def listening? @port_check.open? end |
#running? ⇒ Boolean
20 21 22 |
# File 'lib/rakeup/status.rb', line 20 def running? pid && @process_check.running? end |
#to_s ⇒ Object
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
28 29 30 |
# File 'lib/rakeup/status.rb', line 28 def up? running? && listening? end |