Sha256: a9d57695acff0df5c9494010a7c669a7e3e89ce20d852eeab375b9469894e954
Contents?: true
Size: 1.63 KB
Versions: 4
Compression:
Stored size: 1.63 KB
Contents
require 'redis' require 'fileutils' require 'rack/jsonr' require 'sinatra/base' require 'active_support/all' require 'fanforce/api' require 'fanforce/app_worker' class Fanforce::App require_relative 'core_config' @@loaded = nil @@config = nil # Only one instance is allowed to initialize, and the resulting instance is stored in Fanforce::App. # @param base_dir [String] base dir of app # @param loader_filename [String] either config.ru or Rakefile # @return [Fanforce::App] def self.load(base_dir) @@loaded ? (raise 'Only one instance of Fanforce::AppFactory can be loaded per process') : @@loaded = true @@config = CoreConfig.new(base_dir) return self end def self.app_id @@config._id end def self._id; app_id; end def self.config(&block) block ? block.call(@@config) : @@config end def self.base_dir @@config.base_dir end def self.is_bugsnag_enabled? @@config.is_bugsnag_enabled end def self.redis @@redis ||= ::Redis.new(url: @@config.redis_url) end ###################################################################################################################### # Method for use in config.ru files (i.e., run Fanforce::App) def self.call(env) if ENV['RACK_ENV'] == 'development' and env['PATH_INFO'] =~ /^\/assets\// env['PATH_INFO'] = env['PATH_INFO'].gsub(/^\/assets/, '') sprockets = SprocketsCompiler.setup(base_dir) return sprockets.index.call(env) end require_relative 'sinatra/_load' request = Rack::Request.new(env) Rack::JSONR.intercept_method_override(env, request, request.params, :all) Sinatra.new.call(env) end end
Version data entries
4 entries across 4 versions & 1 rubygems