Class: Teaspoon::Server
- Inherits:
-
Object
- Object
- Teaspoon::Server
- Defined in:
- lib/teaspoon/server.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize ⇒ Server
constructor
A new instance of Server.
- #responsive? ⇒ Boolean
- #start ⇒ Object
- #url ⇒ Object
Constructor Details
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/teaspoon/server.rb', line 7 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/teaspoon/server.rb', line 7 def port @port end |
Instance Method Details
#responsive? ⇒ Boolean
27 28 29 30 31 32 |
# File 'lib/teaspoon/server.rb', line 27 def responsive? TCPSocket.new(host, port).close true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH false end |
#start ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/teaspoon/server.rb', line 14 def start return if responsive? thread = Thread.new do disable_logging server = Rack::Server.new() server.start end wait_until_started(thread) rescue => e raise Teaspoon::ServerError.new(desc: e.) end |
#url ⇒ Object
34 35 36 |
# File 'lib/teaspoon/server.rb', line 34 def url "http://#{host}:#{port}" end |