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.
Files changed (236) hide show
  1. data/.gitignore +17 -10
  2. data/CHANGELOG.md +273 -0
  3. data/Gemfile +1 -1
  4. data/Guardfile +17 -0
  5. data/README.markdown +61 -9
  6. data/Rakefile +16 -48
  7. data/adhearsion.gemspec +21 -7
  8. data/bin/ahn +3 -1
  9. data/cucumber.yml +4 -0
  10. data/features/app_generator.feature +42 -0
  11. data/features/cli.feature +108 -0
  12. data/features/step_definitions/app_generator_steps.rb +6 -0
  13. data/features/step_definitions/cli_steps.rb +74 -0
  14. data/features/support/aruba_helper.rb +22 -0
  15. data/features/support/env.rb +37 -0
  16. data/features/support/utils.rb +8 -0
  17. data/lib/adhearsion.rb +85 -41
  18. data/lib/adhearsion/call.rb +176 -0
  19. data/lib/adhearsion/call_controller.rb +134 -0
  20. data/lib/adhearsion/call_controller/dial.rb +70 -0
  21. data/lib/adhearsion/call_controller/input.rb +173 -0
  22. data/lib/adhearsion/call_controller/menu.rb +124 -0
  23. data/lib/adhearsion/call_controller/output.rb +267 -0
  24. data/lib/adhearsion/call_controller/record.rb +42 -0
  25. data/lib/adhearsion/call_controller/utility.rb +60 -0
  26. data/lib/adhearsion/calls.rb +81 -0
  27. data/lib/adhearsion/cli.rb +1 -3
  28. data/lib/adhearsion/cli_commands.rb +142 -0
  29. data/lib/adhearsion/configuration.rb +149 -0
  30. data/lib/adhearsion/console.rb +19 -8
  31. data/lib/adhearsion/dialplan_controller.rb +9 -0
  32. data/lib/adhearsion/events.rb +84 -0
  33. data/lib/adhearsion/foundation/all.rb +0 -7
  34. data/lib/adhearsion/foundation/custom_daemonizer.rb +4 -6
  35. data/lib/adhearsion/foundation/exception_handler.rb +9 -0
  36. data/lib/adhearsion/foundation/object.rb +26 -8
  37. data/lib/adhearsion/foundation/synchronized_hash.rb +3 -6
  38. data/lib/adhearsion/foundation/thread_safety.rb +17 -1
  39. data/lib/adhearsion/generators/app/app_generator.rb +4 -13
  40. data/lib/adhearsion/generators/app/templates/Gemfile +10 -5
  41. data/lib/adhearsion/generators/app/templates/Procfile +1 -0
  42. data/lib/adhearsion/generators/app/templates/README.md +28 -0
  43. data/lib/adhearsion/generators/app/templates/config/adhearsion.rb +41 -0
  44. data/lib/adhearsion/generators/app/templates/{components/simon_game → lib}/simon_game.rb +6 -18
  45. data/lib/adhearsion/generators/app/templates/script/ahn +2 -2
  46. data/lib/adhearsion/initializer.rb +151 -293
  47. data/lib/adhearsion/initializer/logging.rb +33 -0
  48. data/lib/adhearsion/logging.rb +65 -69
  49. data/lib/adhearsion/menu_dsl.rb +15 -0
  50. data/lib/adhearsion/menu_dsl/calculated_match.rb +39 -0
  51. data/lib/adhearsion/menu_dsl/calculated_match_collection.rb +41 -0
  52. data/lib/adhearsion/menu_dsl/fixnum_match_calculator.rb +18 -0
  53. data/lib/adhearsion/menu_dsl/match_calculator.rb +36 -0
  54. data/lib/adhearsion/{voip/menu_state_machine/menu_class.rb → menu_dsl/menu.rb} +38 -40
  55. data/lib/adhearsion/menu_dsl/menu_builder.rb +69 -0
  56. data/lib/adhearsion/menu_dsl/range_match_calculator.rb +55 -0
  57. data/lib/adhearsion/menu_dsl/string_match_calculator.rb +21 -0
  58. data/lib/adhearsion/outbound_call.rb +64 -0
  59. data/lib/adhearsion/plugin.rb +319 -0
  60. data/lib/adhearsion/plugin/collection.rb +19 -0
  61. data/lib/adhearsion/plugin/initializer.rb +37 -0
  62. data/lib/adhearsion/plugin/methods_container.rb +6 -0
  63. data/lib/adhearsion/process.rb +94 -0
  64. data/lib/adhearsion/punchblock_plugin.rb +29 -0
  65. data/lib/adhearsion/punchblock_plugin/initializer.rb +137 -0
  66. data/lib/adhearsion/router.rb +30 -0
  67. data/lib/adhearsion/router/route.rb +42 -0
  68. data/lib/adhearsion/script_ahn_loader.rb +2 -2
  69. data/lib/adhearsion/tasks.rb +14 -9
  70. data/lib/adhearsion/tasks/configuration.rb +26 -0
  71. data/lib/adhearsion/tasks/plugins.rb +17 -0
  72. data/lib/adhearsion/version.rb +8 -14
  73. data/spec/adhearsion/call_controller/dial_spec.rb +138 -0
  74. data/spec/adhearsion/call_controller/input_spec.rb +278 -0
  75. data/spec/adhearsion/call_controller/menu_spec.rb +120 -0
  76. data/spec/adhearsion/call_controller/output_spec.rb +466 -0
  77. data/spec/adhearsion/call_controller/record_spec.rb +125 -0
  78. data/spec/adhearsion/call_controller_spec.rb +395 -0
  79. data/spec/adhearsion/call_spec.rb +438 -0
  80. data/spec/adhearsion/calls_spec.rb +47 -0
  81. data/spec/adhearsion/configuration_spec.rb +308 -0
  82. data/spec/adhearsion/dialplan_controller_spec.rb +26 -0
  83. data/spec/adhearsion/events_spec.rb +112 -0
  84. data/spec/adhearsion/initializer/logging_spec.rb +58 -0
  85. data/spec/adhearsion/initializer_spec.rb +209 -122
  86. data/spec/adhearsion/logging_spec.rb +58 -47
  87. data/spec/adhearsion/menu_dsl/calculated_match_collection_spec.rb +56 -0
  88. data/spec/adhearsion/menu_dsl/calculated_match_spec.rb +57 -0
  89. data/spec/adhearsion/menu_dsl/fixnum_match_calculator_spec.rb +33 -0
  90. data/spec/adhearsion/menu_dsl/match_calculator_spec.rb +13 -0
  91. data/spec/adhearsion/menu_dsl/menu_builder_spec.rb +118 -0
  92. data/spec/adhearsion/menu_dsl/menu_spec.rb +210 -0
  93. data/spec/adhearsion/menu_dsl/range_match_calculator_spec.rb +28 -0
  94. data/spec/adhearsion/menu_dsl/string_match_calculator_spec.rb +36 -0
  95. data/spec/adhearsion/menu_dsl_spec.rb +12 -0
  96. data/spec/adhearsion/outbound_call_spec.rb +174 -0
  97. data/spec/adhearsion/plugin_spec.rb +489 -0
  98. data/spec/adhearsion/process_spec.rb +34 -0
  99. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +294 -0
  100. data/spec/adhearsion/router/route_spec.rb +99 -0
  101. data/spec/adhearsion/router_spec.rb +106 -0
  102. data/spec/adhearsion_spec.rb +46 -0
  103. data/spec/spec_helper.rb +14 -14
  104. data/spec/support/call_controller_test_helpers.rb +48 -0
  105. data/spec/support/initializer_stubs.rb +8 -13
  106. data/spec/support/punchblock_mocks.rb +6 -0
  107. metadata +255 -253
  108. data/CHANGELOG +0 -174
  109. data/bin/ahnctl +0 -68
  110. data/bin/jahn +0 -43
  111. data/examples/asterisk_manager_interface/standalone.rb +0 -51
  112. data/lib/adhearsion/commands.rb +0 -302
  113. data/lib/adhearsion/component_manager.rb +0 -278
  114. data/lib/adhearsion/component_manager/component_tester.rb +0 -54
  115. data/lib/adhearsion/component_manager/spec_framework.rb +0 -18
  116. data/lib/adhearsion/events_support.rb +0 -65
  117. data/lib/adhearsion/foundation/blank_slate.rb +0 -3
  118. data/lib/adhearsion/foundation/event_socket.rb +0 -205
  119. data/lib/adhearsion/foundation/future_resource.rb +0 -36
  120. data/lib/adhearsion/foundation/metaprogramming.rb +0 -17
  121. data/lib/adhearsion/foundation/numeric.rb +0 -13
  122. data/lib/adhearsion/foundation/pseudo_guid.rb +0 -10
  123. data/lib/adhearsion/foundation/relationship_properties.rb +0 -42
  124. data/lib/adhearsion/foundation/string.rb +0 -26
  125. data/lib/adhearsion/generators/app/templates/.ahnrc +0 -34
  126. data/lib/adhearsion/generators/app/templates/README +0 -8
  127. data/lib/adhearsion/generators/app/templates/components/ami_remote/ami_remote.rb +0 -15
  128. data/lib/adhearsion/generators/app/templates/components/disabled/HOW_TO_ENABLE +0 -7
  129. data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/README.markdown +0 -47
  130. data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/stomp_gateway.rb +0 -34
  131. data/lib/adhearsion/generators/app/templates/components/disabled/stomp_gateway/stomp_gateway.yml +0 -12
  132. data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/README.markdown +0 -3
  133. data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/xmpp_gateway.rb +0 -11
  134. data/lib/adhearsion/generators/app/templates/components/disabled/xmpp_gateway/xmpp_gateway.yml +0 -0
  135. data/lib/adhearsion/generators/app/templates/config/startup.rb +0 -81
  136. data/lib/adhearsion/generators/app/templates/dialplan.rb +0 -3
  137. data/lib/adhearsion/generators/app/templates/events.rb +0 -33
  138. data/lib/adhearsion/host_definitions.rb +0 -67
  139. data/lib/adhearsion/initializer/asterisk.rb +0 -86
  140. data/lib/adhearsion/initializer/configuration.rb +0 -324
  141. data/lib/adhearsion/initializer/database.rb +0 -60
  142. data/lib/adhearsion/initializer/drb.rb +0 -31
  143. data/lib/adhearsion/initializer/freeswitch.rb +0 -22
  144. data/lib/adhearsion/initializer/ldap.rb +0 -57
  145. data/lib/adhearsion/initializer/rails.rb +0 -41
  146. data/lib/adhearsion/initializer/xmpp.rb +0 -42
  147. data/lib/adhearsion/tasks/components.rb +0 -32
  148. data/lib/adhearsion/tasks/database.rb +0 -5
  149. data/lib/adhearsion/tasks/deprecations.rb +0 -59
  150. data/lib/adhearsion/tasks/generating.rb +0 -20
  151. data/lib/adhearsion/tasks/lint.rb +0 -4
  152. data/lib/adhearsion/voip/asterisk.rb +0 -4
  153. data/lib/adhearsion/voip/asterisk/agi_server.rb +0 -121
  154. data/lib/adhearsion/voip/asterisk/commands.rb +0 -1966
  155. data/lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb +0 -140
  156. data/lib/adhearsion/voip/asterisk/config_generators/config_generator.rb +0 -102
  157. data/lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb +0 -250
  158. data/lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb +0 -240
  159. data/lib/adhearsion/voip/asterisk/config_manager.rb +0 -64
  160. data/lib/adhearsion/voip/asterisk/manager_interface.rb +0 -697
  161. data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb +0 -1681
  162. data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb +0 -341
  163. data/lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb +0 -78
  164. data/lib/adhearsion/voip/asterisk/manager_interface/ami_protocol_lexer_machine.rl +0 -87
  165. data/lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb +0 -80
  166. data/lib/adhearsion/voip/call.rb +0 -521
  167. data/lib/adhearsion/voip/call_routing.rb +0 -64
  168. data/lib/adhearsion/voip/commands.rb +0 -17
  169. data/lib/adhearsion/voip/constants.rb +0 -39
  170. data/lib/adhearsion/voip/conveniences.rb +0 -18
  171. data/lib/adhearsion/voip/dial_plan.rb +0 -252
  172. data/lib/adhearsion/voip/dsl/dialing_dsl.rb +0 -151
  173. data/lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb +0 -37
  174. data/lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb +0 -27
  175. data/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb +0 -124
  176. data/lib/adhearsion/voip/dsl/dialplan/parser.rb +0 -69
  177. data/lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb +0 -16
  178. data/lib/adhearsion/voip/dsl/numerical_string.rb +0 -128
  179. data/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb +0 -48
  180. data/lib/adhearsion/voip/freeswitch/event_handler.rb +0 -58
  181. data/lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb +0 -129
  182. data/lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb +0 -38
  183. data/lib/adhearsion/voip/freeswitch/oes_server.rb +0 -195
  184. data/lib/adhearsion/voip/menu_state_machine/calculated_match.rb +0 -80
  185. data/lib/adhearsion/voip/menu_state_machine/matchers.rb +0 -123
  186. data/lib/adhearsion/voip/menu_state_machine/menu_builder.rb +0 -57
  187. data/lib/adhearsion/xmpp/connection.rb +0 -61
  188. data/lib/theatre.rb +0 -147
  189. data/lib/theatre/README.markdown +0 -64
  190. data/lib/theatre/callback_definition_loader.rb +0 -86
  191. data/lib/theatre/guid.rb +0 -23
  192. data/lib/theatre/invocation.rb +0 -131
  193. data/lib/theatre/namespace_manager.rb +0 -153
  194. data/lib/theatre/version.rb +0 -2
  195. data/spec/adhearsion/cli_spec.rb +0 -306
  196. data/spec/adhearsion/component_manager_spec.rb +0 -292
  197. data/spec/adhearsion/constants_spec.rb +0 -8
  198. data/spec/adhearsion/drb_spec.rb +0 -65
  199. data/spec/adhearsion/fixtures/dialplan.rb +0 -3
  200. data/spec/adhearsion/foundation/event_socket_spec.rb +0 -168
  201. data/spec/adhearsion/host_definitions_spec.rb +0 -79
  202. data/spec/adhearsion/initializer/configuration_spec.rb +0 -291
  203. data/spec/adhearsion/initializer/loading_spec.rb +0 -154
  204. data/spec/adhearsion/initializer/paths_spec.rb +0 -74
  205. data/spec/adhearsion/relationship_properties_spec.rb +0 -54
  206. data/spec/adhearsion/voip/asterisk/agi_server_spec.rb +0 -473
  207. data/spec/adhearsion/voip/asterisk/ami/ami_spec.rb +0 -550
  208. data/spec/adhearsion/voip/asterisk/ami/lexer/ami_fixtures.yml +0 -30
  209. data/spec/adhearsion/voip/asterisk/ami/lexer/lexer_story +0 -291
  210. data/spec/adhearsion/voip/asterisk/ami/lexer/lexer_story.rb +0 -241
  211. data/spec/adhearsion/voip/asterisk/ami/lexer/story_helper.rb +0 -124
  212. data/spec/adhearsion/voip/asterisk/commands_spec.rb +0 -3241
  213. data/spec/adhearsion/voip/asterisk/config_file_generators/agents_spec.rb +0 -251
  214. data/spec/adhearsion/voip/asterisk/config_file_generators/queues_spec.rb +0 -323
  215. data/spec/adhearsion/voip/asterisk/config_file_generators/voicemail_spec.rb +0 -306
  216. data/spec/adhearsion/voip/asterisk/config_manager_spec.rb +0 -127
  217. data/spec/adhearsion/voip/asterisk/menu_command/calculated_match_spec.rb +0 -109
  218. data/spec/adhearsion/voip/asterisk/menu_command/matchers_spec.rb +0 -97
  219. data/spec/adhearsion/voip/call_routing_spec.rb +0 -125
  220. data/spec/adhearsion/voip/dialplan_manager_spec.rb +0 -468
  221. data/spec/adhearsion/voip/dsl/dialing_dsl_spec.rb +0 -270
  222. data/spec/adhearsion/voip/dsl/dispatcher_spec.rb +0 -82
  223. data/spec/adhearsion/voip/dsl/dispatcher_spec_helper.rb +0 -45
  224. data/spec/adhearsion/voip/dsl/parser_spec.rb +0 -69
  225. data/spec/adhearsion/voip/freeswitch/basic_connection_manager_spec.rb +0 -39
  226. data/spec/adhearsion/voip/freeswitch/inbound_connection_manager_spec.rb +0 -39
  227. data/spec/adhearsion/voip/freeswitch/oes_server_spec.rb +0 -9
  228. data/spec/adhearsion/voip/numerical_string_spec.rb +0 -61
  229. data/spec/adhearsion/voip/phone_number_spec.rb +0 -45
  230. data/spec/support/the_following_code.rb +0 -3
  231. data/spec/theatre/dsl_examples/simple_before_call.rb +0 -7
  232. data/spec/theatre/dsl_spec.rb +0 -69
  233. data/spec/theatre/invocation_spec.rb +0 -182
  234. data/spec/theatre/namespace_spec.rb +0 -125
  235. data/spec/theatre/spec_helper_spec.rb +0 -28
  236. data/spec/theatre/theatre_class_spec.rb +0 -148
@@ -1,60 +0,0 @@
1
- # TODO: Have all of the initializer modules required and then traverse the subclasses, asking them if they're enabled. If they are enabled, then they should do their initialization stuff. Is this really necessary to develop this entirely new system when the components system exists?
2
-
3
- module Adhearsion
4
- class Initializer
5
-
6
- class DatabaseInitializer
7
-
8
- class << self
9
-
10
- def start
11
- require_dependencies
12
- require_models
13
- @@config = Adhearsion::AHN_CONFIG.database
14
- # You may need to uncomment the following line for older versions of ActiveRecord
15
- # ActiveRecord::Base.allow_concurrency = true
16
- establish_connection
17
- ActiveRecord::Base.logger =
18
- @@config.connection_options.has_key?(:logger) ?
19
- @@config.connection_options[:logger] :
20
- ahn_log.db
21
- create_call_hook_for_connection_cleanup
22
- end
23
-
24
- def stop
25
- ActiveRecord::Base.remove_connection
26
- end
27
-
28
- private
29
-
30
- def create_call_hook_for_connection_cleanup
31
- Events.register_callback([:asterisk, :before_call]) do
32
- ActiveRecord::Base.verify_active_connections!
33
- end
34
- end
35
-
36
- def require_dependencies
37
- begin
38
- require 'active_record'
39
- rescue LoadError
40
- ahn_log.fatal "Database support requires the \"activerecord\" gem."
41
- # Silence the abort so we don't get an ugly backtrace
42
- abort ""
43
- end
44
- end
45
-
46
- def require_models
47
- AHN_CONFIG.files_from_setting("paths", "models").each do |model|
48
- load model
49
- end
50
- end
51
-
52
- def establish_connection
53
- ActiveRecord::Base.establish_connection @@config.connection_options
54
- end
55
-
56
- end
57
- end
58
-
59
- end
60
- end
@@ -1,31 +0,0 @@
1
- require 'drb'
2
- require 'drb/acl'
3
- require 'thread'
4
-
5
- module Adhearsion
6
- class Initializer
7
-
8
- class DrbInitializer
9
-
10
- class << self
11
-
12
- def start
13
- config = Adhearsion::AHN_CONFIG.drb
14
- DRb.install_acl ACL.new(config.acl) if config.acl
15
-
16
- drb_door = Object.new
17
- Components.component_manager.extend_object_with(drb_door, :rpc)
18
-
19
- DRb.start_service "druby://#{config.host}:#{config.port}", drb_door
20
-
21
- ahn_log "Starting DRb on #{config.host}:#{config.port}"
22
- end
23
-
24
- def stop
25
- DRb.stop_service
26
- end
27
-
28
- end
29
- end
30
- end
31
- end
@@ -1,22 +0,0 @@
1
- # THIS FREESWITCH LIBRARY HASN'T BEEN INTEGRATED INTO THE REFACTORED 0.8.0 YET.
2
- # WHAT EXISTS HERE IS OLD, MUST BE CHANGED, AND DOES NOT EVEN GET LOADED AT THE MOMENT.
3
- require "adhearsion/voip/freeswitch/oes_server"
4
- require "adhearsion/voip/freeswitch/event_handler"
5
- require "adhearsion/voip/freeswitch/inbound_connection_manager"
6
- require "adhearsion/voip/dsl/dialplan/control_passing_exception"
7
-
8
- oes_enabled = Adhearsion::Configuration.core.voip.freeswitch.oes && Adhearsion::Configuration.core.voip.freeswitch.oes.port
9
-
10
-
11
- if oes_enabled
12
-
13
- port = Adhearsion::Configuration.core.voip.freeswitch.oes.port
14
- host = Adhearsion::Configuration.core.voip.freeswitch.oes.host
15
-
16
- server = Adhearsion::VoIP::FreeSwitch::OesServer.new port, host
17
-
18
- Events.register_callback(:after_initialized) { server.start }
19
- Events.register_callback(:shutdown) { server.stop }
20
- IMPORTANT_THREADS << server
21
-
22
- end
@@ -1,57 +0,0 @@
1
- # TODO: Have all of the initializer modules required and then traverse the subclasses, asking them if they're enabled. If they are enabled, then they should do their initialization stuff. Is this really necessary to develop this entirely new system when the components system exists?
2
-
3
- module Adhearsion
4
- class Initializer
5
-
6
- class LdapInitializer
7
-
8
- class << self
9
-
10
- def start
11
- require_dependencies
12
- require_models
13
- @@config = Adhearsion::AHN_CONFIG.ldap
14
- # You may need to uncomment the following line for older versions of ActiveRecord
15
- # ActiveRecord::Base.allow_concurrency = true
16
- establish_connection
17
- end
18
-
19
- def stop
20
- ActiveLdap::Base.remove_connection
21
- end
22
-
23
- private
24
-
25
- # TODO: It appears that ActiveLdap does not have a connection validation
26
- # or reconnection routine.
27
- #def create_call_hook_for_connection_cleanup
28
- # Events.register_callback([:asterisk, :before_call]) do
29
- # ActiveLdap::Base.verify_active_connections!
30
- # end
31
- #end
32
-
33
- def require_dependencies
34
- begin
35
- require 'active_ldap'
36
- rescue LoadError
37
- ahn_log.fatal "LDAP support requires the \"activeldap\" gem."
38
- # Silence the abort so we don't get an ugly backtrace
39
- abort ""
40
- end
41
- end
42
-
43
- def require_models
44
- AHN_CONFIG.files_from_setting("paths", "models").each do |model|
45
- load model
46
- end
47
- end
48
-
49
- def establish_connection
50
- ActiveLdap::Base.setup_connection @@config.connection_options
51
- end
52
-
53
- end
54
- end
55
-
56
- end
57
- end
@@ -1,41 +0,0 @@
1
- require 'adhearsion/voip/asterisk'
2
-
3
- module Adhearsion
4
- class Initializer
5
- class RailsInitializer
6
-
7
- cattr_accessor :rails_root, :config, :environment
8
- class << self
9
-
10
- def start
11
- ahn_config = Adhearsion::AHN_CONFIG
12
- self.config = ahn_config.rails
13
- self.rails_root = config.rails_root
14
- self.environment = config.environment
15
- raise "You cannot enable the database and Rails at the same time!" if ahn_config.database_enabled?
16
- raise "Error loading Rails environment in #{rails_root.inspect}. " +
17
- "It's not a directory!" unless File.directory?(rails_root)
18
- load_rails
19
- if defined? ActiveRecord
20
- # You may need to uncomment the following line for older versions of ActiveRecord
21
- # ActiveRecord::Base.allow_concurrency = true
22
- Events.register_callback([:asterisk, :before_call]) do
23
- ActiveRecord::Base.verify_active_connections!
24
- end
25
- end
26
- end
27
-
28
- private
29
-
30
- def load_rails
31
- environment_file = File.expand_path(rails_root + "/config/environment.rb")
32
- raise "There is no config/environment.rb file!" unless File.exists?(environment_file)
33
- ENV['RAILS_ENV'] = environment.to_s
34
- require environment_file
35
- end
36
-
37
- end
38
-
39
- end
40
- end
41
- end
@@ -1,42 +0,0 @@
1
- require 'adhearsion/xmpp/connection.rb'
2
-
3
- module Adhearsion
4
- class Initializer
5
- class XMPPInitializer
6
-
7
- cattr_accessor :config, :jid, :password, :server, :port
8
- class << self
9
-
10
- def start
11
- require_dependencies
12
- XMPP::Connection.extend Blather::DSL
13
- ahn_config = Adhearsion::AHN_CONFIG
14
- self.config = ahn_config.xmpp
15
- self.jid = config.jid
16
- self.password = config.password
17
- self.server = config.server
18
- self.port = config.port
19
-
20
- XMPP::Connection.start(jid, password, server, port)
21
- end
22
-
23
- def stop
24
- XMPP::Connection.stop
25
- end
26
-
27
- private
28
-
29
- def require_dependencies
30
- begin
31
- require 'blather/client/client'
32
- require 'blather/client/dsl'
33
- rescue LoadError
34
- ahn_log.fatal "XMPP support requires the \"blather\" gem."
35
- # Silence the abort so we don't get an ugly backtrace
36
- abort ""
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,32 +0,0 @@
1
- namespace:components do
2
- desc "Install component configuration from templates"
3
- task :genconfig do
4
- init = Adhearsion::Initializer.new(Rake.original_dir)
5
- init.bootstrap_rc
6
- init.load_all_init_files
7
- Adhearsion::AHN_CONFIG.components_to_load.each do |component|
8
- spec = Gem.searcher.find(component)
9
- if spec.nil?
10
- abort "ERROR: Required gem component #{component} not found."
11
- end
12
-
13
- yml = File.join(spec.full_gem_path, 'config', "#{component}.yml")
14
- target = File.join(AHN_ROOT, 'config', 'components', "#{component}.yml")
15
- Dir.mkdir(File.dirname(target)) if !File.exists?(File.dirname(target))
16
- if File.exists?(target)
17
- puts "Skipping existing configuration for component #{component}"
18
- next
19
- end
20
- if File.exists?(yml)
21
- begin
22
- FileUtils.cp(yml, target)
23
- puts "Installed default configuration for component #{component}"
24
- rescue => e
25
- abort "Error copying configuration for component #{component}: #{e.message}"
26
- end
27
- else
28
- puts "No template configuration found for component #{component}"
29
- end
30
- end
31
- end
32
- end
@@ -1,5 +0,0 @@
1
- task:migrate do
2
- require 'active_record'
3
- %w.db/migrate db/ahn..each
4
- ActiveRecord::Migrator.migrate 'db/migrate', ENV['VERSION'] ? ENV['VERSION'].to_i : nil
5
- end
@@ -1,59 +0,0 @@
1
- namespace :deprecations do
2
- desc <<-DESC
3
- Older versions of Adhearsion had an .ahnrc "paths" section similar to the following...
4
-
5
- paths:
6
- models:
7
- directory: models
8
- pattern: *.rb
9
-
10
- This has been deprecated. The new format is this:
11
-
12
- paths:
13
- models: {models,gui/app/models}/*.rb
14
-
15
- This Rake task will fix your .ahnrc if you have
16
- DESC
17
- task :fix_ahnrc_path_format do
18
- puts "\nThis will remove all comments from your .ahnrc file. A backup will be created as .ahnrc.backup."
19
- puts "If you wish to do this manually to preserve your comments, simply overwrite .ahnrc with .ahnrc.backup"
20
- puts "and apply the change manually."
21
- puts
22
-
23
- require 'fileutils'
24
- require 'yaml'
25
-
26
- ahnrc_file = File.expand_path(".ahnrc")
27
-
28
- FileUtils.cp ahnrc_file, ahnrc_file + ".backup"
29
- ahnrc_contents = YAML.load_file ahnrc_file
30
-
31
- abort '.ahnrc does not have a "paths" section!' unless ahnrc_contents.has_key? "paths"
32
-
33
- paths = ahnrc_contents["paths"]
34
- paths.clone.each_pair do |key,value|
35
- if value.kind_of?(Hash)
36
- if value.has_key?("directory") || value.has_key?("pattern")
37
- directory, pattern = value.values_at "directory", "pattern"
38
- new_path = "#{directory}/#{pattern}"
39
-
40
- puts "!!! CHANGING KEY #{key.inspect}!"
41
- puts "!!! NEW: #{new_path.inspect}"
42
- puts "!!! OLD:\n#{{key => value}.to_yaml.sub("---", "")}\n\n"
43
-
44
- paths[key] = new_path
45
- end
46
- end
47
- end
48
-
49
- ahnrc_contents["paths"] = paths
50
- new_yaml = ahnrc_contents.to_yaml.gsub("--- \n", "")
51
-
52
- puts "New .ahnrc file:\n" + ("#" * 25) + "\n"
53
- puts new_yaml
54
- puts '#' * 25
55
-
56
- File.open(ahnrc_file, "w") { |file| file.puts new_yaml }
57
- puts "Wrote to .ahnrc. Done!"
58
- end
59
- end
@@ -1,20 +0,0 @@
1
- namespace:create do
2
-
3
- task:war do
4
- # Hmm, this will is a tough one
5
- end
6
-
7
- task:rails_plugin do
8
-
9
- end
10
-
11
- task:migration do
12
- name = ARGV.shift
13
- end
14
- end
15
-
16
- namespace:delete do
17
- task:migration do
18
- # Take arg.underscore and remove it
19
- end
20
- end
@@ -1,4 +0,0 @@
1
- task :sanity do
2
- puts "Performing many checks on your Adhearsion application!"
3
- # TODO: Anything that should be brought to the user's attention should be placed here!
4
- end
@@ -1,4 +0,0 @@
1
- require File.dirname(__FILE__) + "/dsl/numerical_string"
2
- require File.dirname(__FILE__) + "/asterisk/agi_server"
3
- require File.dirname(__FILE__) + "/asterisk/manager_interface"
4
- require File.dirname(__FILE__) + "/asterisk/commands"
@@ -1,121 +0,0 @@
1
- require 'gserver'
2
- module Adhearsion
3
- module VoIP
4
- module Asterisk
5
- module AGI
6
- class Server
7
-
8
- class RubyServer < GServer
9
-
10
- def initialize(port, host)
11
- super(port, host, (1.0/0.0)) # (1.0/0.0) == Infinity
12
- end
13
-
14
- def disconnecting(port)
15
- @call.deliver_message :cancel if !@call.nil?
16
- super(port)
17
- end
18
-
19
- def serve(io)
20
- begin
21
- call = Adhearsion.receive_call_from(io)
22
- rescue EOFError
23
- # We didn't get the initial headers we were expecting
24
- return
25
- end
26
-
27
- Events.trigger_immediately([:asterisk, :before_call], call)
28
- ahn_log.agi.debug "Handling call with variables #{call.variables.inspect}"
29
-
30
- return DialPlan::ConfirmationManager.handle(call) if DialPlan::ConfirmationManager.confirmation_call?(call)
31
-
32
- # This is what happens 99.9% of the time.
33
-
34
- DialPlan::Manager.handle call
35
- rescue Hangup
36
- ahn_log.agi "HANGUP event for call with uniqueid #{call.variables[:uniqueid].inspect} and channel #{call.variables[:channel].inspect}"
37
- Events.trigger_immediately([:asterisk, :after_call], call)
38
- call.hangup!
39
- rescue DialPlan::Manager::NoContextError => e
40
- ahn_log.agi e.message
41
- call.hangup!
42
- rescue FailedExtensionCallException => failed_call
43
- begin
44
- ahn_log.agi "Received \"failed\" meta-call with :failed_reason => #{failed_call.call.failed_reason.inspect}. Executing Executing /asterisk/failed_call event callbacks."
45
- Events.trigger [:asterisk, :failed_call], failed_call.call
46
- call.hangup!
47
- rescue => e
48
- ahn_log.agi.error e
49
- end
50
- rescue HungupExtensionCallException => hungup_call
51
- begin
52
- ahn_log.agi "Received \"h\" meta-call. Executing /asterisk/hungup_call event callbacks."
53
- Events.trigger [:asterisk, :hungup_call], hungup_call.call
54
- call.hangup!
55
- rescue => e
56
- ahn_log.agi.error e
57
- end
58
- rescue UselessCallException
59
- ahn_log.agi "Ignoring meta-AGI request"
60
- call.hangup!
61
- # TBD: (may have more hooks than what Jay has defined in hooks.rb)
62
- rescue SyntaxError, StandardError => e
63
- Events.trigger(['exception'], e)
64
- ensure
65
- Adhearsion.remove_inactive_call call rescue nil
66
- end
67
-
68
- def log(msg)
69
- ahn_log.agi msg
70
- end
71
-
72
- def error(detail)
73
- ahn_log.agi.error detail.backtrace.join("\n")
74
- end
75
- end
76
-
77
- DEFAULT_OPTIONS = { :server_class => RubyServer, :port => 4573, :host => "0.0.0.0" } unless defined? DEFAULT_OPTIONS
78
- attr_reader :host, :port, :server_class, :server
79
-
80
- def initialize(options = {})
81
- options = DEFAULT_OPTIONS.merge options
82
- @host, @port, @server_class = options.values_at(:host, :port, :server_class)
83
- @server = server_class.new(port, host)
84
- end
85
-
86
- def start
87
- server.audit = true
88
- server.start
89
- end
90
-
91
- def graceful_shutdown
92
- if @shutting_down
93
- server.stop
94
- return
95
- end
96
-
97
- @shutting_down = true
98
-
99
- while server.connections > 0
100
- sleep 0.2
101
- end
102
-
103
- server.stop
104
- end
105
-
106
- def shutdown
107
- server.shutdown
108
- end
109
-
110
- def stop
111
- server.stop
112
- end
113
-
114
- def join
115
- server.join
116
- end
117
- end
118
- end
119
- end
120
- end
121
- end