Class: Madness::ServerBase
- Inherits:
-
Sinatra::Application
- Object
- Sinatra::Application
- Madness::ServerBase
- Defined in:
- lib/madness/server_base.rb
Overview
The base class for the sinatra server. Initialize what we can here, but since there are values that will become known only later, the #prepare method is provided.
Direct Known Subclasses
Class Method Summary collapse
- .config ⇒ Object
-
.prepare ⇒ Object
Since we cannot use any config values in the main body of the class, since they will be updated later, we need to set anything that relys on the config values just before running the server.
- .set_basic_auth ⇒ Object
- .set_tempalate_locations ⇒ Object
Class Method Details
.config ⇒ Object
47 48 49 |
# File 'lib/madness/server_base.rb', line 47 def self.config Settings.instance end |
.prepare ⇒ Object
Since we cannot use any config values in the main body of the class, since they will be updated later, we need to set anything that relys on the config values just before running the server. The CommandLine class and the test suite should both call ‘Server.prepare` before calling Server.run!
25 26 27 28 29 30 31 32 |
# File 'lib/madness/server_base.rb', line 25 def self.prepare use Madness::Static, root: "#{config.path}/", urls: %w[/], cascade: true set :bind, config.bind set :port, config.port set_basic_auth if config.auth set_tempalate_locations end |
.set_basic_auth ⇒ Object
41 42 43 44 45 |
# File 'lib/madness/server_base.rb', line 41 def self.set_basic_auth use Rack::Auth::Basic, config.auth_realm do |username, password| config.auth.split(':') == [username, password] end end |