Sha256: 32c962418b42200bae4aa11641cd5832b2f87b7e35ec9f1eb469e01f5302ea65
Contents?: true
Size: 1.63 KB
Versions: 6
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' require_relative 'core_config' class Fanforce::App @@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
6 entries across 6 versions & 1 rubygems