Sha256: 80ffd093f021ef4758a87700fc7f779d60ef311dece2217723e8dddb1079876f

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

ENV['RACK_ENV'] ||= 'development'
####################################################################################
require 'fanforce/api'
require 'active_support/all'
require 'sinatra/base'
require 'fileutils'
require 'redis'

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

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

module FanforceApp

  def self.config(&block)
    config = @@config ||= FanforceApp::SinatraConfig.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'
    FanforceApp::Sinatra.new.call(env)
  end

  require_relative 'app_factory/config/sinatra_config'
  require_relative 'app_factory/initializers/ff_globals'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fanforce-app-factory-0.8.1 lib/fanforce/app_factory.rb