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
data/adhearsion.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "adhearsion/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "adhearsion"
|
7
|
-
s.version = Adhearsion::VERSION
|
7
|
+
s.version = Adhearsion::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Jay Phillips", "Jason Goecke", "Ben Klang", "Ben Langfeld"]
|
10
10
|
s.email = "dev&Adhearsion.com"
|
@@ -20,23 +20,37 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
# Runtime dependencies
|
22
22
|
s.add_runtime_dependency "bundler", [">= 1.0.10"]
|
23
|
-
s.add_runtime_dependency
|
24
|
-
s.add_runtime_dependency "
|
23
|
+
s.add_runtime_dependency 'punchblock', [">= 0.8.3"]
|
24
|
+
s.add_runtime_dependency "logging", [">= 1.6.1"]
|
25
|
+
s.add_runtime_dependency "loquacious", [">= 1.9.0"]
|
26
|
+
s.add_runtime_dependency "activesupport", [">= 3.0.10"]
|
25
27
|
# i18n is only strictly a dependency for ActiveSupport >= 3.0.0
|
26
28
|
# Since it doesn't conflict with <3.0.0 we'll require it to be
|
27
29
|
# on the safe side.
|
28
|
-
s.add_runtime_dependency "i18n"
|
30
|
+
s.add_runtime_dependency "i18n", ">= 0.5.0"
|
29
31
|
s.add_runtime_dependency "json"
|
30
32
|
s.add_runtime_dependency "thor"
|
31
33
|
s.add_runtime_dependency "rake"
|
32
34
|
s.add_runtime_dependency "pry"
|
35
|
+
s.add_runtime_dependency "uuid"
|
36
|
+
s.add_runtime_dependency "future-resource", [">= 0.0.2"]
|
37
|
+
s.add_runtime_dependency "ruby_speech", [">= 0.4.0"]
|
38
|
+
s.add_runtime_dependency 'countdownlatch'
|
39
|
+
s.add_runtime_dependency 'has-guarded-handlers', [">= 0.1.1"]
|
40
|
+
s.add_runtime_dependency 'girl_friday'
|
41
|
+
s.add_runtime_dependency 'jruby-openssl' if RUBY_PLATFORM == 'java'
|
33
42
|
|
34
43
|
# Development dependencies
|
35
|
-
s.add_development_dependency 'rspec', ["
|
44
|
+
s.add_development_dependency 'rspec', ["~> 2.7.0"]
|
36
45
|
s.add_development_dependency 'flexmock'
|
37
|
-
s.add_development_dependency 'activerecord', [">=
|
38
|
-
s.add_development_dependency 'rake'
|
46
|
+
s.add_development_dependency 'activerecord', [">= 3.0.10"]
|
39
47
|
s.add_development_dependency 'simplecov'
|
40
48
|
s.add_development_dependency 'simplecov-rcov'
|
41
49
|
s.add_development_dependency 'ci_reporter'
|
50
|
+
s.add_development_dependency 'yard'
|
51
|
+
s.add_development_dependency 'guard-rspec'
|
52
|
+
s.add_development_dependency 'guard-cucumber'
|
53
|
+
s.add_development_dependency 'ruby_gntp'
|
54
|
+
s.add_development_dependency 'cucumber'
|
55
|
+
s.add_development_dependency 'aruba'
|
42
56
|
end
|
data/bin/ahn
CHANGED
data/cucumber.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Feature: Adhearsion App Generator
|
2
|
+
In order to do development on new Adhearsion apps
|
3
|
+
As a Adhearsiohn developer
|
4
|
+
I want to generate an Adhearsion app
|
5
|
+
|
6
|
+
Scenario: Generate application with valid layout
|
7
|
+
When I run `ahn create path/somewhere`
|
8
|
+
And I cd to "path/somewhere"
|
9
|
+
Then the following directories should exist:
|
10
|
+
| lib |
|
11
|
+
| config |
|
12
|
+
| script |
|
13
|
+
|
14
|
+
And the following files should exist:
|
15
|
+
| config/adhearsion.rb |
|
16
|
+
| config/environment.rb |
|
17
|
+
| Gemfile |
|
18
|
+
| lib/simon_game.rb |
|
19
|
+
| script/ahn |
|
20
|
+
| README.md |
|
21
|
+
| Rakefile |
|
22
|
+
|
23
|
+
And the file "config/adhearsion.rb" should contain each of these content parts:
|
24
|
+
"""
|
25
|
+
Adhearsion.router
|
26
|
+
Adhearsion.config
|
27
|
+
logging.level
|
28
|
+
config.punchblock
|
29
|
+
"""
|
30
|
+
And the file "README.md" should contain each of these content parts:
|
31
|
+
"""
|
32
|
+
Start your new app with
|
33
|
+
AGI(agi
|
34
|
+
"""
|
35
|
+
And the file "Rakefile" should contain "adhearsion/tasks"
|
36
|
+
And the file "Gemfile" should contain each of these content parts:
|
37
|
+
"""
|
38
|
+
source :rubygems
|
39
|
+
gem 'adhearsion-asterisk'
|
40
|
+
"""
|
41
|
+
And the file "lib/simon_game.rb" should contain "class SimonGame"
|
42
|
+
And the file "script/ahn" should contain "require 'adhearsion'"
|
@@ -0,0 +1,108 @@
|
|
1
|
+
Feature: Adhearsion Ahn CLI
|
2
|
+
As a Adhearsion user
|
3
|
+
I want a cli command (ahn)
|
4
|
+
So that I can create and interact with adhearsion apps
|
5
|
+
|
6
|
+
Scenario: No arguments given
|
7
|
+
When I run `ahn`
|
8
|
+
Then I should see the usage message
|
9
|
+
And the exit status should be 0
|
10
|
+
|
11
|
+
Scenario: Unrecognized commands
|
12
|
+
When I run `ahn alpha beta`
|
13
|
+
Then the output should contain:
|
14
|
+
"""
|
15
|
+
Unknown command: alpha beta
|
16
|
+
"""
|
17
|
+
And the exit status should be 1
|
18
|
+
|
19
|
+
Scenario: Command create with correct arguments
|
20
|
+
When I run `ahn create path/somewhere`
|
21
|
+
And I cd to "path/somewhere"
|
22
|
+
Then the following files should exist:
|
23
|
+
| Gemfile |
|
24
|
+
| README.md |
|
25
|
+
| Rakefile |
|
26
|
+
| config/adhearsion.rb |
|
27
|
+
| config/environment.rb |
|
28
|
+
And the file "config/adhearsion.rb" should contain "Adhearsion.router"
|
29
|
+
Then the exit status should be 0
|
30
|
+
|
31
|
+
Scenario: Running create with no arguments
|
32
|
+
When I run `ahn create`
|
33
|
+
Then the output should contain:
|
34
|
+
"""
|
35
|
+
"create" was called incorrectly. Call as "ahn create /path/to/directory".
|
36
|
+
"""
|
37
|
+
And the exit status should be 1
|
38
|
+
|
39
|
+
Scenario: Command start with no path outside of the app directory
|
40
|
+
When I run `ahn start`
|
41
|
+
Then the output should contain:
|
42
|
+
"""
|
43
|
+
A valid path is required for start, unless run from an Adhearson app directory
|
44
|
+
"""
|
45
|
+
And the exit status should be 1
|
46
|
+
|
47
|
+
Scenario: Command start with no path inside of the app directory
|
48
|
+
Given that I create a valid app under "path/somewhere"
|
49
|
+
When I cd to "path/somewhere"
|
50
|
+
And I run `ahn start` interactively
|
51
|
+
And I wait for output to contain "Transitioning from booting to running"
|
52
|
+
And I terminate the interactive process
|
53
|
+
Then the output should contain "Loaded config"
|
54
|
+
And the output should contain "Adhearsion::Console: Starting up..."
|
55
|
+
And the output should contain "AHN>"
|
56
|
+
And the output should contain "Starting connection"
|
57
|
+
And the output should contain "Transitioning from running to stopping"
|
58
|
+
|
59
|
+
Scenario: Command start with only path works properly
|
60
|
+
Given that I create a valid app under "path/somewhere"
|
61
|
+
When I run `ahn start path/somewhere` interactively
|
62
|
+
And I wait for output to contain "Transitioning from booting to running"
|
63
|
+
And I terminate the interactive process
|
64
|
+
Then the output should contain "Loaded config"
|
65
|
+
And the output should contain "Adhearsion::Console: Starting up..."
|
66
|
+
And the output should contain "AHN>"
|
67
|
+
And the output should contain "Starting connection"
|
68
|
+
And the output should contain "Transitioning from running to stopping"
|
69
|
+
|
70
|
+
Scenario: Command daemon with path works correctly
|
71
|
+
Given JRuby skip test
|
72
|
+
Given that I create a valid app under "path/somewhere"
|
73
|
+
When I run `ahn daemon path/somewhere`
|
74
|
+
And I cd to "path/somewhere"
|
75
|
+
And I terminate the process using the pid file "adhearsion.pid"
|
76
|
+
Then the output should contain "Daemonizing now"
|
77
|
+
And the exit status should be 0
|
78
|
+
|
79
|
+
Scenario: Command start with daemon and pid option
|
80
|
+
Given JRuby skip test
|
81
|
+
Given that I create a valid app under "path/somewhere"
|
82
|
+
When I run `ahn daemon path/somewhere --pid-file=ahn.pid`
|
83
|
+
And I cd to "path/somewhere"
|
84
|
+
And I terminate the process using the pid file "ahn.pid"
|
85
|
+
Then the output should contain "Daemonizing now"
|
86
|
+
|
87
|
+
Scenario: Command stop with valid path and pid option
|
88
|
+
Given JRuby skip test
|
89
|
+
Given that I create a valid app under "path/somewhere"
|
90
|
+
When I run `ahn daemon path/somewhere --pid-file=ahn.pid`
|
91
|
+
And I run `ahn stop path/somewhere --pid-file=ahn.pid`
|
92
|
+
Then the output should contain:
|
93
|
+
"""
|
94
|
+
Stopping Adhearsion
|
95
|
+
"""
|
96
|
+
|
97
|
+
Scenario: Command version should print the version
|
98
|
+
When I run `ahn version`
|
99
|
+
Then the output should contain:
|
100
|
+
"""
|
101
|
+
Adhearsion v
|
102
|
+
"""
|
103
|
+
And the exit status should be 0
|
104
|
+
|
105
|
+
Scenario: Command help
|
106
|
+
When I run `ahn help`
|
107
|
+
Then I should see the usage message
|
108
|
+
And the exit status should be 0
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
3
|
+
Then /^I should see the usage message$/ do
|
4
|
+
steps %Q{
|
5
|
+
Then the output should contain "Tasks:"
|
6
|
+
Then the output should contain "ahn create"
|
7
|
+
Then the output should contain "ahn start"
|
8
|
+
Then the output should contain "ahn daemon"
|
9
|
+
Then the output should contain "ahn version"
|
10
|
+
Then the output should contain "ahn help"
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# TODO: Remove after pull request is merged in cucumber.rb from Aruba
|
15
|
+
When /^I terminate the interactive process$/ do
|
16
|
+
terminate_processes!
|
17
|
+
end
|
18
|
+
|
19
|
+
When /^I wait (\d+) seconds?$/ do |arg1|
|
20
|
+
sleep arg1.to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
# TODO: Remove after pull request is merged in cucumber.rb from Aruba
|
24
|
+
When /^I wait for (?:output|stdout) to contain "([^"]*)"$/ do |expected|
|
25
|
+
Timeout::timeout(exit_timeout) do
|
26
|
+
loop do
|
27
|
+
break if assert_partial_output_interactive(expected)
|
28
|
+
sleep 0.1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Given /^that I create a valid app under "([^"]*)"$/ do |path|
|
34
|
+
steps %Q{
|
35
|
+
When I run `ahn create #{path}`
|
36
|
+
Then there should be a valid adhearsion directory named "#{path}"
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
Then /^there should be a valid adhearsion directory named "([^"]*)"$/ do |path|
|
41
|
+
steps %Q{
|
42
|
+
Then a directory named "#{path}" should exist
|
43
|
+
}
|
44
|
+
|
45
|
+
cd(path)
|
46
|
+
steps %Q{
|
47
|
+
Then the following directories should exist:
|
48
|
+
| lib |
|
49
|
+
| config |
|
50
|
+
Then the following files should exist:
|
51
|
+
| Gemfile |
|
52
|
+
| README.md |
|
53
|
+
| Rakefile |
|
54
|
+
| config/adhearsion.rb |
|
55
|
+
| config/environment.rb |
|
56
|
+
}
|
57
|
+
|
58
|
+
## NOTE: Aruba's cd method is not really changing directories
|
59
|
+
## Either we use cd or we need absolute path... could not figure out cleaner
|
60
|
+
## way to get back to previous dir.
|
61
|
+
dotsback=1.upto(path.split(File::SEPARATOR)[0..-1].count).collect {|x| ".."}.join(File::SEPARATOR)
|
62
|
+
dotsback.shift if dotsback[0].is_a?(String) and dotsback[0].empty?
|
63
|
+
cd(dotsback)
|
64
|
+
end
|
65
|
+
|
66
|
+
When /^I terminate the process using the pid file "([^"]*)"$/ do |pidfile|
|
67
|
+
check_file_presence([pidfile], true)
|
68
|
+
prep_for_fs_check do
|
69
|
+
pid = File.read(pidfile).to_i
|
70
|
+
Process.kill("TERM", pid)
|
71
|
+
sleep 1
|
72
|
+
Process.kill("KILL", pid)
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Aruba
|
2
|
+
module Api
|
3
|
+
# output() blocks for stderr and stdout it seems
|
4
|
+
def assert_partial_output_interactive(expected)
|
5
|
+
unescape(_read_interactive).include?(unescape(expected)) ? true : false
|
6
|
+
end
|
7
|
+
|
8
|
+
def _read_interactive
|
9
|
+
@interactive.read_stdout(@aruba_keep_ansi)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Process
|
14
|
+
def read_stdout(keep_ansi)
|
15
|
+
wait_for_io do
|
16
|
+
@process.io.stdout.flush
|
17
|
+
content = filter_ansi(open(@out.path).read, keep_ansi)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'simplecov-rcov'
|
3
|
+
class SimpleCov::Formatter::MergedFormatter
|
4
|
+
def format(result)
|
5
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
6
|
+
SimpleCov::Formatter::RcovFormatter.new.format(result)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter "/vendor/"
|
12
|
+
end
|
13
|
+
|
14
|
+
JRUBY_OPTS_SAVED=ENV['JRUBY_OPTS']
|
15
|
+
JAVA_OPTS_SAVED=ENV['JAVA_OPTS']
|
16
|
+
|
17
|
+
require 'cucumber'
|
18
|
+
require 'aruba/cucumber'
|
19
|
+
require 'adhearsion'
|
20
|
+
|
21
|
+
Before do
|
22
|
+
@aruba_timeout_seconds = ENV['ARUBA_TIMEOUT'] || RUBY_PLATFORM == 'java' ? 60 : 30
|
23
|
+
end
|
24
|
+
|
25
|
+
# TODO: check for name space / run issues
|
26
|
+
# NOTE: this will not stop a forked process (eg. daemon mode)
|
27
|
+
After do
|
28
|
+
terminate_processes!
|
29
|
+
end
|
30
|
+
|
31
|
+
# Aruba upstream overwrites these variables so set them here until it is fixed.
|
32
|
+
Aruba.configure do |config|
|
33
|
+
config.before_cmd do |cmd|
|
34
|
+
set_env('JRUBY_OPTS', "#{ENV['JRUBY_OPTS']} #{JRUBY_OPTS_SAVED}")
|
35
|
+
set_env('JAVA_OPTS', "#{ENV['JAVA_OPTS']} #{JAVA_OPTS_SAVED}")
|
36
|
+
end
|
37
|
+
end if RUBY_PLATFORM == 'java'
|
data/lib/adhearsion.rb
CHANGED
@@ -1,46 +1,90 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
require
|
19
|
-
require 'adhearsion/initializer/configuration'
|
20
|
-
require 'adhearsion/initializer'
|
21
|
-
require 'adhearsion/voip/dsl/numerical_string'
|
22
|
-
require 'adhearsion/voip/dsl/dialplan/parser'
|
23
|
-
require 'adhearsion/voip/commands'
|
24
|
-
require 'adhearsion/voip/asterisk/commands'
|
25
|
-
require 'adhearsion/voip/dsl/dialing_dsl'
|
26
|
-
require 'adhearsion/voip/call_routing'
|
27
|
-
|
28
|
-
begin
|
29
|
-
# Try ActiveSupport >= 2.3.0
|
30
|
-
require 'active_support/all'
|
31
|
-
rescue LoadError
|
32
|
-
# Assume ActiveSupport < 2.3.0
|
33
|
-
require 'active_support'
|
34
|
-
end
|
1
|
+
abort "ERROR: You are running Adhearsion on an unsupported version of Ruby (Ruby #{RUBY_VERSION} #{RUBY_RELEASE_DATE})! Please upgrade to at least Ruby v1.9.2, JRuby 1.6.5 or Rubinius 2.0." if RUBY_VERSION < "1.9.2"
|
2
|
+
|
3
|
+
%w{
|
4
|
+
bundler/setup
|
5
|
+
|
6
|
+
active_support/all
|
7
|
+
uuid
|
8
|
+
future-resource
|
9
|
+
punchblock
|
10
|
+
ostruct
|
11
|
+
ruby_speech
|
12
|
+
countdownlatch
|
13
|
+
has_guarded_handlers
|
14
|
+
girl_friday
|
15
|
+
loquacious
|
16
|
+
|
17
|
+
adhearsion/foundation/all
|
18
|
+
}.each { |f| require f }
|
35
19
|
|
36
20
|
module Adhearsion
|
37
|
-
|
38
|
-
|
39
|
-
|
21
|
+
extend ActiveSupport::Autoload
|
22
|
+
|
23
|
+
autoload :Process
|
24
|
+
autoload :Call
|
25
|
+
autoload :CallController
|
26
|
+
autoload :Calls
|
27
|
+
autoload :Configuration
|
28
|
+
autoload :Console
|
29
|
+
autoload :Conveniences
|
30
|
+
autoload :DialplanController
|
31
|
+
autoload :Dispatcher
|
32
|
+
autoload :Events
|
33
|
+
autoload :MenuDSL
|
34
|
+
autoload :Initializer
|
35
|
+
autoload :Logging
|
36
|
+
autoload :OutboundCall
|
37
|
+
autoload :Plugin
|
38
|
+
autoload :Router
|
39
|
+
autoload :Version
|
40
|
+
|
41
|
+
class << self
|
42
|
+
|
43
|
+
def ahn_root=(path)
|
44
|
+
Adhearsion.config[:platform].root = path.nil? ? nil : File.expand_path(path)
|
45
|
+
end
|
46
|
+
|
47
|
+
def config(&block)
|
48
|
+
@config ||= initialize_config
|
49
|
+
block_given? and yield @config
|
50
|
+
@config
|
51
|
+
end
|
52
|
+
|
53
|
+
def initialize_config
|
54
|
+
_config = Configuration.new
|
55
|
+
env = ENV['AHN_ENV']
|
56
|
+
env = nil unless _config.valid_environment? env
|
57
|
+
_config.platform.environment = env if env
|
58
|
+
_config
|
59
|
+
end
|
60
|
+
|
61
|
+
def environments
|
62
|
+
config.valid_environments
|
63
|
+
end
|
64
|
+
|
65
|
+
def config=(config)
|
66
|
+
@config = config
|
67
|
+
end
|
68
|
+
|
69
|
+
def router(&block)
|
70
|
+
@router ||= Router.new(&block || Proc.new {})
|
71
|
+
end
|
72
|
+
|
73
|
+
def router=(other)
|
74
|
+
@router = other
|
75
|
+
end
|
76
|
+
|
77
|
+
def active_calls
|
78
|
+
@calls ||= Calls.new
|
79
|
+
end
|
40
80
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
81
|
+
def status
|
82
|
+
Adhearsion::Process.state_name
|
83
|
+
end
|
84
|
+
end
|
45
85
|
|
86
|
+
Hangup = Class.new StandardError # At the moment, we'll just use this to end a call-handling Thread
|
87
|
+
PlaybackError = Class.new StandardError # Represents failure to play audio, such as when the sound file cannot be found
|
88
|
+
RecordError = Class.new StandardError # Represents failure to record such as when a file cannot be written.
|
89
|
+
ConfigurationError = Class.new StandardError # Error raised while trying to configure a non existent plugin
|
46
90
|
end
|