Class: Guard::Yard::Server
- Inherits:
-
Object
- Object
- Guard::Yard::Server
- Defined in:
- lib/guard/yard/server.rb
Instance Attribute Summary collapse
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #kill ⇒ Object
- #spawn ⇒ Object
- #verify ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
8 9 10 11 12 13 |
# File 'lib/guard/yard/server.rb', line 8 def initialize( = {}) @port = [:port] || '8808' @stdout = [:stdout] @stderr = [:stderr] @cli = [:cli] end |
Instance Attribute Details
#pid ⇒ Object
Returns the value of attribute pid.
6 7 8 |
# File 'lib/guard/yard/server.rb', line 6 def pid @pid end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/guard/yard/server.rb', line 6 def port @port end |
Instance Method Details
#kill ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/guard/yard/server.rb', line 26 def kill UI.info "[Guard::Yard] Stopping YARD Documentation Server." begin if pid Process.kill('QUIT', pid) Process.wait2(pid) end rescue Errno::ESRCH, Errno::ECHILD # Process is already dead. end true end |
#spawn ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/guard/yard/server.rb', line 15 def spawn UI.info "[Guard::Yard] Starting YARD Documentation Server." command = ["yard server -p #{port}"] command << @cli if @cli command << "2> #{@stderr}" if @stderr command << "1> #{@stdout}" if @stdout self.pid = Process.spawn(command.join(' ')) end |
#verify ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/guard/yard/server.rb', line 39 def verify 5.times do sleep 1 begin TCPSocket.new('localhost', port.to_i).close rescue Errno::ECONNREFUSED next end UI.info "[Guard::Yard] Server successfully started." return true end UI.error "[Guard::Yard] Error starting documentation server." Notifier.notify "[Guard::Yard] Server NOT started.", :title => 'yard', :image => :failed false end |