sevenscale-adhearsion 0.7.1003 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +8 -2
- data/EVENTS +11 -0
- data/Rakefile +92 -26
- data/adhearsion.gemspec +131 -23
- data/app_generators/ahn/ahn_generator.rb +21 -7
- data/app_generators/ahn/templates/.ahnrc +10 -4
- data/app_generators/ahn/templates/Rakefile +7 -2
- data/app_generators/ahn/templates/components/ami_remote/ami_remote.rb +15 -0
- data/app_generators/ahn/templates/components/disabled/HOW_TO_ENABLE +7 -0
- data/app_generators/ahn/templates/components/disabled/stomp_gateway/README.markdown +47 -0
- data/app_generators/ahn/templates/components/disabled/stomp_gateway/config.yml +12 -0
- data/app_generators/ahn/templates/components/disabled/stomp_gateway/stomp_gateway.rb +34 -0
- data/app_generators/ahn/templates/components/simon_game/{lib/simon_game.rb → simon_game.rb} +14 -19
- data/app_generators/ahn/templates/config/startup.rb +3 -6
- data/app_generators/ahn/templates/dialplan.rb +2 -3
- data/app_generators/ahn/templates/events.rb +32 -6
- data/bin/jahn +10 -0
- data/examples/asterisk_manager_interface/standalone.rb +51 -0
- data/lib/adhearsion/cli.rb +140 -23
- data/lib/adhearsion/component_manager/component_tester.rb +55 -0
- data/lib/adhearsion/component_manager/spec_framework.rb +24 -0
- data/lib/adhearsion/component_manager.rb +169 -238
- data/lib/adhearsion/events_support.rb +59 -237
- data/lib/adhearsion/{core_extensions → foundation}/all.rb +0 -0
- data/lib/adhearsion/{blank_slate.rb → foundation/blank_slate.rb} +0 -0
- data/lib/adhearsion/{core_extensions → foundation}/custom_daemonizer.rb +0 -0
- data/lib/adhearsion/foundation/event_socket.rb +203 -0
- data/lib/adhearsion/foundation/future_resource.rb +36 -0
- data/lib/adhearsion/{core_extensions → foundation}/global.rb +0 -0
- data/lib/adhearsion/{core_extensions → foundation}/metaprogramming.rb +0 -0
- data/lib/adhearsion/foundation/numeric.rb +13 -0
- data/lib/adhearsion/foundation/pseudo_guid.rb +10 -0
- data/lib/adhearsion/{core_extensions → foundation}/relationship_properties.rb +2 -0
- data/lib/adhearsion/foundation/string.rb +26 -0
- data/lib/adhearsion/foundation/synchronized_hash.rb +96 -0
- data/lib/adhearsion/{core_extensions → foundation}/thread_safety.rb +0 -0
- data/lib/adhearsion/host_definitions.rb +5 -1
- data/lib/adhearsion/initializer/asterisk.rb +33 -11
- data/lib/adhearsion/initializer/configuration.rb +58 -6
- data/lib/adhearsion/initializer/database.rb +3 -46
- data/lib/adhearsion/initializer/drb.rb +9 -3
- data/lib/adhearsion/initializer/freeswitch.rb +3 -3
- data/lib/adhearsion/initializer/rails.rb +1 -1
- data/lib/adhearsion/initializer.rb +213 -87
- data/lib/adhearsion/tasks/deprecations.rb +59 -0
- data/lib/adhearsion/tasks.rb +2 -1
- data/lib/adhearsion/version.rb +3 -3
- data/lib/adhearsion/voip/asterisk/agi_server.rb +6 -6
- data/lib/adhearsion/voip/asterisk/commands.rb +100 -2
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb +1754 -0
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb +286 -0
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb +78 -0
- data/lib/adhearsion/voip/asterisk/manager_interface/ami_protocol_lexer_machine.rl +87 -0
- data/lib/adhearsion/voip/asterisk/manager_interface.rb +562 -0
- data/lib/adhearsion/voip/asterisk/super_manager.rb +19 -0
- data/lib/adhearsion/voip/asterisk.rb +1 -8
- data/lib/adhearsion/voip/call.rb +5 -1
- data/lib/adhearsion/voip/dial_plan.rb +74 -61
- data/lib/adhearsion/voip/dsl/dialing_dsl.rb +1 -1
- data/lib/adhearsion/voip/dsl/dialplan/parser.rb +2 -6
- data/lib/adhearsion/voip/dsl/numerical_string.rb +2 -2
- data/lib/adhearsion/voip/freeswitch/oes_server.rb +2 -2
- data/lib/adhearsion.rb +16 -11
- data/lib/theatre/README.markdown +64 -0
- data/lib/theatre/callback_definition_loader.rb +84 -0
- data/lib/theatre/guid.rb +23 -0
- data/lib/theatre/invocation.rb +121 -0
- data/lib/theatre/namespace_manager.rb +153 -0
- data/lib/theatre/version.rb +2 -0
- data/lib/theatre.rb +151 -0
- metadata +60 -147
- data/Manifest.txt +0 -151
- data/README.txt +0 -5
- data/ahn_generators/component/USAGE +0 -5
- data/ahn_generators/component/component_generator.rb +0 -57
- data/ahn_generators/component/templates/configuration.rb +0 -0
- data/ahn_generators/component/templates/lib/lib.rb.erb +0 -3
- data/ahn_generators/component/templates/test/test.rb.erb +0 -12
- data/ahn_generators/component/templates/test/test_helper.rb +0 -14
- data/app_generators/ahn/templates/components/simon_game/configuration.rb +0 -0
- data/app_generators/ahn/templates/components/simon_game/test/test_helper.rb +0 -14
- data/app_generators/ahn/templates/components/simon_game/test/test_simon_game.rb +0 -31
- data/lib/adhearsion/core_extensions/array.rb +0 -0
- data/lib/adhearsion/core_extensions/guid.rb +0 -5
- data/lib/adhearsion/core_extensions/hash.rb +0 -0
- data/lib/adhearsion/core_extensions/numeric.rb +0 -4
- data/lib/adhearsion/core_extensions/proc.rb +0 -0
- data/lib/adhearsion/core_extensions/pseudo_uuid.rb +0 -11
- data/lib/adhearsion/core_extensions/publishable.rb +0 -73
- data/lib/adhearsion/core_extensions/string.rb +0 -26
- data/lib/adhearsion/core_extensions/thread.rb +0 -13
- data/lib/adhearsion/core_extensions/time.rb +0 -0
- data/lib/adhearsion/distributed/gateways/dbus_gateway.rb +0 -0
- data/lib/adhearsion/distributed/gateways/osa_gateway.rb +0 -0
- data/lib/adhearsion/distributed/gateways/rest_gateway.rb +0 -9
- data/lib/adhearsion/distributed/gateways/soap_gateway.rb +0 -9
- data/lib/adhearsion/distributed/gateways/xmlrpc_gateway.rb +0 -9
- data/lib/adhearsion/distributed/peer_finder.rb +0 -0
- data/lib/adhearsion/distributed/remote_cli.rb +0 -0
- data/lib/adhearsion/hooks.rb +0 -57
- data/lib/adhearsion/initializer/paths.rb +0 -55
- data/lib/adhearsion/voip/asterisk/ami/actions.rb +0 -238
- data/lib/adhearsion/voip/asterisk/ami/machine.rb +0 -871
- data/lib/adhearsion/voip/asterisk/ami/machine.rl +0 -109
- data/lib/adhearsion/voip/asterisk/ami/parser.rb +0 -262
- data/lib/adhearsion/voip/asterisk/ami.rb +0 -147
- data/spec/fixtures/dialplan.rb +0 -3
- data/spec/initializer/test_configuration.rb +0 -267
- data/spec/initializer/test_loading.rb +0 -162
- data/spec/initializer/test_paths.rb +0 -43
- data/spec/sample.rb +0 -9
- data/spec/silence.rb +0 -10
- data/spec/test_ahn_command.rb +0 -149
- data/spec/test_code_quality.rb +0 -87
- data/spec/test_component_manager.rb +0 -97
- data/spec/test_constants.rb +0 -8
- data/spec/test_drb.rb +0 -104
- data/spec/test_events.rb +0 -136
- data/spec/test_helper.rb +0 -106
- data/spec/test_hooks.rb +0 -15
- data/spec/test_host_definitions.rb +0 -79
- data/spec/test_initialization.rb +0 -124
- data/spec/test_logging.rb +0 -80
- data/spec/test_relationship_properties.rb +0 -54
- data/spec/voip/asterisk/ami_response_definitions.rb +0 -23
- data/spec/voip/asterisk/config_file_generators/test_agents.rb +0 -253
- data/spec/voip/asterisk/config_file_generators/test_queues.rb +0 -325
- data/spec/voip/asterisk/config_file_generators/test_voicemail.rb +0 -306
- data/spec/voip/asterisk/menu_command/test_calculated_match.rb +0 -111
- data/spec/voip/asterisk/menu_command/test_matchers.rb +0 -98
- data/spec/voip/asterisk/mock_ami_server.rb +0 -176
- data/spec/voip/asterisk/test_agi_server.rb +0 -453
- data/spec/voip/asterisk/test_ami.rb +0 -227
- data/spec/voip/asterisk/test_commands.rb +0 -2006
- data/spec/voip/asterisk/test_config_manager.rb +0 -129
- data/spec/voip/dsl/dispatcher_spec_helper.rb +0 -45
- data/spec/voip/dsl/test_dialing_dsl.rb +0 -268
- data/spec/voip/dsl/test_dispatcher.rb +0 -82
- data/spec/voip/dsl/test_parser.rb +0 -87
- data/spec/voip/freeswitch/test_basic_connection_manager.rb +0 -39
- data/spec/voip/freeswitch/test_inbound_connection_manager.rb +0 -39
- data/spec/voip/freeswitch/test_oes_server.rb +0 -9
- data/spec/voip/test_call_routing.rb +0 -127
- data/spec/voip/test_dialplan_manager.rb +0 -442
- data/spec/voip/test_numerical_string.rb +0 -48
- data/spec/voip/test_phone_number.rb +0 -36
- data/test/test_ahn_generator.rb +0 -59
- data/test/test_component_generator.rb +0 -52
- data/test/test_generator_helper.rb +0 -20
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
-
|
1
|
+
0.8.0 rev 2
|
2
|
+
- Added a few non-critical files to the .gemspec. They were ignored
|
2
3
|
|
3
|
-
|
4
|
+
Notes from before 0.8.0:
|
5
|
+
- (NOTE: This is obviously not a comprehensive list of pre-0.8.0 work. 0.8.0 was a complete rewrite of the previous version)
|
6
|
+
- Adding a deprecation warning about Fixnum#digit and Fixnum#digits
|
7
|
+
- Removed the AMI class and replaced it with the ManagerInterface class.
|
8
|
+
- The old AMI high-level instance methods are available in the new ManagerInterface class, but a deprecation warning will be logged each time they're used. When the SuperManager class is implemented, they'll be removed entirely.
|
9
|
+
- Moved Theatre into Adhearsion's lib folder.
|
data/EVENTS
ADDED
data/Rakefile
CHANGED
@@ -2,53 +2,119 @@
|
|
2
2
|
ENV['RUBY_FLAGS'] = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require '
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
abort "You must install RSpec: sudo gem install rspec"
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'yard'
|
15
|
+
YARD::Rake::YardocTask.new do |t|
|
16
|
+
t.files = ['lib/**/*.rb'] + %w[README.markdown TODO.markdown LICENSE]
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
STDERR.puts "\nCould not require() YARD! Install with 'gem install yard' to get the 'yardoc' task\n\n"
|
20
|
+
end
|
21
|
+
|
6
22
|
require 'lib/adhearsion/version'
|
7
|
-
|
23
|
+
|
24
|
+
AHN_TESTS = ['spec/**/test_*.rb']
|
25
|
+
GEMSPEC = eval File.read("adhearsion.gemspec")
|
26
|
+
RAGEL_FILES = %w[lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb]
|
27
|
+
THEATRE_TESTS = 'theatre-spec/**/*_spec.rb'
|
8
28
|
|
9
29
|
begin
|
10
30
|
require 'rcov/rcovtask'
|
11
31
|
Rcov::RcovTask.new do |t|
|
12
|
-
t.test_files = Dir[
|
32
|
+
t.test_files = Dir[*AHN_TESTS]
|
13
33
|
t.output_dir = 'coverage'
|
14
34
|
t.verbose = true
|
15
35
|
t.rcov_opts.concat %w[--sort coverage --sort-reverse -x gems -x /var --no-validator-links]
|
16
36
|
end
|
17
37
|
rescue LoadError
|
18
|
-
STDERR.puts "Could not load rcov tasks -- rcov does not appear to be installed."
|
38
|
+
STDERR.puts "Could not load rcov tasks -- rcov does not appear to be installed. Continuing anyway."
|
19
39
|
end
|
20
40
|
|
21
|
-
|
22
|
-
|
23
|
-
task :test do
|
24
|
-
STDERR.puts "\nTry using \"rake spec\" for something less noisy.\n\n"
|
25
|
-
# The other :test task is created by Hoe below.
|
26
|
-
end
|
41
|
+
Rake::GemPackageTask.new(GEMSPEC).define
|
27
42
|
|
28
43
|
# YARD::Rake::YardocTask.new do |t|
|
29
44
|
# t.files = ['lib/**/*.rb'] # optional
|
30
45
|
# # t.options = ['--any', '--extra', '--opts'] # optional
|
31
46
|
# end
|
32
47
|
|
33
|
-
|
34
|
-
Hoe.new('adhearsion', Adhearsion::VERSION::STRING) do |p|
|
35
|
-
p.rubyforge_name = 'adhearsion'
|
36
|
-
p.author = 'Jay Phillips'
|
37
|
-
p.email = 'Jay -at- Codemecca.com'
|
38
|
-
p.summary = 'Adhearsion, open-source telephony integrator.'
|
39
|
-
p.description = "Adhearsion is an open-source VoIP development framework written in Ruby"
|
40
|
-
p.url = "http://adhearsion.com"
|
41
|
-
p.changes = "" # Removed because History.txt is tedious.
|
42
|
-
p.test_globs = TestGlob
|
43
|
-
p.extra_deps = [['rubigen', '>=1.0.6'], ['log4r', '>=1.0.5']]
|
44
|
-
end
|
45
|
-
|
48
|
+
desc "Run the unit tests for Adhearsion"
|
46
49
|
task :spec do
|
47
|
-
Dir[*
|
50
|
+
Dir[*AHN_TESTS].each do |file|
|
48
51
|
load file
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
52
|
-
|
53
|
-
|
55
|
+
desc "Check Ragel version"
|
56
|
+
task :check_ragel_version do
|
57
|
+
ragel_version_match = `ragel --version`.match(/(\d)\.(\d)+/)
|
58
|
+
abort "Could not get Ragel version! Is it installed? You must have at least version 6.3" unless ragel_version_match
|
59
|
+
big, small = ragel_version_match.captures.map { |n| n.to_i }
|
60
|
+
if big < 6 || (big == 6 && small < 3)
|
61
|
+
abort "Please upgrade Ragel! You're on version #{ragel_version_match[0]} and must be on 6.3 or later"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Used to regenerate the AMI source code files. Note: requires Ragel 6.3 or later be installed on your system"
|
66
|
+
task :ragel => :check_ragel_version do
|
67
|
+
RAGEL_FILES.each do |ragel_file|
|
68
|
+
ruby_file = ragel_file.sub(".rl.rb", ".rb")
|
69
|
+
puts `ragel -n -R #{ragel_file} -o #{ruby_file} 2>&1`
|
70
|
+
raise "Failed generating code from Ragel file #{ragel_file}" if $?.to_i.nonzero?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "Generates a GraphVis document showing the Ragel state machine"
|
75
|
+
task :visualize_ragel => :check_ragel_version do
|
76
|
+
RAGEL_FILES.each do |ragel_file|
|
77
|
+
base_name = File.basename ragel_file, ".rl.rb"
|
78
|
+
puts "ragel -V #{ragel_file} -o #{base_name}.dot 2>&1"
|
79
|
+
puts `ragel -V #{ragel_file} -o #{base_name}.dot 2>&1`
|
80
|
+
raise "Failed generating code from Ragel file #{ragel_file}" if $?.to_i.nonzero?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "Run all RSpecs for Theatre"
|
85
|
+
Spec::Rake::SpecTask.new("theatre_specs") do |t|
|
86
|
+
t.spec_files = FileList[THEATRE_TESTS]
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Compares Adhearsion's files with those listed in adhearsion.gemspec"
|
90
|
+
task :check_gemspec_files do
|
91
|
+
|
92
|
+
files_from_gemspec = ADHEARSION_FILES
|
93
|
+
files_from_filesystem = Dir.glob(File.dirname(__FILE__) + "/**/*").map do |filename|
|
94
|
+
filename[0...Dir.pwd.length] == Dir.pwd ? filename[(Dir.pwd.length+1)..-1] : filename
|
95
|
+
end
|
96
|
+
files_from_filesystem.reject! { |f| File.directory? f }
|
97
|
+
|
98
|
+
puts
|
99
|
+
puts 'Pipe this command to "grep -v \'spec/\' | grep -v test" to ignore test files'
|
100
|
+
puts
|
101
|
+
puts '##########################################'
|
102
|
+
puts '## Files on filesystem not in the gemspec:'
|
103
|
+
puts '##########################################'
|
104
|
+
puts((files_from_filesystem - files_from_gemspec).map { |f| " " + f })
|
105
|
+
|
106
|
+
|
107
|
+
puts '##########################################'
|
108
|
+
puts '## Files in gemspec not in the filesystem:'
|
109
|
+
puts '##########################################'
|
110
|
+
puts((files_from_gemspec - files_from_filesystem).map { |f| " " + f })
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "Test that the .gemspec file executes"
|
114
|
+
task :debug_gem do
|
115
|
+
require 'rubygems/specification'
|
116
|
+
gemspec = File.read('adhearsion.gemspec')
|
117
|
+
spec = nil
|
118
|
+
Thread.new { spec = eval("$SAFE = 3\n#{gemspec}") }.join
|
119
|
+
puts "SUCCESS: Gemspec runs at the $SAFE level 3."
|
54
120
|
end
|
data/adhearsion.gemspec
CHANGED
@@ -1,40 +1,148 @@
|
|
1
|
+
ADHEARSION_FILES = %w{
|
2
|
+
adhearsion.gemspec
|
3
|
+
app_generators/ahn/ahn_generator.rb
|
4
|
+
app_generators/ahn/templates/.ahnrc
|
5
|
+
app_generators/ahn/templates/components/ami_remote/ami_remote.rb
|
6
|
+
app_generators/ahn/templates/components/disabled/HOW_TO_ENABLE
|
7
|
+
app_generators/ahn/templates/components/disabled/stomp_gateway/config.yml
|
8
|
+
app_generators/ahn/templates/components/disabled/stomp_gateway/README.markdown
|
9
|
+
app_generators/ahn/templates/components/disabled/stomp_gateway/stomp_gateway.rb
|
10
|
+
app_generators/ahn/templates/components/restful_rpc/config.yml
|
11
|
+
app_generators/ahn/templates/components/restful_rpc/example-client.rb
|
12
|
+
app_generators/ahn/templates/components/restful_rpc/README.markdown
|
13
|
+
app_generators/ahn/templates/components/restful_rpc/restful_rpc.rb
|
14
|
+
app_generators/ahn/templates/components/restful_rpc/spec/restful_rpc_spec.rb
|
15
|
+
app_generators/ahn/templates/components/simon_game/simon_game.rb
|
16
|
+
app_generators/ahn/templates/config/startup.rb
|
17
|
+
app_generators/ahn/templates/dialplan.rb
|
18
|
+
app_generators/ahn/templates/events.rb
|
19
|
+
app_generators/ahn/templates/Rakefile
|
20
|
+
app_generators/ahn/templates/README
|
21
|
+
app_generators/ahn/USAGE
|
22
|
+
bin/ahn
|
23
|
+
bin/ahnctl
|
24
|
+
bin/jahn
|
25
|
+
CHANGELOG
|
26
|
+
EVENTS
|
27
|
+
examples/asterisk_manager_interface/standalone.rb
|
28
|
+
lib/adhearsion.rb
|
29
|
+
lib/adhearsion/cli.rb
|
30
|
+
lib/adhearsion/component_manager.rb
|
31
|
+
lib/adhearsion/component_manager/component_tester.rb
|
32
|
+
lib/adhearsion/component_manager/spec_framework.rb
|
33
|
+
lib/adhearsion/events_support.rb
|
34
|
+
lib/adhearsion/foundation/all.rb
|
35
|
+
lib/adhearsion/foundation/blank_slate.rb
|
36
|
+
lib/adhearsion/foundation/custom_daemonizer.rb
|
37
|
+
lib/adhearsion/foundation/event_socket.rb
|
38
|
+
lib/adhearsion/foundation/future_resource.rb
|
39
|
+
lib/adhearsion/foundation/global.rb
|
40
|
+
lib/adhearsion/foundation/metaprogramming.rb
|
41
|
+
lib/adhearsion/foundation/numeric.rb
|
42
|
+
lib/adhearsion/foundation/pseudo_guid.rb
|
43
|
+
lib/adhearsion/foundation/relationship_properties.rb
|
44
|
+
lib/adhearsion/foundation/string.rb
|
45
|
+
lib/adhearsion/foundation/synchronized_hash.rb
|
46
|
+
lib/adhearsion/foundation/thread_safety.rb
|
47
|
+
lib/adhearsion/host_definitions.rb
|
48
|
+
lib/adhearsion/initializer.rb
|
49
|
+
lib/adhearsion/initializer/asterisk.rb
|
50
|
+
lib/adhearsion/initializer/configuration.rb
|
51
|
+
lib/adhearsion/initializer/database.rb
|
52
|
+
lib/adhearsion/initializer/drb.rb
|
53
|
+
lib/adhearsion/initializer/freeswitch.rb
|
54
|
+
lib/adhearsion/initializer/rails.rb
|
55
|
+
lib/adhearsion/logging.rb
|
56
|
+
lib/adhearsion/tasks.rb
|
57
|
+
lib/adhearsion/tasks/database.rb
|
58
|
+
lib/adhearsion/tasks/deprecations.rb
|
59
|
+
lib/adhearsion/tasks/generating.rb
|
60
|
+
lib/adhearsion/tasks/lint.rb
|
61
|
+
lib/adhearsion/tasks/testing.rb
|
62
|
+
lib/adhearsion/version.rb
|
63
|
+
lib/adhearsion/voip/asterisk.rb
|
64
|
+
lib/adhearsion/voip/asterisk/agi_server.rb
|
65
|
+
lib/adhearsion/voip/asterisk/commands.rb
|
66
|
+
lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb
|
67
|
+
lib/adhearsion/voip/asterisk/config_generators/config_generator.rb
|
68
|
+
lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb
|
69
|
+
lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb
|
70
|
+
lib/adhearsion/voip/asterisk/config_manager.rb
|
71
|
+
lib/adhearsion/voip/asterisk/manager_interface.rb
|
72
|
+
lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb
|
73
|
+
lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rl.rb
|
74
|
+
lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb
|
75
|
+
lib/adhearsion/voip/asterisk/manager_interface/ami_protocol_lexer_machine.rl
|
76
|
+
lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb
|
77
|
+
lib/adhearsion/voip/asterisk/super_manager.rb
|
78
|
+
lib/adhearsion/voip/call.rb
|
79
|
+
lib/adhearsion/voip/call_routing.rb
|
80
|
+
lib/adhearsion/voip/commands.rb
|
81
|
+
lib/adhearsion/voip/constants.rb
|
82
|
+
lib/adhearsion/voip/conveniences.rb
|
83
|
+
lib/adhearsion/voip/dial_plan.rb
|
84
|
+
lib/adhearsion/voip/dsl/dialing_dsl.rb
|
85
|
+
lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb
|
86
|
+
lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb
|
87
|
+
lib/adhearsion/voip/dsl/dialplan/dispatcher.rb
|
88
|
+
lib/adhearsion/voip/dsl/dialplan/parser.rb
|
89
|
+
lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb
|
90
|
+
lib/adhearsion/voip/dsl/numerical_string.rb
|
91
|
+
lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
|
92
|
+
lib/adhearsion/voip/freeswitch/event_handler.rb
|
93
|
+
lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb
|
94
|
+
lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb
|
95
|
+
lib/adhearsion/voip/freeswitch/oes_server.rb
|
96
|
+
lib/adhearsion/voip/menu_state_machine/calculated_match.rb
|
97
|
+
lib/adhearsion/voip/menu_state_machine/matchers.rb
|
98
|
+
lib/adhearsion/voip/menu_state_machine/menu_builder.rb
|
99
|
+
lib/adhearsion/voip/menu_state_machine/menu_class.rb
|
100
|
+
lib/theatre.rb
|
101
|
+
lib/theatre/callback_definition_loader.rb
|
102
|
+
lib/theatre/guid.rb
|
103
|
+
lib/theatre/invocation.rb
|
104
|
+
lib/theatre/namespace_manager.rb
|
105
|
+
lib/theatre/README.markdown
|
106
|
+
lib/theatre/version.rb
|
107
|
+
LICENSE
|
108
|
+
Rakefile
|
109
|
+
README.txt
|
110
|
+
}
|
111
|
+
|
1
112
|
Gem::Specification.new do |s|
|
2
|
-
s.name =
|
3
|
-
s.version = "0.
|
113
|
+
s.name = "adhearsion"
|
114
|
+
s.version = "0.8.0"
|
4
115
|
|
5
116
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
117
|
s.authors = ["Jay Phillips"]
|
7
|
-
|
8
|
-
s.
|
9
|
-
s.
|
118
|
+
|
119
|
+
s.date = "2008-08-21"
|
120
|
+
s.description = "Adhearsion is an open-source telephony development framework"
|
121
|
+
s.email = "Jay -at- Codemecca.com"
|
10
122
|
s.executables = ["ahn", "ahnctl", "jahn"]
|
11
|
-
|
12
|
-
s.files =
|
13
|
-
|
14
|
-
s.
|
15
|
-
s.
|
123
|
+
|
124
|
+
s.files = ADHEARSION_FILES
|
125
|
+
|
126
|
+
s.has_rdoc = false
|
127
|
+
s.homepage = "http://adhearsion.com"
|
16
128
|
s.require_paths = ["lib"]
|
17
|
-
s.rubyforge_project =
|
18
|
-
s.rubygems_version =
|
19
|
-
s.summary =
|
20
|
-
s.test_files = ["spec/initializer/test_configuration.rb", "spec/initializer/test_loading.rb", "spec/initializer/test_paths.rb", "spec/test_ahn_command.rb", "spec/test_code_quality.rb", "spec/test_component_manager.rb", "spec/test_constants.rb", "spec/test_drb.rb", "spec/test_events.rb", "spec/test_helper.rb", "spec/test_hooks.rb", "spec/test_host_definitions.rb", "spec/test_initialization.rb", "spec/test_logging.rb", "spec/test_relationship_properties.rb", "spec/voip/asterisk/config_file_generators/test_agents.rb", "spec/voip/asterisk/config_file_generators/test_queues.rb", "spec/voip/asterisk/config_file_generators/test_voicemail.rb", "spec/voip/asterisk/menu_command/test_calculated_match.rb", "spec/voip/asterisk/menu_command/test_matchers.rb", "spec/voip/asterisk/test_agi_server.rb", "spec/voip/asterisk/test_ami.rb", "spec/voip/asterisk/test_commands.rb", "spec/voip/asterisk/test_config_manager.rb", "spec/voip/dsl/test_dialing_dsl.rb", "spec/voip/dsl/test_dispatcher.rb", "spec/voip/dsl/test_parser.rb", "spec/voip/freeswitch/test_basic_connection_manager.rb", "spec/voip/freeswitch/test_inbound_connection_manager.rb", "spec/voip/freeswitch/test_oes_server.rb", "spec/voip/test_call_routing.rb", "spec/voip/test_dialplan_manager.rb", "spec/voip/test_numerical_string.rb", "spec/voip/test_phone_number.rb"]
|
129
|
+
s.rubyforge_project = "adhearsion"
|
130
|
+
s.rubygems_version = "1.2.0"
|
131
|
+
s.summary = "Adhearsion, open-source telephony development framework"
|
21
132
|
|
22
133
|
if s.respond_to? :specification_version then
|
23
134
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
135
|
s.specification_version = 2
|
25
136
|
|
26
137
|
if current_version >= 3 then
|
27
|
-
s.add_runtime_dependency(
|
28
|
-
s.add_runtime_dependency(
|
29
|
-
s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
|
138
|
+
s.add_runtime_dependency("rubigen", [">= 1.0.6"])
|
139
|
+
s.add_runtime_dependency("log4r", [">= 1.0.5"])
|
30
140
|
else
|
31
|
-
s.add_dependency(
|
32
|
-
s.add_dependency(
|
33
|
-
s.add_dependency(%q<hoe>, [">= 1.7.0"])
|
141
|
+
s.add_dependency("rubigen", [">= 1.0.6"])
|
142
|
+
s.add_dependency("log4r", [">= 1.0.5"])
|
34
143
|
end
|
35
144
|
else
|
36
|
-
s.add_dependency(
|
37
|
-
s.add_dependency(
|
38
|
-
s.add_dependency(%q<hoe>, [">= 1.7.0"])
|
145
|
+
s.add_dependency("rubigen", [">= 1.0.6"])
|
146
|
+
s.add_dependency("log4r", [">= 1.0.5"])
|
39
147
|
end
|
40
148
|
end
|
@@ -24,10 +24,21 @@ class AhnGenerator < RubiGen::Base
|
|
24
24
|
|
25
25
|
m.file *[".ahnrc"]*2
|
26
26
|
|
27
|
-
m.file *["components/simon_game/
|
28
|
-
m.file *["components/
|
29
|
-
|
30
|
-
m.file *["components/
|
27
|
+
m.file *["components/simon_game/simon_game.rb"]*2
|
28
|
+
m.file *["components/ami_remote/ami_remote.rb"]*2
|
29
|
+
|
30
|
+
m.file *["components/disabled/stomp_gateway/stomp_gateway.rb"]*2
|
31
|
+
m.file *["components/disabled/stomp_gateway/config.yml"]*2
|
32
|
+
m.file *["components/disabled/stomp_gateway/README.markdown"]*2
|
33
|
+
|
34
|
+
m.file *["components/disabled/restful_rpc/restful_rpc.rb"]*2
|
35
|
+
m.file *["components/disabled/restful_rpc/config.yml"]*2
|
36
|
+
m.file *["components/disabled/restful_rpc/README.markdown"]*2
|
37
|
+
m.file *["components/disabled/restful_rpc/example-client.rb"]*2
|
38
|
+
m.file *["components/disabled/restful_rpc/spec/restful_rpc_spec.rb"]*2
|
39
|
+
|
40
|
+
m.file *["components/disabled/sandbox/config.yml"]*2
|
41
|
+
m.file *["components/disabled/sandbox/sandbox.rb"]*2
|
31
42
|
|
32
43
|
m.file *["config/startup.rb"]*2
|
33
44
|
m.file *["dialplan.rb"]*2
|
@@ -70,8 +81,11 @@ EOS
|
|
70
81
|
# Installation skeleton. Intermediate directories are automatically
|
71
82
|
# created so don't sweat their absence here.
|
72
83
|
BASEDIRS = %w(
|
73
|
-
components/simon_game
|
74
|
-
components/
|
84
|
+
components/simon_game
|
85
|
+
components/disabled/stomp_gateway
|
86
|
+
components/disabled/sandbox
|
87
|
+
components/ami_remote
|
88
|
+
components/disabled/restful_rpc/spec
|
75
89
|
config
|
76
90
|
)
|
77
|
-
end
|
91
|
+
end
|
@@ -4,11 +4,19 @@
|
|
4
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
5
|
# For example, if a component require()s activerecord, sucking in the latest on the system, and then you enable a Rails app
|
6
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 and
|
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
8
|
gems:
|
9
9
|
# twitter:
|
10
10
|
# hpricot:
|
11
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
|
12
20
|
# activerecord:
|
13
21
|
# version: >= 2.1.0
|
14
22
|
# aasm:
|
@@ -23,6 +31,4 @@ paths:
|
|
23
31
|
|
24
32
|
events: events.rb
|
25
33
|
|
26
|
-
models:
|
27
|
-
directory: models
|
28
|
-
pattern: "*.rb"
|
34
|
+
models: models/*.rb
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'adhearsion'
|
5
|
+
require 'adhearsion/tasks'
|
6
|
+
rescue LoadError
|
7
|
+
STDERR.puts "\nCannot load Adhearsion! Not all Rake tasks will be loaded!\n\n"
|
8
|
+
end
|
4
9
|
|
5
10
|
desc "Writes a .gitignore file that ignores certain SCM annoyances such as log files"
|
6
11
|
task :gitignore do
|
@@ -0,0 +1,15 @@
|
|
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].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
|
@@ -0,0 +1,47 @@
|
|
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 config.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
|
@@ -0,0 +1,12 @@
|
|
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
|
+
# - hangup_call
|
@@ -0,0 +1,34 @@
|
|
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.
|
@@ -1,10 +1,14 @@
|
|
1
|
+
methods_for :dialplan do
|
2
|
+
def simon_game
|
3
|
+
SimonGame.new(self).start
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
1
7
|
class SimonGame
|
2
|
-
add_call_context :as => :call_context
|
3
8
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
initialize_attempt
|
9
|
+
def initialize(call)
|
10
|
+
@call = call
|
11
|
+
reset
|
8
12
|
end
|
9
13
|
|
10
14
|
def start
|
@@ -20,38 +24,29 @@ class SimonGame
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def update_number
|
23
|
-
initialize_attempt
|
24
27
|
@number << random_number
|
25
28
|
end
|
26
29
|
|
27
30
|
def say_number
|
28
31
|
update_number
|
29
|
-
|
32
|
+
@call.say_digits @number
|
30
33
|
end
|
31
34
|
|
32
35
|
def collect_attempt
|
33
|
-
@attempt =
|
36
|
+
@attempt = @call.input @number.length
|
34
37
|
end
|
35
38
|
|
36
39
|
def verify_attempt
|
37
40
|
if attempt_correct?
|
38
|
-
|
41
|
+
@call.play 'good'
|
39
42
|
else
|
40
|
-
|
43
|
+
@call.play %W[#{@number.length-1} times wrong-try-again-smarty]
|
41
44
|
reset
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
45
48
|
def attempt_correct?
|
46
|
-
attempt == number
|
47
|
-
end
|
48
|
-
|
49
|
-
def initialize_attempt
|
50
|
-
@attempt ||= ''
|
51
|
-
end
|
52
|
-
|
53
|
-
def initialize_number
|
54
|
-
@number ||= ''
|
49
|
+
@attempt == @number
|
55
50
|
end
|
56
51
|
|
57
52
|
def reset
|
@@ -26,12 +26,9 @@ Adhearsion::Configuration.configure do |config|
|
|
26
26
|
|
27
27
|
# By default Asterisk is enabled with the default settings
|
28
28
|
config.enable_asterisk
|
29
|
-
# config.asterisk.enable_ami :host => "127.0.0.1", :username => "admin", :password => "password"
|
29
|
+
# config.asterisk.enable_ami :host => "127.0.0.1", :username => "admin", :password => "password", :events => true
|
30
30
|
|
31
|
-
#
|
32
|
-
# config.enable_asterisk :listening_port => 4574, :listening_host => "127.0.0.1"
|
33
|
-
|
34
|
-
# config.enable_drb
|
31
|
+
# config.enable_drb
|
35
32
|
|
36
33
|
# Streamlined Rails integration! The first argument should be a relative or absolute path to
|
37
34
|
# the Rails app folder with which you're integrating. The second argument must be one of the
|
@@ -50,4 +47,4 @@ Adhearsion::Configuration.configure do |config|
|
|
50
47
|
# :host => 'db.example.org'
|
51
48
|
end
|
52
49
|
|
53
|
-
Adhearsion::Initializer.start_from_init_file(__FILE__, File.dirname(__FILE__) + "/..")
|
50
|
+
Adhearsion::Initializer.start_from_init_file(__FILE__, File.dirname(__FILE__) + "/..")
|