class Madness::ServerBase
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.
Public Class Methods
config()
click to toggle source
# File lib/madness/server_base.rb, line 47 def self.config Settings.instance end
prepare()
click to toggle source
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!
# 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()
click to toggle source
# 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
set_tempalate_locations()
click to toggle source
# File lib/madness/server_base.rb, line 34 def self.set_tempalate_locations theme = Theme.new config.theme set :views, theme.views_path set :public_folder, theme.public_path end