Module: FanforcePlugin

Defined in:
lib/fanforce/plugin_factory.rb

Defined Under Namespace

Classes: CoreConfig, Sinatra

Class Method Summary collapse

Class Method Details

._idObject



42
43
44
# File 'lib/fanforce/plugin_factory.rb', line 42

def self._id
  config._id
end

.call(env) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fanforce/plugin_factory.rb', line 54

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'
  request = Rack::Request.new(env)
  Rack::JSONR.intercept_method_override(env, request, request.params, :all)
  FanforcePlugin::Sinatra.new.call(env)
end

.config(&block) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/fanforce/plugin_factory.rb', line 25

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

.dir_nameObject



38
39
40
# File 'lib/fanforce/plugin_factory.rb', line 38

def self.dir_name
  config.dir_name
end

.enqueue(queue_name, payload) ⇒ Object



21
22
23
# File 'lib/fanforce/plugin_factory.rb', line 21

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

.load_configObject



50
51
52
# File 'lib/fanforce/plugin_factory.rb', line 50

def self.load_config
  config.load
end

.rootObject



34
35
36
# File 'lib/fanforce/plugin_factory.rb', line 34

def self.root
  config.root_dir
end

.typeObject



46
47
48
# File 'lib/fanforce/plugin_factory.rb', line 46

def self.type
  config.type
end