eric-adhearsion 0.7.999 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. data/CHANGELOG +8 -2
  2. data/EVENTS +11 -0
  3. data/Rakefile +96 -24
  4. data/adhearsion.gemspec +148 -0
  5. data/app_generators/ahn/ahn_generator.rb +24 -9
  6. data/app_generators/ahn/templates/.ahnrc +25 -3
  7. data/app_generators/ahn/templates/Rakefile +22 -2
  8. data/app_generators/ahn/templates/components/ami_remote/ami_remote.rb +15 -0
  9. data/app_generators/ahn/templates/components/disabled/HOW_TO_ENABLE +7 -0
  10. data/app_generators/ahn/templates/components/disabled/stomp_gateway/README.markdown +47 -0
  11. data/app_generators/ahn/templates/components/disabled/stomp_gateway/config.yml +12 -0
  12. data/app_generators/ahn/templates/components/disabled/stomp_gateway/stomp_gateway.rb +34 -0
  13. data/app_generators/ahn/templates/components/simon_game/{lib/simon_game.rb → simon_game.rb} +14 -19
  14. data/app_generators/ahn/templates/config/startup.rb +3 -6
  15. data/app_generators/ahn/templates/dialplan.rb +2 -3
  16. data/app_generators/ahn/templates/events.rb +32 -0
  17. data/bin/jahn +10 -0
  18. data/examples/asterisk_manager_interface/standalone.rb +51 -0
  19. data/lib/adhearsion.rb +17 -11
  20. data/lib/adhearsion/cli.rb +141 -24
  21. data/lib/adhearsion/component_manager.rb +169 -238
  22. data/lib/adhearsion/component_manager/component_tester.rb +55 -0
  23. data/lib/adhearsion/component_manager/spec_framework.rb +24 -0
  24. data/lib/adhearsion/events_support.rb +84 -0
  25. data/lib/adhearsion/{core_extensions → foundation}/all.rb +0 -0
  26. data/lib/adhearsion/{blank_slate.rb → foundation/blank_slate.rb} +0 -0
  27. data/lib/adhearsion/{core_extensions → foundation}/custom_daemonizer.rb +0 -0
  28. data/lib/adhearsion/foundation/event_socket.rb +203 -0
  29. data/lib/adhearsion/foundation/future_resource.rb +36 -0
  30. data/lib/adhearsion/{core_extensions → foundation}/global.rb +0 -0
  31. data/lib/adhearsion/{core_extensions → foundation}/metaprogramming.rb +0 -0
  32. data/lib/adhearsion/foundation/numeric.rb +13 -0
  33. data/lib/adhearsion/foundation/pseudo_guid.rb +10 -0
  34. data/lib/adhearsion/{core_extensions → foundation}/relationship_properties.rb +2 -0
  35. data/lib/adhearsion/foundation/string.rb +26 -0
  36. data/lib/adhearsion/foundation/synchronized_hash.rb +96 -0
  37. data/lib/adhearsion/{core_extensions → foundation}/thread_safety.rb +0 -0
  38. data/lib/adhearsion/host_definitions.rb +5 -1
  39. data/lib/adhearsion/initializer.rb +229 -73
  40. data/lib/adhearsion/initializer/asterisk.rb +33 -11
  41. data/lib/adhearsion/initializer/configuration.rb +58 -6
  42. data/lib/adhearsion/initializer/database.rb +3 -46
  43. data/lib/adhearsion/initializer/drb.rb +9 -3
  44. data/lib/adhearsion/initializer/freeswitch.rb +3 -3
  45. data/lib/adhearsion/initializer/rails.rb +1 -1
  46. data/lib/adhearsion/tasks.rb +2 -1
  47. data/lib/adhearsion/tasks/deprecations.rb +59 -0
  48. data/lib/adhearsion/version.rb +3 -3
  49. data/lib/adhearsion/voip/asterisk.rb +2 -2
  50. data/lib/adhearsion/voip/asterisk/agi_server.rb +9 -6
  51. data/lib/adhearsion/voip/asterisk/commands.rb +106 -4
  52. data/lib/adhearsion/voip/asterisk/manager_interface.rb +562 -0
  53. data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb +1754 -0
  54. data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb +286 -0
  55. data/lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb +78 -0
  56. data/lib/adhearsion/voip/asterisk/manager_interface/ami_protocol_lexer_machine.rl +87 -0
  57. data/lib/adhearsion/voip/asterisk/super_manager.rb +19 -0
  58. data/lib/adhearsion/voip/call.rb +51 -2
  59. data/lib/adhearsion/voip/dial_plan.rb +74 -61
  60. data/lib/adhearsion/voip/dsl/dialing_dsl.rb +1 -1
  61. data/lib/adhearsion/voip/dsl/dialplan/parser.rb +2 -6
  62. data/lib/adhearsion/voip/dsl/numerical_string.rb +2 -2
  63. data/lib/adhearsion/voip/freeswitch/oes_server.rb +2 -2
  64. data/lib/theatre.rb +151 -0
  65. data/lib/theatre/README.markdown +64 -0
  66. data/lib/theatre/callback_definition_loader.rb +84 -0
  67. data/lib/theatre/guid.rb +23 -0
  68. data/lib/theatre/invocation.rb +121 -0
  69. data/lib/theatre/namespace_manager.rb +153 -0
  70. data/lib/theatre/version.rb +2 -0
  71. metadata +63 -138
  72. data/Manifest.txt +0 -149
  73. data/README.txt +0 -6
  74. data/ahn_generators/component/USAGE +0 -5
  75. data/ahn_generators/component/component_generator.rb +0 -57
  76. data/ahn_generators/component/templates/configuration.rb +0 -0
  77. data/ahn_generators/component/templates/lib/lib.rb.erb +0 -3
  78. data/ahn_generators/component/templates/test/test.rb.erb +0 -12
  79. data/ahn_generators/component/templates/test/test_helper.rb +0 -14
  80. data/app_generators/ahn/templates/components/simon_game/configuration.rb +0 -0
  81. data/app_generators/ahn/templates/components/simon_game/test/test_helper.rb +0 -14
  82. data/app_generators/ahn/templates/components/simon_game/test/test_simon_game.rb +0 -31
  83. data/lib/adhearsion/core_extensions/array.rb +0 -0
  84. data/lib/adhearsion/core_extensions/guid.rb +0 -5
  85. data/lib/adhearsion/core_extensions/hash.rb +0 -0
  86. data/lib/adhearsion/core_extensions/numeric.rb +0 -4
  87. data/lib/adhearsion/core_extensions/proc.rb +0 -0
  88. data/lib/adhearsion/core_extensions/pseudo_uuid.rb +0 -11
  89. data/lib/adhearsion/core_extensions/publishable.rb +0 -73
  90. data/lib/adhearsion/core_extensions/string.rb +0 -26
  91. data/lib/adhearsion/core_extensions/thread.rb +0 -13
  92. data/lib/adhearsion/core_extensions/time.rb +0 -0
  93. data/lib/adhearsion/distributed/gateways/dbus_gateway.rb +0 -0
  94. data/lib/adhearsion/distributed/gateways/osa_gateway.rb +0 -0
  95. data/lib/adhearsion/distributed/gateways/rest_gateway.rb +0 -9
  96. data/lib/adhearsion/distributed/gateways/soap_gateway.rb +0 -9
  97. data/lib/adhearsion/distributed/gateways/xmlrpc_gateway.rb +0 -9
  98. data/lib/adhearsion/distributed/peer_finder.rb +0 -0
  99. data/lib/adhearsion/distributed/remote_cli.rb +0 -0
  100. data/lib/adhearsion/hooks.rb +0 -57
  101. data/lib/adhearsion/initializer/paths.rb +0 -55
  102. data/lib/adhearsion/services/scheduler.rb +0 -5
  103. data/lib/adhearsion/voip/asterisk/ami.rb +0 -147
  104. data/lib/adhearsion/voip/asterisk/ami/actions.rb +0 -238
  105. data/lib/adhearsion/voip/asterisk/ami/machine.rb +0 -871
  106. data/lib/adhearsion/voip/asterisk/ami/machine.rl +0 -109
  107. data/lib/adhearsion/voip/asterisk/ami/parser.rb +0 -262
  108. data/script/destroy +0 -14
  109. data/script/generate +0 -14
  110. data/spec/fixtures/dialplan.rb +0 -3
  111. data/spec/initializer/test_configuration.rb +0 -267
  112. data/spec/initializer/test_loading.rb +0 -162
  113. data/spec/initializer/test_paths.rb +0 -43
  114. data/spec/silence.rb +0 -10
  115. data/spec/test_ahn_command.rb +0 -149
  116. data/spec/test_code_quality.rb +0 -87
  117. data/spec/test_component_manager.rb +0 -97
  118. data/spec/test_constants.rb +0 -8
  119. data/spec/test_drb.rb +0 -104
  120. data/spec/test_helper.rb +0 -94
  121. data/spec/test_hooks.rb +0 -37
  122. data/spec/test_host_definitions.rb +0 -79
  123. data/spec/test_initialization.rb +0 -105
  124. data/spec/test_logging.rb +0 -80
  125. data/spec/test_relationship_properties.rb +0 -54
  126. data/spec/voip/asterisk/ami_response_definitions.rb +0 -23
  127. data/spec/voip/asterisk/config_file_generators/test_agents.rb +0 -253
  128. data/spec/voip/asterisk/config_file_generators/test_queues.rb +0 -325
  129. data/spec/voip/asterisk/config_file_generators/test_voicemail.rb +0 -306
  130. data/spec/voip/asterisk/menu_command/test_calculated_match.rb +0 -111
  131. data/spec/voip/asterisk/menu_command/test_matchers.rb +0 -98
  132. data/spec/voip/asterisk/mock_ami_server.rb +0 -176
  133. data/spec/voip/asterisk/test_agi_server.rb +0 -451
  134. data/spec/voip/asterisk/test_ami.rb +0 -227
  135. data/spec/voip/asterisk/test_commands.rb +0 -2006
  136. data/spec/voip/asterisk/test_config_manager.rb +0 -129
  137. data/spec/voip/dsl/dispatcher_spec_helper.rb +0 -45
  138. data/spec/voip/dsl/test_dialing_dsl.rb +0 -268
  139. data/spec/voip/dsl/test_dispatcher.rb +0 -82
  140. data/spec/voip/dsl/test_parser.rb +0 -87
  141. data/spec/voip/freeswitch/test_basic_connection_manager.rb +0 -39
  142. data/spec/voip/freeswitch/test_inbound_connection_manager.rb +0 -39
  143. data/spec/voip/freeswitch/test_oes_server.rb +0 -9
  144. data/spec/voip/test_call_routing.rb +0 -127
  145. data/spec/voip/test_dialplan_manager.rb +0 -372
  146. data/spec/voip/test_numerical_string.rb +0 -48
  147. data/spec/voip/test_phone_number.rb +0 -36
  148. data/test/test_ahn_generator.rb +0 -59
  149. data/test/test_component_generator.rb +0 -52
  150. data/test/test_generator_helper.rb +0 -20
@@ -1,48 +0,0 @@
1
- require File.dirname(__FILE__) + "/../test_helper"
2
-
3
- require 'adhearsion/voip/dsl/numerical_string'
4
- require 'adhearsion/voip/constants'
5
-
6
- context "A NumericalString" do
7
- test "NumericalString should appear to be behave like a Fixnum in a case statement" do
8
- assert 123 === numerical_string_for("123")
9
- assert 987 === numerical_string_for("0987")
10
- end
11
-
12
- test "NumericalString should appear to behave like a String in a case statement" do
13
- assert "123" === numerical_string_for("123")
14
- assert "0987" === numerical_string_for("0987")
15
- end
16
-
17
- test "when compared against a Range that contains the numeric equivalent, the NumericalString is seen as a member" do
18
- assert((100..200) === numerical_string_for("150"))
19
- assert((100..200) === numerical_string_for("0150"))
20
- assert !((100..200) === numerical_string_for("1000000"))
21
- end
22
-
23
- test "comparing against a regular expression works" do
24
- assert %r|^\d+$| === numerical_string_for("027316287")
25
- end
26
-
27
- test "checking if a string representation of a number starts with a leading zero" do
28
- with_leading_zeros = %w(01 01234 01.23 01.2)
29
- without_leading_zeros = %w(1 1.2 0 0.0)
30
-
31
- with_leading_zeros.each do |number|
32
- assert numerical_string.starts_with_leading_zero?(number), number
33
- end
34
-
35
- without_leading_zeros.each do |number|
36
- assert !numerical_string.starts_with_leading_zero?(number), number
37
- end
38
- end
39
-
40
- private
41
- def numerical_string
42
- Adhearsion::VoIP::DSL::NumericalString
43
- end
44
-
45
- def numerical_string_for(string)
46
- numerical_string.new(string)
47
- end
48
- end
@@ -1,36 +0,0 @@
1
- require File.dirname(__FILE__) + "/../test_helper"
2
- require 'adhearsion/voip/constants'
3
- require 'adhearsion/voip/dsl/numerical_string'
4
-
5
-
6
- # Use cases...
7
- # case extension
8
- # when US_NUMBER
9
- # when (100..200)
10
- # when _('12Z')
11
- # when 123
12
- # when "123"
13
- # end
14
-
15
- describe "A PhoneNumber" do
16
-
17
- it "should have an ISN pattern-matching method" do
18
- !! Adhearsion::VoIP::DSL::PhoneNumber.new("0115544332211").isn?.should == false
19
- !! Adhearsion::VoIP::DSL::PhoneNumber.new("1*548").isn?.should == false
20
- end
21
-
22
- it "should have a US local number pattern-matching method" do
23
- !! Adhearsion::VoIP::DSL::PhoneNumber.new("18887776665555").local_number?.should == false
24
- !! Adhearsion::VoIP::DSL::PhoneNumber.new("18887776665555").national_number?.should == false
25
-
26
- !! Adhearsion::VoIP::DSL::PhoneNumber.new("8887776665555").local_number?.should == false
27
- !! Adhearsion::VoIP::DSL::PhoneNumber.new("8887776665555").national_number?.should == true
28
-
29
- !! Adhearsion::VoIP::DSL::PhoneNumber.new("4445555").local_number?.should == true
30
- !! Adhearsion::VoIP::DSL::PhoneNumber.new("4445555").national_number?.should == false
31
- end
32
-
33
- it "should convert from vanity numbers properly" do
34
- Adhearsion::VoIP::DSL::PhoneNumber.from_vanity("1-800-FUDGEME").should == "18003834363"
35
- end
36
- end
@@ -1,59 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
-
3
- class TestAhnGenerator < Test::Unit::TestCase
4
- include RubiGen::GeneratorTestHelper
5
-
6
- def setup
7
- bare_setup
8
- end
9
-
10
- def teardown
11
- bare_teardown
12
- end
13
-
14
- # Some generator-related assertions:
15
- # assert_generated_file(name, &block) # block passed the file contents
16
- # assert_directory_exists(name)
17
- # assert_generated_class(name, &block)
18
- # assert_generated_module(name, &block)
19
- # assert_generated_test_for(name, &block)
20
- # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
21
- # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
22
- #
23
- # Other helper methods are:
24
- # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
25
- # bare_setup - place this in setup method to create the APP_ROOT folder for each test
26
- # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
27
-
28
- def test_generator_without_options
29
- run_generator('ahn', [APP_ROOT], sources)
30
- assert_directory_exists "components/simon_game/lib"
31
- assert_directory_exists "components/simon_game/test"
32
- assert_directory_exists "config"
33
-
34
- assert_generated_file "components/simon_game/configuration.rb"
35
- assert_generated_file "components/simon_game/lib/simon_game.rb"
36
- assert_generated_file "components/simon_game/test/test_helper.rb"
37
- assert_generated_file "components/simon_game/test/test_simon_game.rb"
38
- assert_generated_file "config/startup.rb"
39
- assert_generated_file "dialplan.rb"
40
- assert_generated_file "README"
41
- assert_generated_file "Rakefile"
42
-
43
- assert_generated_class "components/simon_game/lib/simon_game" do |body|
44
- assert_has_method body, "initialize"
45
- assert_has_method body, "start"
46
- assert_has_method body, "random_number"
47
- end
48
- end
49
-
50
- private
51
- def sources
52
- [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
53
- ]
54
- end
55
-
56
- def generator_path
57
- "app_generators"
58
- end
59
- end
@@ -1,52 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
-
3
- class TestComponentGenerator < Test::Unit::TestCase
4
- include RubiGen::GeneratorTestHelper
5
-
6
- def setup
7
- bare_setup
8
- end
9
-
10
- def teardown
11
- bare_teardown
12
- end
13
-
14
- # Some generator-related assertions:
15
- # assert_generated_file(name, &block) # block passed the file contents
16
- # assert_directory_exists(name)
17
- # assert_generated_class(name, &block)
18
- # assert_generated_module(name, &block)
19
- # assert_generated_test_for(name, &block)
20
- # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
21
- # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
22
- #
23
- # Other helper methods are:
24
- # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
25
- # bare_setup - place this in setup method to create the APP_ROOT folder for each test
26
- # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
27
-
28
- def test_generator_without_options
29
- name = "bobs_game"
30
- run_generator('component', [name], sources)
31
- assert_directory_exists "components/bobs_game/lib"
32
- assert_directory_exists "components/bobs_game/test"
33
- assert_generated_file "components/bobs_game/configuration.rb"
34
-
35
- assert_generated_file "components/bobs_game/lib/bobs_game.rb"
36
- assert_generated_class "components/bobs_game/lib/bobs_game"
37
-
38
- assert_generated_file "components/bobs_game/test/test_bobs_game.rb"
39
- assert_generated_file "components/bobs_game/test/test_helper.rb"
40
-
41
- end
42
-
43
- private
44
- def sources
45
- [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
46
- ]
47
- end
48
-
49
- def generator_path
50
- "ahn_generators"
51
- end
52
- end
@@ -1,20 +0,0 @@
1
- require 'test/unit'
2
- require 'fileutils'
3
-
4
- # Must set before requiring generator libs.
5
- TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
6
- PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
7
- app_root = File.join(TMP_ROOT, PROJECT_NAME)
8
- if defined?(APP_ROOT)
9
- APP_ROOT.replace(app_root)
10
- else
11
- APP_ROOT = app_root
12
- end
13
-
14
- begin
15
- require 'rubigen'
16
- rescue LoadError
17
- require 'rubygems'
18
- require 'rubigen'
19
- end
20
- require 'rubigen/helpers/generator_test_helper'