Module: Adhearsion

Defined in:
lib/adhearsion/foundation/custom_daemonizer.rb,
lib/adhearsion.rb,
lib/adhearsion/call.rb,
lib/adhearsion/calls.rb,
lib/adhearsion/events.rb,
lib/adhearsion/plugin.rb,
lib/adhearsion/router.rb,
lib/adhearsion/console.rb,
lib/adhearsion/logging.rb,
lib/adhearsion/process.rb,
lib/adhearsion/version.rb,
lib/adhearsion/generators.rb,
lib/adhearsion/statistics.rb,
lib/adhearsion/initializer.rb,
lib/adhearsion/cli_commands.rb,
lib/adhearsion/router/route.rb,
lib/adhearsion/configuration.rb,
lib/adhearsion/outbound_call.rb,
lib/adhearsion/call_controller.rb,
lib/adhearsion/linux_proc_name.rb,
lib/adhearsion/plugin/collection.rb,
lib/adhearsion/punchblock_plugin.rb,
lib/adhearsion/script_ahn_loader.rb,
lib/adhearsion/plugin/initializer.rb,
lib/adhearsion/call_controller/dial.rb,
lib/adhearsion/generators/generator.rb,
lib/adhearsion/router/evented_route.rb,
lib/adhearsion/call_controller/input.rb,
lib/adhearsion/call_controller/output.rb,
lib/adhearsion/call_controller/record.rb,
lib/adhearsion/router/openended_route.rb,
lib/adhearsion/call_controller/utility.rb,
lib/adhearsion/call_controller/menu_dsl.rb,
lib/adhearsion/cli_commands/ahn_command.rb,
lib/adhearsion/cli_commands/thor_errors.rb,
lib/adhearsion/router/unaccepting_route.rb,
lib/adhearsion/cli_commands/plugin_command.rb,
lib/adhearsion/generators/app/app_generator.rb,
lib/adhearsion/call_controller/menu_dsl/menu.rb,
lib/adhearsion/call_controller/output/player.rb,
lib/adhearsion/punchblock_plugin/initializer.rb,
lib/adhearsion/call_controller/output/formatter.rb,
lib/adhearsion/generators/plugin/plugin_generator.rb,
lib/adhearsion/call_controller/output/async_player.rb,
lib/adhearsion/call_controller/menu_dsl/menu_builder.rb,
lib/adhearsion/call_controller/output/abstract_player.rb,
lib/adhearsion/call_controller/menu_dsl/calculated_match.rb,
lib/adhearsion/call_controller/menu_dsl/match_calculator.rb,
lib/adhearsion/generators/controller/controller_generator.rb,
lib/adhearsion/call_controller/menu_dsl/array_match_calculator.rb,
lib/adhearsion/call_controller/menu_dsl/range_match_calculator.rb,
lib/adhearsion/call_controller/menu_dsl/fixnum_match_calculator.rb,
lib/adhearsion/call_controller/menu_dsl/string_match_calculator.rb,
lib/adhearsion/call_controller/menu_dsl/calculated_match_collection.rb

Overview

This is largely based on the Daemonize library by Travis Whitton and Judson Lester. grub.ath.cx/daemonize. I cleaned it up a bit to meet Adhearsion's quality standards.

Defined Under Namespace

Modules: CLI, CustomDaemonizer, Generators, LinuxProcName, Logging, Safely, ScriptAhnLoader Classes: Call, CallController, Calls, Configuration, Console, Events, Initializer, OutboundCall, Plugin, Process, PunchblockPlugin, Router, Statistics

Constant Summary collapse

Error =
Class.new StandardError
VERSION =
'2.6.4'

Class Method Summary collapse

Class Method Details

.active_callsObject



82
83
84
# File 'lib/adhearsion.rb', line 82

def active_calls
  @active_calls ||= Calls.new
end

.ahn_root=(path) ⇒ Object

Deprecated.

Use #root= instead



35
36
37
38
# File 'lib/adhearsion.rb', line 35

def ahn_root=(path)
  Adhearsion.deprecated "#Adhearsion.root="
  Adhearsion.root = path
end

.config(&block) ⇒ Object



40
41
42
43
44
# File 'lib/adhearsion.rb', line 40

def config(&block)
  @config ||= initialize_config
  block_given? and yield @config
  @config
end

.config=(config) ⇒ Object



70
71
72
# File 'lib/adhearsion.rb', line 70

def config=(config)
  @config = config
end

.deprecated(new_method) ⇒ Object



46
47
48
49
# File 'lib/adhearsion.rb', line 46

def deprecated(new_method)
  logger.info "#{caller[0]} - This method is deprecated, please use #{new_method}."
  logger.warn caller.join("\n")
end

.environmentObject



62
63
64
# File 'lib/adhearsion.rb', line 62

def environment
  ENV['AHN_ENV'] || ENV['RAILS_ENV'] || :development
end

.environmentsObject



66
67
68
# File 'lib/adhearsion.rb', line 66

def environments
  config.valid_environments
end

.initialize_configObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/adhearsion.rb', line 51

def initialize_config
  _config = Configuration.new
  env = environment.to_sym if environment.respond_to? :to_sym
  unless _config.valid_environment? env
    puts  "You tried to initialize with an invalid environment name #{env}; environment-specific config may not load successfully. Valid values are #{_config.valid_environments}."
    env = nil
  end
  _config.platform.environment = env if env
  _config
end

.rootPathname

Returns the current application path

Returns:

  • (Pathname)

    The application path



28
29
30
# File 'lib/adhearsion.rb', line 28

def root
  Adhearsion.config[:platform].root
end

.root=(path) ⇒ Object

Sets the application path @param The application path to set



20
21
22
# File 'lib/adhearsion.rb', line 20

def root=(path)
  Adhearsion.config[:platform].root = path.nil? ? nil : File.expand_path(path)
end

.router(&block) ⇒ Object



74
75
76
# File 'lib/adhearsion.rb', line 74

def router(&block)
  @router ||= Router.new(&block || Proc.new {})
end

.router=(other) ⇒ Object



78
79
80
# File 'lib/adhearsion.rb', line 78

def router=(other)
  @router = other
end

.statisticsAdhearsion::Statistics

Returns a statistics aggregator object capable of producing stats dumps

Returns:



88
89
90
91
92
93
94
# File 'lib/adhearsion.rb', line 88

def statistics
  unless Celluloid::Actor[:statistics]
    Statistics.supervise_as :statistics
    Statistics.setup_event_handlers
  end
  Celluloid::Actor[:statistics]
end

.statusObject



96
97
98
# File 'lib/adhearsion.rb', line 96

def status
  Adhearsion::Process.state_name
end