Class: RubyHome::HAP::ServerHandler
- Inherits:
-
Object
- Object
- RubyHome::HAP::ServerHandler
- Defined in:
- lib/ruby_home/hap/server_handler.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #bind_address ⇒ Object
-
#initialize(configuration:) ⇒ ServerHandler
constructor
A new instance of ServerHandler.
- #port ⇒ Object
- #run ⇒ Object
- #server ⇒ Object
- #server_logger ⇒ Object
- #server_options ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(configuration:) ⇒ ServerHandler
Returns a new instance of ServerHandler.
13 14 15 |
# File 'lib/ruby_home/hap/server_handler.rb', line 13 def initialize(configuration: ) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
60 61 62 |
# File 'lib/ruby_home/hap/server_handler.rb', line 60 def configuration @configuration end |
Instance Method Details
#bind_address ⇒ Object
52 53 54 |
# File 'lib/ruby_home/hap/server_handler.rb', line 52 def bind_address configuration.host end |
#port ⇒ Object
56 57 58 |
# File 'lib/ruby_home/hap/server_handler.rb', line 56 def port configuration.port end |
#run ⇒ Object
17 18 19 |
# File 'lib/ruby_home/hap/server_handler.rb', line 17 def run server.start end |
#server ⇒ Object
25 26 27 28 29 30 |
# File 'lib/ruby_home/hap/server_handler.rb', line 25 def server @server ||= RackHandler.run( HTTP::Application.rack_builder, ) end |
#server_logger ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby_home/hap/server_handler.rb', line 42 def server_logger if ENV['DEBUG'] == 'debug' WEBrick::Log::new(STDOUT, WEBrick::BasicLog::DEBUG) elsif ENV['DEBUG'] == 'info' WEBrick::Log::new(STDOUT, WEBrick::BasicLog::INFO) else WEBrick::Log::new("/dev/null", WEBrick::BasicLog::WARN) end end |
#server_options ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby_home/hap/server_handler.rb', line 32 def { Port: port, Host: bind_address, ServerSoftware: 'RubyHome', Logger: server_logger, AccessLog: [] } end |
#shutdown ⇒ Object
21 22 23 |
# File 'lib/ruby_home/hap/server_handler.rb', line 21 def shutdown server.shutdown end |