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 @@modules = [] @@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 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.modules @@modules end def self.views @@views end def self.title @@title end def self.current_working_folder @@root end def self.use_module(teamster_module) if @@modules.include? teamster_module puts "Module #{teamster_module} already registered!" else @@modules << teamster_module @@views << teamster_module.views end teamster_module.helpers GeneralHelper if teamster_module.has_helper? teamster_module.helper_module.flatten.each do |mod| helpers mod end end use teamster_module end end end end require_relative 'teamster/base_module'