require 'sinatra/base' require 'yaml' require 'json' require 'uri' require_relative 'teamster/general_helper' require_relative 'teamster/core_helper' require_relative 'teamster/login' module Teamster module Core class App < Sinatra::Base @@adapters = [] @@views = [] @@title = 'TEAMSTER' @@root = Dir.pwd CORE_CONFIG = './conf/teamster.conf' # NOTE: Class methods used in configure block needs be declared # before the configure block. def self.set_default_options_from(core_opts) @@title = core_opts[:title] end configure do set :root, @@root set :referrer, nil @@views << "#{settings.root}/views" enable :sessions, :logging set :session_secret, 'THIS IS MY SESSION SECRET KEY' set :core_opts, YAML.load_file("#{settings.root}/#{CORE_CONFIG}") set_default_options_from settings.core_opts use Login end helpers GeneralHelper, CoreHelper get '/' do erb :index end def self.adapters @@adapters end def self.views @@views end def self.title @@title end def self.current_working_folder @@root end def self.use_adapter(teamster_adapter) if @@adapters.include? teamster_adapter warn "Adapter #{teamster_adapter} already registered!" else @@adapters << teamster_adapter @@views << teamster_adapter.views end teamster_adapter.helpers GeneralHelper if teamster_adapter.has_helper? teamster_adapter.helper_adapter.flatten.each do |mod| helpers mod end end use teamster_adapter end end end end require_relative 'teamster/base_adapter'