Sha256: c5cf15c0f9933e2f8da8263de764cf958feffb3071cac9ffa3d945c016723288
Contents?: true
Size: 1.82 KB
Versions: 6
Compression:
Stored size: 1.82 KB
Contents
class FanforceApp::SinatraConfig attr_accessor :layout_for_index, :layout_for_dashboard attr_accessor :_id, :redis_url, :factory_root_dir, :root_dir, :dir_name, :show_error_details attr_reader :type def initialize(root_dir) @layout_for_index = true @layout_for_dashboard = true @_id = ENV['FANFORCE_APP_ID'] @root_dir = root_dir @factory_root_dir = File.expand_path '../../', __FILE__ @redis_url = ENV['REDIS_URL'] || 'redis://localhost:6379' @show_error_details = false end def show_error_details=(bool) @show_error_details = [true,1,'1'].include?(bool) end def load raise 'CRITICAL: This FanforceApp requires config._id to be set. See documentation.' if !@_id raise 'CRITICAL: This FanforceApp requires config.root_dir to be set. See documentation' if !@root_dir FanforceApp::Sinatra.set :root, @root_dir FanforceApp::Sinatra.set :public_folder, [@root_dir+'/public', @factory_root_dir+'/public'].inject(''){|dir, d| File.directory?(d) ? (break d) : d } FanforceApp::Sinatra.set :views, [@root_dir+'/views', @factory_root_dir+'/views'].inject(''){|dir, d| File.directory?(d) ? (break d) : d } FanforceApp.config.load_routes FanforceApp.config.load_redis end def load_routes @dir_name = /\/([^\/]+)\/?$/.match(@root_dir)[1] $: << File.join(@root_dir,'lib') if File.directory?("#{@root_dir}/lib") require "#{@root_dir}/config/initializer" if File.exists?("#{@root_dir}/config/initializer.rb") require "#{@root_dir}/config/routes" if File.exists?("#{@root_dir}/config/routes.rb") require "#{@root_dir}/initializer" if File.exists?("#{@root_dir}/initializer.rb") require "#{@root_dir}/routes" if File.exists?("#{@root_dir}/routes.rb") require "#{@factory_root_dir}/routes" end def load_redis $Redis = ::Redis.new(url: @redis_url) end end
Version data entries
6 entries across 6 versions & 1 rubygems