adhearsion 1.2.6 → 2.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -10
- data/CHANGELOG.md +273 -0
- data/Gemfile +1 -1
- data/Guardfile +17 -0
- data/README.markdown +61 -9
- data/Rakefile +16 -48
- data/adhearsion.gemspec +21 -7
- data/bin/ahn +3 -1
- data/cucumber.yml +4 -0
- data/features/app_generator.feature +42 -0
- data/features/cli.feature +108 -0
- data/features/step_definitions/app_generator_steps.rb +6 -0
- data/features/step_definitions/cli_steps.rb +74 -0
- data/features/support/aruba_helper.rb +22 -0
- data/features/support/env.rb +37 -0
- data/features/support/utils.rb +8 -0
- data/lib/adhearsion.rb +85 -41
- data/lib/adhearsion/call.rb +176 -0
- data/lib/adhearsion/call_controller.rb +134 -0
- data/lib/adhearsion/call_controller/dial.rb +70 -0
- data/lib/adhearsion/call_controller/input.rb +173 -0
- data/lib/adhearsion/call_controller/menu.rb +124 -0
- data/lib/adhearsion/call_controller/output.rb +267 -0
- data/lib/adhearsion/call_controller/record.rb +42 -0
- data/lib/adhearsion/call_controller/utility.rb +60 -0
- data/lib/adhearsion/calls.rb +81 -0
- data/lib/adhearsion/cli.rb +1 -3
- data/lib/adhearsion/cli_commands.rb +142 -0
- data/lib/adhearsion/configuration.rb +149 -0
- data/lib/adhearsion/console.rb +19 -8
- data/lib/adhearsion/dialplan_controller.rb +9 -0
- data/lib/adhearsion/events.rb +84 -0
- data/lib/adhearsion/foundation/all.rb +0 -7
- data/lib/adhearsion/foundation/custom_daemonizer.rb +4 -6
- data/lib/adhearsion/foundation/exception_handler.rb +9 -0
- data/lib/adhearsion/foundation/object.rb +26 -8
- data/lib/adhearsion/foundation/synchronized_hash.rb +3 -6
- data/lib/adhearsion/foundation/thread_safety.rb +17 -1
- data/lib/adhearsion/generators/app/app_generator.rb +4 -13
- data/lib/adhearsion/generators/app/templates/Gemfile +10 -5
- data/lib/adhearsion/generators/app/templates/Procfile +1 -0
- data/lib/adhearsion/generators/app/templates/README.md +28 -0
- data/lib/adhearsion/generators/app/templates/config/adhearsion.rb +41 -0
- data/lib/adhearsion/generators/app/templates/{components/simon_game → lib}/simon_game.rb +6 -18
- data/lib/adhearsion/generators/app/templates/script/ahn +2 -2
- data/lib/adhearsion/initializer.rb +151 -293
- data/lib/adhearsion/initializer/logging.rb +33 -0
- data/lib/adhearsion/logging.rb +65 -69
- data/lib/adhearsion/menu_dsl.rb +15 -0
- data/lib/adhearsion/menu_dsl/calculated_match.rb +39 -0
- data/lib/adhearsion/menu_dsl/calculated_match_collection.rb +41 -0
- data/lib/adhearsion/menu_dsl/fixnum_match_calculator.rb +18 -0
- data/lib/adhearsion/menu_dsl/match_calculator.rb +36 -0
- data/lib/adhearsion/{voip/menu_state_machine/menu_class.rb → menu_dsl/menu.rb} +38 -40
- data/lib/adhearsion/menu_dsl/menu_builder.rb +69 -0
- data/lib/adhearsion/menu_dsl/range_match_calculator.rb +55 -0
- data/lib/adhearsion/menu_dsl/string_match_calculator.rb +21 -0
- data/lib/adhearsion/outbound_call.rb +64 -0
- data/lib/adhearsion/plugin.rb +319 -0
- data/lib/adhearsion/plugin/collection.rb +19 -0
- data/lib/adhearsion/plugin/initializer.rb +37 -0
- data/lib/adhearsion/plugin/methods_container.rb +6 -0
- data/lib/adhearsion/process.rb +94 -0
- data/lib/adhearsion/punchblock_plugin.rb +29 -0
- data/lib/adhearsion/punchblock_plugin/initializer.rb +137 -0
- data/lib/adhearsion/router.rb +30 -0
- data/lib/adhearsion/router/route.rb +42 -0
- data/lib/adhearsion/script_ahn_loader.rb +2 -2
- data/lib/adhearsion/tasks.rb +14 -9
- data/lib/adhearsion/tasks/configuration.rb +26 -0
- data/lib/adhearsion/tasks/plugins.rb +17 -0
- data/lib/adhearsion/version.rb +8 -14
- data/spec/adhearsion/call_controller/dial_spec.rb +138 -0
- data/spec/adhearsion/call_controller/input_spec.rb +278 -0
- data/spec/adhearsion/call_controller/menu_spec.rb +120 -0
- data/spec/adhearsion/call_controller/output_spec.rb +466 -0
- data/spec/adhearsion/call_controller/record_spec.rb +125 -0
- data/spec/adhearsion/call_controller_spec.rb +395 -0
- data/spec/adhearsion/call_spec.rb +438 -0
- data/spec/adhearsion/calls_spec.rb +47 -0
- data/spec/adhearsion/configuration_spec.rb +308 -0
- data/spec/adhearsion/dialplan_controller_spec.rb +26 -0
- data/spec/adhearsion/events_spec.rb +112 -0
- data/spec/adhearsion/initializer/logging_spec.rb +58 -0
- data/spec/adhearsion/initializer_spec.rb +209 -122
- data/spec/adhearsion/logging_spec.rb +58 -47
- data/spec/adhearsion/menu_dsl/calculated_match_collection_spec.rb +56 -0
- data/spec/adhearsion/menu_dsl/calculated_match_spec.rb +57 -0
- data/spec/adhearsion/menu_dsl/fixnum_match_calculator_spec.rb +33 -0
- data/spec/adhearsion/menu_dsl/match_calculator_spec.rb +13 -0
- data/spec/adhearsion/menu_dsl/menu_builder_spec.rb +118 -0
- data/spec/adhearsion/menu_dsl/menu_spec.rb +210 -0
- data/spec/adhearsion/menu_dsl/range_match_calculator_spec.rb +28 -0
- data/spec/adhearsion/menu_dsl/string_match_calculator_spec.rb +36 -0
- data/spec/adhearsion/menu_dsl_spec.rb +12 -0
- data/spec/adhearsion/outbound_call_spec.rb +174 -0
- data/spec/adhearsion/plugin_spec.rb +489 -0
- data/spec/adhearsion/process_spec.rb +34 -0
- data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +294 -0
- data/spec/adhearsion/router/route_spec.rb +99 -0
- data/spec/adhearsion/router_spec.rb +106 -0
- data/spec/adhearsion_spec.rb +46 -0
- data/spec/spec_helper.rb +14 -14
- data/spec/support/call_controller_test_helpers.rb +48 -0
- data/spec/support/initializer_stubs.rb +8 -13
- data/spec/support/punchblock_mocks.rb +6 -0
- metadata +255 -253
- data/CHANGELOG +0 -174
- data/bin/ahnctl +0 -68
- data/bin/jahn +0 -43
- data/examples/asterisk_manager_interface/standalone.rb +0 -51
- data/lib/adhearsion/commands.rb +0 -302
- data/lib/adhearsion/component_manager.rb +0 -278
- data/lib/adhearsion/component_manager/component_tester.rb +0 -54
- data/lib/adhearsion/component_manager/spec_framework.rb +0 -18
- data/lib/adhearsion/events_support.rb +0 -65
- data/lib/adhearsion/foundation/blank_slate.rb +0 -3
- data/lib/adhearsion/foundation/event_socket.rb +0 -205
- data/lib/adhearsion/foundation/future_resource.rb +0 -36
- data/lib/adhearsion/foundation/metaprogramming.rb +0 -17
- data/lib/adhearsion/foundation/numeric.rb +0 -13
- data/lib/adhearsion/foundation/pseudo_guid.rb +0 -10
- data/lib/adhearsion/foundation/relationship_properties.rb +0 -42
- data/lib/adhearsion/foundation/string.rb +0 -26
- data/lib/adhearsion/generators/app/templates/.ahnrc +0 -34
- data/lib/adhearsion/generators/app/templates/README +0 -8
- data/lib/adhearsion/generators/app/templates/components/ami_remote/ami_remote.rb +0 -15
- data/lib/adhearsion/generators/app/templates/components/disabled/HOW_TO_ENABLE +0 -7
- data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/README.markdown +0 -47
- data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/stomp_gateway.rb +0 -34
- data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/stomp_gateway.yml +0 -12
- data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/README.markdown +0 -3
- data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/xmpp_gateway.rb +0 -11
- data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/xmpp_gateway.yml +0 -0
- data/lib/adhearsion/generators/app/templates/config/startup.rb +0 -81
- data/lib/adhearsion/generators/app/templates/dialplan.rb +0 -3
- data/lib/adhearsion/generators/app/templates/events.rb +0 -33
- data/lib/adhearsion/host_definitions.rb +0 -67
- data/lib/adhearsion/initializer/asterisk.rb +0 -86
- data/lib/adhearsion/initializer/configuration.rb +0 -324
- data/lib/adhearsion/initializer/database.rb +0 -60
- data/lib/adhearsion/initializer/drb.rb +0 -31
- data/lib/adhearsion/initializer/freeswitch.rb +0 -22
- data/lib/adhearsion/initializer/ldap.rb +0 -57
- data/lib/adhearsion/initializer/rails.rb +0 -41
- data/lib/adhearsion/initializer/xmpp.rb +0 -42
- data/lib/adhearsion/tasks/components.rb +0 -32
- data/lib/adhearsion/tasks/database.rb +0 -5
- data/lib/adhearsion/tasks/deprecations.rb +0 -59
- data/lib/adhearsion/tasks/generating.rb +0 -20
- data/lib/adhearsion/tasks/lint.rb +0 -4
- data/lib/adhearsion/voip/asterisk.rb +0 -4
- data/lib/adhearsion/voip/asterisk/agi_server.rb +0 -121
- data/lib/adhearsion/voip/asterisk/commands.rb +0 -1966
- data/lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb +0 -140
- data/lib/adhearsion/voip/asterisk/config_generators/config_generator.rb +0 -102
- data/lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb +0 -250
- data/lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb +0 -240
- data/lib/adhearsion/voip/asterisk/config_manager.rb +0 -64
- data/lib/adhearsion/voip/asterisk/manager_interface.rb +0 -697
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb +0 -1681
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb +0 -341
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb +0 -78
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_protocol_lexer_machine.rl +0 -87
- data/lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb +0 -80
- data/lib/adhearsion/voip/call.rb +0 -521
- data/lib/adhearsion/voip/call_routing.rb +0 -64
- data/lib/adhearsion/voip/commands.rb +0 -17
- data/lib/adhearsion/voip/constants.rb +0 -39
- data/lib/adhearsion/voip/conveniences.rb +0 -18
- data/lib/adhearsion/voip/dial_plan.rb +0 -252
- data/lib/adhearsion/voip/dsl/dialing_dsl.rb +0 -151
- data/lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb +0 -37
- data/lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb +0 -27
- data/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb +0 -124
- data/lib/adhearsion/voip/dsl/dialplan/parser.rb +0 -69
- data/lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb +0 -16
- data/lib/adhearsion/voip/dsl/numerical_string.rb +0 -128
- data/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb +0 -48
- data/lib/adhearsion/voip/freeswitch/event_handler.rb +0 -58
- data/lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb +0 -129
- data/lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb +0 -38
- data/lib/adhearsion/voip/freeswitch/oes_server.rb +0 -195
- data/lib/adhearsion/voip/menu_state_machine/calculated_match.rb +0 -80
- data/lib/adhearsion/voip/menu_state_machine/matchers.rb +0 -123
- data/lib/adhearsion/voip/menu_state_machine/menu_builder.rb +0 -57
- data/lib/adhearsion/xmpp/connection.rb +0 -61
- data/lib/theatre.rb +0 -147
- data/lib/theatre/README.markdown +0 -64
- data/lib/theatre/callback_definition_loader.rb +0 -86
- data/lib/theatre/guid.rb +0 -23
- data/lib/theatre/invocation.rb +0 -131
- data/lib/theatre/namespace_manager.rb +0 -153
- data/lib/theatre/version.rb +0 -2
- data/spec/adhearsion/cli_spec.rb +0 -306
- data/spec/adhearsion/component_manager_spec.rb +0 -292
- data/spec/adhearsion/constants_spec.rb +0 -8
- data/spec/adhearsion/drb_spec.rb +0 -65
- data/spec/adhearsion/fixtures/dialplan.rb +0 -3
- data/spec/adhearsion/foundation/event_socket_spec.rb +0 -168
- data/spec/adhearsion/host_definitions_spec.rb +0 -79
- data/spec/adhearsion/initializer/configuration_spec.rb +0 -291
- data/spec/adhearsion/initializer/loading_spec.rb +0 -154
- data/spec/adhearsion/initializer/paths_spec.rb +0 -74
- data/spec/adhearsion/relationship_properties_spec.rb +0 -54
- data/spec/adhearsion/voip/asterisk/agi_server_spec.rb +0 -473
- data/spec/adhearsion/voip/asterisk/ami/ami_spec.rb +0 -550
- data/spec/adhearsion/voip/asterisk/ami/lexer/ami_fixtures.yml +0 -30
- data/spec/adhearsion/voip/asterisk/ami/lexer/lexer_story +0 -291
- data/spec/adhearsion/voip/asterisk/ami/lexer/lexer_story.rb +0 -241
- data/spec/adhearsion/voip/asterisk/ami/lexer/story_helper.rb +0 -124
- data/spec/adhearsion/voip/asterisk/commands_spec.rb +0 -3241
- data/spec/adhearsion/voip/asterisk/config_file_generators/agents_spec.rb +0 -251
- data/spec/adhearsion/voip/asterisk/config_file_generators/queues_spec.rb +0 -323
- data/spec/adhearsion/voip/asterisk/config_file_generators/voicemail_spec.rb +0 -306
- data/spec/adhearsion/voip/asterisk/config_manager_spec.rb +0 -127
- data/spec/adhearsion/voip/asterisk/menu_command/calculated_match_spec.rb +0 -109
- data/spec/adhearsion/voip/asterisk/menu_command/matchers_spec.rb +0 -97
- data/spec/adhearsion/voip/call_routing_spec.rb +0 -125
- data/spec/adhearsion/voip/dialplan_manager_spec.rb +0 -468
- data/spec/adhearsion/voip/dsl/dialing_dsl_spec.rb +0 -270
- data/spec/adhearsion/voip/dsl/dispatcher_spec.rb +0 -82
- data/spec/adhearsion/voip/dsl/dispatcher_spec_helper.rb +0 -45
- data/spec/adhearsion/voip/dsl/parser_spec.rb +0 -69
- data/spec/adhearsion/voip/freeswitch/basic_connection_manager_spec.rb +0 -39
- data/spec/adhearsion/voip/freeswitch/inbound_connection_manager_spec.rb +0 -39
- data/spec/adhearsion/voip/freeswitch/oes_server_spec.rb +0 -9
- data/spec/adhearsion/voip/numerical_string_spec.rb +0 -61
- data/spec/adhearsion/voip/phone_number_spec.rb +0 -45
- data/spec/support/the_following_code.rb +0 -3
- data/spec/theatre/dsl_examples/simple_before_call.rb +0 -7
- data/spec/theatre/dsl_spec.rb +0 -69
- data/spec/theatre/invocation_spec.rb +0 -182
- data/spec/theatre/namespace_spec.rb +0 -125
- data/spec/theatre/spec_helper_spec.rb +0 -28
- data/spec/theatre/theatre_class_spec.rb +0 -148
@@ -1,36 +0,0 @@
|
|
1
|
-
require "thread"
|
2
|
-
|
3
|
-
class FutureResource
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@resource_lock = Monitor.new
|
7
|
-
@resource_value_blocker = @resource_lock.new_cond
|
8
|
-
end
|
9
|
-
|
10
|
-
def set_yet?
|
11
|
-
@resource_lock.synchronize { defined? @resource }
|
12
|
-
end
|
13
|
-
|
14
|
-
def resource
|
15
|
-
@resource_lock.synchronize do
|
16
|
-
@resource_value_blocker.wait unless defined? @resource
|
17
|
-
@resource
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def resource=(resource)
|
22
|
-
@resource_lock.synchronize do
|
23
|
-
raise ResourceAlreadySetException if defined? @resource
|
24
|
-
@resource = resource
|
25
|
-
@resource_value_blocker.broadcast
|
26
|
-
@resource_value_blocker = nil # Don't really need it anymore.
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class ResourceAlreadySetException < StandardError
|
31
|
-
def initialize
|
32
|
-
super "Cannot set this resource twice!"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class Numeric
|
2
|
-
|
3
|
-
def digit()
|
4
|
-
ahn_log.deprecation 'Please do not use Fixnum#digit() and Fixnum#digits() in the future! These will be deprecated soon'
|
5
|
-
self
|
6
|
-
end
|
7
|
-
|
8
|
-
def digits()
|
9
|
-
ahn_log.deprecation 'Please do not use Fixnum#digit() and Fixnum#digits() in the future! These will be deprecated soon'
|
10
|
-
self
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module PseudoGuidGenerator
|
2
|
-
##
|
3
|
-
# Generates a new 128-bit Globally Unique Identifier. It is a "pseudo" in that it does not adhere to the RFC which mandates
|
4
|
-
# that a certain section be reserved for a fragment of the NIC MAC address.
|
5
|
-
def new_guid(separator="-")
|
6
|
-
[8,4,4,4,12].map { |segment_length| String.random(segment_length) }.join(separator)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
include PseudoGuidGenerator
|
@@ -1,42 +0,0 @@
|
|
1
|
-
class Module
|
2
|
-
|
3
|
-
##
|
4
|
-
# In OOP, relationships between classes should be treated as *properties* of those classes. Often, in a complex OO
|
5
|
-
# architecture, you'll end up with many relationships that intermingle in monolithic ways, blunting the effectiveness of
|
6
|
-
# subclassing.
|
7
|
-
#
|
8
|
-
# For example, say you have an Automobile class which, in its constructor, instantiates a new Battery class and performs
|
9
|
-
# some operations on it such as calling an install() method. Let's also assume the Automobile class exposes a repair()
|
10
|
-
# method which uses a class-level method of Battery to diagnose your own instance of Battery. If the result of the
|
11
|
-
# diagnosis shows that the Battery is bad, the Automobile will instantiate a new Battery object and replace the old battery
|
12
|
-
# with the new one.
|
13
|
-
#
|
14
|
-
# Now, what if you wish to create a new Automobile derived from existing technology: a HybridAutomobile subclass. For this
|
15
|
-
# particular HybridAutomobile class, let's simply say the only difference between it and its parent is which kind of
|
16
|
-
# Battery it uses -- it requires its own special subclass of Battery. With Automobile's current implementation, its
|
17
|
-
# references to which Battery it instantiates and uses are embedded in the immutable method defintions. This
|
18
|
-
# HybridAutomobile needs to override which Battery its superclass' methods use and nothing else.
|
19
|
-
#
|
20
|
-
# For this reason, the Battery class which Automobile uses is semantically a property which others may want to override.
|
21
|
-
# In OOP theory, we define overridable properties in the form of methods and override those methods in the subclasses.
|
22
|
-
#
|
23
|
-
# This method exposes one method which creates human-readable semantics to defining these relationships as properties. It's
|
24
|
-
# used as follows:
|
25
|
-
#
|
26
|
-
# class Automobile
|
27
|
-
# relationship :battery => Battery
|
28
|
-
# relationship :chassis => Chassis
|
29
|
-
# # Other properties and instance methods here....
|
30
|
-
# end
|
31
|
-
#
|
32
|
-
# class HybridAutomobile < Automobile
|
33
|
-
# relationship :battery => HybridBattery
|
34
|
-
# end
|
35
|
-
#
|
36
|
-
def relationships(relationship_mapping)
|
37
|
-
relationship_mapping.each_pair do |class_name, class_object|
|
38
|
-
define_method(class_name) { class_object }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
|
3
|
-
def unindent
|
4
|
-
gsub(/^\s*/,'')
|
5
|
-
end
|
6
|
-
|
7
|
-
def unindent!
|
8
|
-
gsub!(/^\s*/,'')
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.random_char
|
12
|
-
case random_digit = rand(62)
|
13
|
-
when 0...10 then random_digit.to_s
|
14
|
-
when 10...36 then (random_digit + 55).chr
|
15
|
-
when 36...62 then (random_digit + 61).chr
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.random(length_of_string=8)
|
20
|
-
Array.new(length_of_string) { random_char }.join
|
21
|
-
end
|
22
|
-
|
23
|
-
def nameify() downcase.gsub(/[^\w]/, '') end
|
24
|
-
def nameify!() replace nameify end
|
25
|
-
|
26
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# Adhearsion Runtime Configuration.
|
2
|
-
|
3
|
-
# You can use the "gems" section to force Adhearsion to load a particular version of a gem.
|
4
|
-
# This is useful when a component require()s a gem, but you don't want it to use the latest one installed on the system.
|
5
|
-
# For example, if a component require()s activerecord, sucking in the latest on the system, and then you enable a Rails app
|
6
|
-
# which wants a particular version of activerecord, RubyGems will raise an error saying "you cannot activate two versions of
|
7
|
-
# the same gem". Note: specifying the version, source and require names is optional, but you must include a : after the gem name to make it a YAML key/value pair (with a nil value).
|
8
|
-
gems:
|
9
|
-
# twitter:
|
10
|
-
# hpricot:
|
11
|
-
# rack:
|
12
|
-
# # require() one library when initializing:
|
13
|
-
# require: rack
|
14
|
-
# memcache-client:
|
15
|
-
# version >= 1.5.2
|
16
|
-
# require:
|
17
|
-
# # require() an Array of libraries when initializing:
|
18
|
-
# - memcache
|
19
|
-
# - memcache_util
|
20
|
-
# activerecord:
|
21
|
-
# version: >= 2.1.0
|
22
|
-
# aasm:
|
23
|
-
# source: http://gems.github.com
|
24
|
-
|
25
|
-
paths:
|
26
|
-
|
27
|
-
# All paths are relative to this file's directory
|
28
|
-
init: config/startup.rb
|
29
|
-
|
30
|
-
dialplan: dialplan.rb
|
31
|
-
|
32
|
-
events: events.rb
|
33
|
-
|
34
|
-
models: models/*.rb
|
@@ -1,8 +0,0 @@
|
|
1
|
-
Start your new app with "ahn start /path/to/your/app"
|
2
|
-
|
3
|
-
If you wish to use Adhearsion to control Asterisk's dialplan,
|
4
|
-
change the contexts you wish to be affected in your
|
5
|
-
/etc/asterisk/extensions.conf file to the following:
|
6
|
-
|
7
|
-
[your_context_name]
|
8
|
-
exten => _X.,1,AGI(agi://1.2.3.4) ; This IP here
|
@@ -1,15 +0,0 @@
|
|
1
|
-
methods_for :rpc do
|
2
|
-
|
3
|
-
# Simply create proxy methods for the high-level AMI methods
|
4
|
-
|
5
|
-
[:send_action, :introduce, :originate, :call_into_context, :call_and_exec, :ping].each do |method_name|
|
6
|
-
define_method(method_name) do |*args|
|
7
|
-
if VoIP::Asterisk.manager_interface
|
8
|
-
VoIP::Asterisk.manager_interface.send(method_name, *args)
|
9
|
-
else
|
10
|
-
ahn_log.ami_remote.error "AMI has not been enabled in startup.rb!"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/README.markdown
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
What is Stomp?
|
2
|
-
==============
|
3
|
-
|
4
|
-
Stomp is a very simple message-queue protocol with which two separate systems can communicate. Because the protocol is so simple, there are many Stomp server implementations from which you can choose. Some of these include
|
5
|
-
|
6
|
-
- ActiveMQ (http://activemq.com)
|
7
|
-
- Ruby "stompserver" gem (gem install stompserver)
|
8
|
-
- RabbitMQ (http://rabbitmq.com)
|
9
|
-
|
10
|
-
If you wish to get up and running with a development environment, the Ruby stompserver gem is a fantastic starting point. For a critical production system, ActiveMQ should probably be used but it bears the cumbersome paradigm of many "enterprisey" Java applications.
|
11
|
-
|
12
|
-
How does it work?
|
13
|
-
=================
|
14
|
-
|
15
|
-
Stomp is used when certain processes have defined responsibilities. For example, your Adhearsion application's responsibility is to communicate with your Asterisk machine. Other processes (e.g. a Rails web application) will probably need to instruct Adhearsion to do something. Instructions may include
|
16
|
-
|
17
|
-
- Start a new call between two given phone numbers
|
18
|
-
- Have a particular call do something based on a new event
|
19
|
-
- Hangup a call
|
20
|
-
|
21
|
-
Below is a diagram which should give you a better idea of how it works.
|
22
|
-
|
23
|
-
Process Process Process (e.g. Rails)
|
24
|
-
\ | /
|
25
|
-
\ | /
|
26
|
-
Stomp Server (e.g. ActiveMQ)
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Process (e.g. Adhearsion)
|
30
|
-
|
31
|
-
Note: Adhearsion could also be the sender of messages through the Stomp server which are consumed by a number of handlers.
|
32
|
-
|
33
|
-
Setting up a Ruby Stomp server
|
34
|
-
==============================
|
35
|
-
|
36
|
-
Install the pure-Ruby Stomp server by doing "gem install stompserver". This will add the "stompserver" command to your system. When running it without any parameters, it starts without requiring authentication. If you're wanting to get a quick experiment running, I recommend simply doing that.
|
37
|
-
|
38
|
-
Open the `stomp_gateway.yml` file in the stomp_gateway component folder. Comment out the four settings at the top of the file named "user", "pass", "host" and "port" by prepending a "#" to their line. This will cause the component to choose defaults for those properties. The component's defaults will match the expected credentials for the experimental stompserver you're already running on your computer.
|
39
|
-
|
40
|
-
You also need specify a subscription name in
|
41
|
-
|
42
|
-
events.stomp.start_call.each do |event|
|
43
|
-
# The "event" variable holds a Stomp::Message object.
|
44
|
-
name = event.headers
|
45
|
-
end
|
46
|
-
|
47
|
-
You a
|
data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/stomp_gateway.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'stomp'
|
2
|
-
|
3
|
-
# TODO: Recover from a disconnect!
|
4
|
-
|
5
|
-
initialization do
|
6
|
-
user = COMPONENTS.stomp_gateway[:user] || ""
|
7
|
-
pass = COMPONENTS.stomp_gateway[:pass] || ""
|
8
|
-
host = COMPONENTS.stomp_gateway[:host] || "localhost"
|
9
|
-
port = COMPONENTS.stomp_gateway[:port] || 61613
|
10
|
-
|
11
|
-
::StompGatewayConnection = Stomp::Client.open(user, pass, host, port)
|
12
|
-
|
13
|
-
subscriptions = COMPONENTS.stomp_gateway["subscriptions"]
|
14
|
-
|
15
|
-
ahn_log.stomp_gateway "Connection established. Subscriptions: #{subscriptions.inspect}"
|
16
|
-
|
17
|
-
Events.register_namespace_name "/stomp"
|
18
|
-
|
19
|
-
subscriptions.each do |subscription|
|
20
|
-
Events.register_namespace_name "/stomp/#{subscription}"
|
21
|
-
::StompGatewayConnection.subscribe subscription do |event|
|
22
|
-
Adhearsion::Events.trigger ["stomp", subscription], event
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
methods_for :global do
|
29
|
-
def send_stomp(destination, message, headers={})
|
30
|
-
::StompGatewayConnection.send(destination, message, headers)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# In the future, I may add a methods_for(:events) method which allows synchronous messaging.
|
data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/stomp_gateway.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# Comment out any of these properties to use a default.
|
2
|
-
|
3
|
-
user: stomp_user
|
4
|
-
pass: secret_password
|
5
|
-
host: localhost
|
6
|
-
port: 61613
|
7
|
-
|
8
|
-
### Add your list of subscriptions below that this gateway should proxy to events.rb
|
9
|
-
|
10
|
-
# subscriptions:
|
11
|
-
# - start_call
|
12
|
-
# - hungup_call
|
data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/xmpp_gateway.yml
DELETED
File without changes
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'environment')
|
2
|
-
|
3
|
-
Adhearsion::Configuration.configure do |config|
|
4
|
-
|
5
|
-
# Components to load from the system.
|
6
|
-
# All components that are activated in components/ will be automatically
|
7
|
-
# loaded and made available.
|
8
|
-
# This configuration option allows you to load components provided by gems.
|
9
|
-
# List the gem names here:
|
10
|
-
# config.add_component "ahn_test_component"
|
11
|
-
|
12
|
-
# Log configuration
|
13
|
-
# :level : Supported levels (in increasing severity) -- :debug < :info < :warn < :error < :fatal
|
14
|
-
# :outputters : An array of log outputters to use. The default is to log to stdout and log/adhearsion.log
|
15
|
-
# :formatters : An array of log formatters to apply to the outputters in use
|
16
|
-
# :formatter : A log formatter to apply to all active outputters
|
17
|
-
config.logging :level => :info
|
18
|
-
|
19
|
-
# Whether incoming calls be automatically answered. Defaults to true.
|
20
|
-
# config.automatically_answer_incoming_calls = false
|
21
|
-
|
22
|
-
# Whether the other end hanging up should end the call immediately. Defaults to true.
|
23
|
-
# config.end_call_on_hangup = false
|
24
|
-
|
25
|
-
# Whether to end the call immediately if an unrescued exception is caught. Defaults to true.
|
26
|
-
# config.end_call_on_error = false
|
27
|
-
|
28
|
-
# NOTE: Pay special attention to the argument_delimiter field below:
|
29
|
-
# For Asterisk <= 1.4, use "|" (default)
|
30
|
-
# For Asterisk >= 1.6, use ","
|
31
|
-
# The delimiter can also be specified in Asterisk's asterisk.conf.
|
32
|
-
# This setting applies only to AGI. The AMI delimiter is auto-detected.
|
33
|
-
# NB: The AMI user should have write access in order to execute actions, and AMI connections will fail otherwise.
|
34
|
-
config.enable_asterisk :argument_delimiter => '|'
|
35
|
-
# config.asterisk.enable_ami :host => "127.0.0.1", :username => "admin", :password => "password", :events => true
|
36
|
-
|
37
|
-
# Adhearsion supports two possible speech engines with Asterisk: UniMRCP and Cepstral.
|
38
|
-
# Uncomment one of the below if you have it available.
|
39
|
-
# config.asterisk.speech_engine = :cepstral
|
40
|
-
# config.asterisk.speech_engine = :unimrcp
|
41
|
-
|
42
|
-
# config.enable_drb
|
43
|
-
|
44
|
-
# Streamlined Rails integration! The first argument should be a relative or absolute path to
|
45
|
-
# the Rails app folder with which you're integrating. The second argument must be one of the
|
46
|
-
# the following: :development, :production, or :test.
|
47
|
-
|
48
|
-
# config.enable_rails :path => 'gui', :env => :development
|
49
|
-
|
50
|
-
# Note: You CANNOT do enable_rails and enable_database at the same time. When you enable Rails,
|
51
|
-
# it will automatically connect to same database Rails does and load the Rails app's models.
|
52
|
-
|
53
|
-
# Configure a database to use ActiveRecord-backed models. See ActiveRecord::Base.establish_connection
|
54
|
-
# for the appropriate settings here.
|
55
|
-
# You can also override the default log destination by supplying an alternate
|
56
|
-
# logging object with :logger. The default is ahn_log.db.
|
57
|
-
# config.enable_database :adapter => 'mysql',
|
58
|
-
# :username => 'joe',
|
59
|
-
# :password => 'secret',
|
60
|
-
# :host => 'db.example.org'
|
61
|
-
|
62
|
-
# Configure an LDAP connection using ActiveLdap. See ActiveLdap::Base.establish_connect
|
63
|
-
# for the appropriate settings here.
|
64
|
-
# config.enable_ldap :host => 'ldap.dataspill.org',
|
65
|
-
# :port => 389,
|
66
|
-
# :base => 'dc=dataspill,dc=org',
|
67
|
-
# :logger => ahn_log.ldap,
|
68
|
-
# :bind_dn => "uid=drewry,ou=People,dc=dataspill,dc=org",
|
69
|
-
# :password => 'password12345',
|
70
|
-
# :allow_anonymous => false,
|
71
|
-
# :try_sasl => false
|
72
|
-
|
73
|
-
# Configure XMPP call controller
|
74
|
-
# config.enable_xmpp :jid => 'active-calls.xmpp.example.com',
|
75
|
-
# :password => 'passwd',
|
76
|
-
# :server => 'xmpp.example.com',
|
77
|
-
# :port => 5347
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
Adhearsion::Initializer.start_from_init_file(__FILE__, File.dirname(__FILE__) + "/..")
|
@@ -1,33 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# In this file you can define callbacks for different aspects of the framework. Below is an example:
|
3
|
-
##
|
4
|
-
#
|
5
|
-
# events.asterisk.before_call.each do |call|
|
6
|
-
# # This simply logs the extension for all calls going through this Adhearsion app.
|
7
|
-
# extension = call.variables[:extension]
|
8
|
-
# ahn_log "Got a new call with extension #{extension}"
|
9
|
-
# end
|
10
|
-
#
|
11
|
-
##
|
12
|
-
# Asterisk Manager Interface example:
|
13
|
-
#
|
14
|
-
# events.asterisk.manager_interface.each do |event|
|
15
|
-
# ahn_log.events event.inspect
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# This assumes you gave :events => true to the config.asterisk.enable_ami method in config/startup.rb
|
19
|
-
#
|
20
|
-
##
|
21
|
-
# Here is a list of the events included by default:
|
22
|
-
#
|
23
|
-
# - events.exception
|
24
|
-
# - events.asterisk.manager_interface
|
25
|
-
# - events.after_initialized
|
26
|
-
# - events.shutdown
|
27
|
-
# - events.asterisk.before_call
|
28
|
-
# - events.asterisk.failed_call
|
29
|
-
# - events.asterisk.hungup_call
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# Note: events are mostly for components to register and expose to you.
|
33
|
-
##
|