lib/teamster.rb in teamster-0.3.4 vs lib/teamster.rb in teamster-0.4.0

- old
+ new

@@ -1,68 +1,45 @@ require 'sinatra/base' require 'yaml' require 'json' require 'uri' -require_relative 'teamster/login' require_relative 'teamster/general_helper' -require_relative 'teamster/base_module' +require_relative 'teamster/core_helper' +require_relative 'teamster/login' module Teamster module Core class App < Sinatra::Base @@modules = [] @@views = [] @@title = 'TEAMSTER' - CORE_CONFIG = 'conf/teamster.conf' + @@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 - def self.current_working_folder - Dir.pwd - end - configure do - set :root, current_working_folder + 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(CORE_CONFIG) + set :core_opts, YAML.load_file("#{settings.root}/#{CORE_CONFIG}") set_default_options_from settings.core_opts use Login end - helpers GeneralHelper + helpers GeneralHelper, CoreHelper get '/' do erb :index end - def summary_div_class_for(index) - size = all_modules.size - if size == 1 - "col-lg-12" - elsif size%2 == 0 - "col-lg-6" - else - last = size - 1 - index == last ? "col-lg-12" : "col-lg-6" - end - end - - def summary_of(module_name) - name = module_name.downcase - if send(:"#{name}_summary?") - send(:"#{name}_summary") - else - erb :no_summary - end - end - def self.modules @@modules end def self.views @@ -71,10 +48,14 @@ 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 @@ -89,5 +70,7 @@ use teamster_module end end end end + +require_relative 'teamster/base_module'