Sha256: f8c0e4ef41418ee7319c81ac9e3dd6487630f998bc2ca49239d729b535dc5cff

Contents?: true

Size: 1.65 KB

Versions: 12

Compression:

Stored size: 1.65 KB

Contents

ENV['RACK_ENV'] ||= 'development'
####################################################################################

require 'fanforce/api'
require 'fanforce/workers'
require 'active_support/all'
require 'sinatra/base'
require 'fileutils'
require 'redis'
require_relative 'plugin_factory/version'

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

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

module FanforcePlugin

  def self.enqueue(queue_name, payload)
    Fanforce::Workers.enqueue "#{config._id}-#{queue_name}", payload
  end

  def self.config(&block)
    config = @@config ||= FanforcePlugin::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.type
    config.type
  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(FanforcePlugin.config.root_dir)
      return sprockets.index.call(env)
    end
    require_relative 'plugin_factory/_init_sinatra'
    FanforcePlugin::Sinatra.new.call(env)
  end

  require_relative 'plugin_factory/config/core_config'
  require_relative 'plugin_factory/initializers/ff_globals'
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fanforce-plugin-factory-0.16.1 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.16.0 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.15.1 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.14.1 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.14.0 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.13.5 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.13.4 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.13.3 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.13.2 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.13.1 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.13.0 lib/fanforce/plugin_factory.rb
fanforce-plugin-factory-0.12.1 lib/fanforce/plugin_factory.rb