Module: FSR::App

Included in:
Listener::Outbound
Defined in:
lib/fsr/app/read.rb,
lib/fsr/app.rb,
lib/fsr/app/log.rb,
lib/fsr/app/say.rb,
lib/fsr/app/set.rb,
lib/fsr/app/fifo.rb,
lib/fsr/app/limit.rb,
lib/fsr/app/speak.rb,
lib/fsr/app/answer.rb,
lib/fsr/app/bridge.rb,
lib/fsr/app/hangup.rb,
lib/fsr/app/fs_break.rb,
lib/fsr/app/fs_sleep.rb,
lib/fsr/app/playback.rb,
lib/fsr/app/transfer.rb,
lib/fsr/file_methods.rb,
lib/fsr/app/uuid_dump.rb,
lib/fsr/app/callcenter.rb,
lib/fsr/app/conference.rb,
lib/fsr/app/pre_answer.rb,
lib/fsr/app/ring_ready.rb,
lib/fsr/app/valet_park.rb,
lib/fsr/app/execute_app.rb,
lib/fsr/app/uuid_getvar.rb,
lib/fsr/app/uuid_setvar.rb,
lib/fsr/app/bind_meta_app.rb,
lib/fsr/app/play_and_get_digits.rb

Overview

Defined Under Namespace

Modules: FileMethods Classes: Answer, Application, BindMetaApp, Bridge, Callcenter, Conference, ExecuteApp, FSBreak, FSSleep, Fifo, Hangup, Limit, Log, PlayAndGetDigits, Playback, PreAnswer, Read, RingReady, Say, Set, Speak, Transfer, UuidDump, UuidGetVar, UuidSetVar, ValetPark

Constant Summary collapse

APPLICATIONS =
{}
LOAD_PATH =
[FSR::ROOT.join("fsr/app")]
REGISTER_CODE =
"def %s(*args, &block); APPLICATIONS[%p].new(*args, &block); end"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.listObject



31
32
33
# File 'lib/fsr/app.rb', line 31

def self.list
  APPLICATIONS.keys
end

.load_all(force_reload = false) ⇒ Object

Load all of the applications we find in App::LOAD_PATH



55
56
57
58
59
60
61
62
63
# File 'lib/fsr/app.rb', line 55

def self.load_all(force_reload = false)
  glob = "{#{LOAD_PATH.join(',')}}/*.{so,rb,bundle}"

  Dir[glob].each do |file|
    force_reload ? load(file) : require(file)
  end

  list
end

.load_application(application, force_reload = false) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fsr/app.rb', line 35

def self.load_application(application, force_reload = false)
  exception = nil

  if Pathname(application).absolute?
    glob = application
  else
    glob = "{#{LOAD_PATH.join(',')}}/#{application}.{so,rb,bundle}"
  end

  Dir[glob].each do |file|
    begin
      return force_reload ? load(file) : require(file)
    rescue LoadError => exception
    end
  end

  raise("Couldn't find %s in %p" % [application, LOAD_PATH])
end

.register(application, obj) ⇒ Object



26
27
28
29
# File 'lib/fsr/app.rb', line 26

def self.register(application, obj)
  APPLICATIONS[application.to_sym] = obj
  App.module_eval(REGISTER_CODE % [application, application])
end

Instance Method Details

#applicationsObject



65
66
67
# File 'lib/fsr/app.rb', line 65

def applications
  FSR::App.list
end