Sha256: d665568747442d57cb07fffd7b3443ecd3bfb062760cafa0fb4c4590a691aafb

Contents?: true

Size: 1.55 KB

Versions: 16

Compression:

Stored size: 1.55 KB

Contents

ENV['RACK_ENV'] ||= 'development'
####################################################################################
require 'rack/jsonr'
require 'fanforce/api'
require 'fanforce/worker'
require 'active_support/all'
require 'sinatra/base'
require 'fileutils'
require 'redis'
require_relative 'app_factory/version'

if ENV['RACK_ENV'] == 'development'
  require_relative 'app_factory/sprockets/hacks'
  require_relative 'app_factory/sprockets/compiler'
end

ROOT_DIR ||= (caller[0].split(':')[0] =~ /^(.+(config\.ru|Rakefile))$/) ? File.dirname($1) : $BaseDir

module FanforceApp

  def self.config(&block)
    config = @@config ||= FanforceApp::CoreConfig.new(ROOT_DIR)
    if block.present?
      block.call(config)
      config.root_dir = File.dirname($1) if !config.root_dir and caller[0].split(':')[0] =~ /^(.+(config\.ru|Rakefile))$/
    end
    config
  end

  def self.root
    config.root_dir
  end

  def self.dir_name
    config.dir_name
  end

  def self._id
    config._id
  end

  def self.load_config
    config.load
  end

  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(FanforceApp.config.root_dir)
      return sprockets.index.call(env)
    end
    require_relative 'app_factory/_init_sinatra'
    request = Rack::Request.new(env)
    Rack::JSONR.intercept_method_override(env, request, request.params, :all)
    FanforceApp::Sinatra.new.call(env)
  end

  require_relative 'app_factory/config/core_config'
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fanforce-app-factory-1.7.1 lib/fanforce/app_factory.rb
fanforce-app-factory-1.7.0 lib/fanforce/app_factory.rb
fanforce-app-factory-1.6.3 lib/fanforce/app_factory.rb
fanforce-app-factory-1.6.2 lib/fanforce/app_factory.rb
fanforce-app-factory-1.6.1 lib/fanforce/app_factory.rb
fanforce-app-factory-1.6.0 lib/fanforce/app_factory.rb
fanforce-app-factory-1.5.0 lib/fanforce/app_factory.rb
fanforce-app-factory-1.4.4 lib/fanforce/app_factory.rb
fanforce-app-factory-1.4.3 lib/fanforce/app_factory.rb
fanforce-app-factory-1.4.2 lib/fanforce/app_factory.rb
fanforce-app-factory-1.4.1 lib/fanforce/app_factory.rb
fanforce-app-factory-1.4.0 lib/fanforce/app_factory.rb
fanforce-app-factory-1.3.0 lib/fanforce/app_factory.rb
fanforce-app-factory-1.2.0 lib/fanforce/app_factory.rb
fanforce-app-factory-1.1.0 lib/fanforce/app_factory.rb
fanforce-app-factory-1.0.0 lib/fanforce/app_factory.rb