sant0sk1-adhearsion 0.7.999
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +456 -0
- data/README.txt +5 -0
- data/Rakefile +75 -0
- data/adhearsion.gemspec +136 -0
- data/app_generators/ahn/USAGE +5 -0
- data/app_generators/ahn/ahn_generator.rb +77 -0
- data/app_generators/ahn/templates/.ahnrc +36 -0
- data/app_generators/ahn/templates/README +8 -0
- data/app_generators/ahn/templates/Rakefile +18 -0
- data/app_generators/ahn/templates/components/simon_game/configuration.rb +0 -0
- data/app_generators/ahn/templates/components/simon_game/lib/simon_game.rb +61 -0
- data/app_generators/ahn/templates/components/simon_game/test/test_helper.rb +14 -0
- data/app_generators/ahn/templates/components/simon_game/test/test_simon_game.rb +31 -0
- data/app_generators/ahn/templates/config/startup.rb +53 -0
- data/app_generators/ahn/templates/dialplan.rb +4 -0
- data/bin/ahn +28 -0
- data/bin/ahnctl +68 -0
- data/bin/jahn +32 -0
- data/lib/adhearsion.rb +32 -0
- data/lib/adhearsion/blank_slate.rb +5 -0
- data/lib/adhearsion/cli.rb +106 -0
- data/lib/adhearsion/component_manager.rb +277 -0
- data/lib/adhearsion/core_extensions/all.rb +9 -0
- data/lib/adhearsion/core_extensions/array.rb +0 -0
- data/lib/adhearsion/core_extensions/custom_daemonizer.rb +45 -0
- data/lib/adhearsion/core_extensions/global.rb +1 -0
- data/lib/adhearsion/core_extensions/hash.rb +0 -0
- data/lib/adhearsion/core_extensions/metaprogramming.rb +17 -0
- data/lib/adhearsion/core_extensions/numeric.rb +4 -0
- data/lib/adhearsion/core_extensions/proc.rb +0 -0
- data/lib/adhearsion/core_extensions/publishable.rb +73 -0
- data/lib/adhearsion/core_extensions/relationship_properties.rb +40 -0
- data/lib/adhearsion/core_extensions/string.rb +26 -0
- data/lib/adhearsion/core_extensions/thread.rb +13 -0
- data/lib/adhearsion/core_extensions/thread_safety.rb +7 -0
- 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 +9 -0
- data/lib/adhearsion/distributed/gateways/soap_gateway.rb +9 -0
- data/lib/adhearsion/distributed/gateways/xmlrpc_gateway.rb +9 -0
- data/lib/adhearsion/distributed/peer_finder.rb +0 -0
- data/lib/adhearsion/distributed/remote_cli.rb +0 -0
- data/lib/adhearsion/events_support.rb +26 -0
- data/lib/adhearsion/hooks.rb +57 -0
- data/lib/adhearsion/host_definitions.rb +63 -0
- data/lib/adhearsion/initializer.rb +246 -0
- data/lib/adhearsion/initializer/asterisk.rb +59 -0
- data/lib/adhearsion/initializer/configuration.rb +236 -0
- data/lib/adhearsion/initializer/database.rb +49 -0
- data/lib/adhearsion/initializer/drb.rb +25 -0
- data/lib/adhearsion/initializer/freeswitch.rb +22 -0
- data/lib/adhearsion/initializer/rails.rb +40 -0
- data/lib/adhearsion/logging.rb +92 -0
- data/lib/adhearsion/tasks.rb +15 -0
- data/lib/adhearsion/tasks/database.rb +5 -0
- data/lib/adhearsion/tasks/generating.rb +20 -0
- data/lib/adhearsion/tasks/lint.rb +4 -0
- data/lib/adhearsion/tasks/testing.rb +37 -0
- data/lib/adhearsion/version.rb +9 -0
- data/lib/adhearsion/voip/asterisk.rb +10 -0
- data/lib/adhearsion/voip/asterisk/agi_server.rb +81 -0
- data/lib/adhearsion/voip/asterisk/ami.rb +147 -0
- data/lib/adhearsion/voip/asterisk/ami/actions.rb +238 -0
- data/lib/adhearsion/voip/asterisk/ami/machine.rb +871 -0
- data/lib/adhearsion/voip/asterisk/ami/machine.rl +109 -0
- data/lib/adhearsion/voip/asterisk/ami/parser.rb +262 -0
- data/lib/adhearsion/voip/asterisk/commands.rb +1284 -0
- data/lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb +140 -0
- data/lib/adhearsion/voip/asterisk/config_generators/config_generator.rb +101 -0
- data/lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb +250 -0
- data/lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb +240 -0
- data/lib/adhearsion/voip/asterisk/config_manager.rb +71 -0
- data/lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb +80 -0
- data/lib/adhearsion/voip/call.rb +436 -0
- data/lib/adhearsion/voip/call_routing.rb +64 -0
- data/lib/adhearsion/voip/commands.rb +9 -0
- data/lib/adhearsion/voip/constants.rb +39 -0
- data/lib/adhearsion/voip/conveniences.rb +18 -0
- data/lib/adhearsion/voip/dial_plan.rb +207 -0
- data/lib/adhearsion/voip/dsl/dialing_dsl.rb +151 -0
- data/lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb +37 -0
- data/lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb +27 -0
- data/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb +124 -0
- data/lib/adhearsion/voip/dsl/dialplan/parser.rb +71 -0
- data/lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb +16 -0
- data/lib/adhearsion/voip/dsl/numerical_string.rb +117 -0
- data/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb +48 -0
- data/lib/adhearsion/voip/freeswitch/event_handler.rb +58 -0
- data/lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb +129 -0
- data/lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb +38 -0
- data/lib/adhearsion/voip/freeswitch/oes_server.rb +195 -0
- data/lib/adhearsion/voip/menu_state_machine/calculated_match.rb +80 -0
- data/lib/adhearsion/voip/menu_state_machine/matchers.rb +123 -0
- data/lib/adhearsion/voip/menu_state_machine/menu_builder.rb +58 -0
- data/lib/adhearsion/voip/menu_state_machine/menu_class.rb +149 -0
- metadata +167 -0
data/README.txt
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Adhearsion
|
2
|
+
by Jay Phillips, et. al
|
3
|
+
http://adhearsion.com
|
4
|
+
|
5
|
+
Adhearsion is an open-source framework written in Ruby designed to vastly improve Voice over IP development. It rests atop established telephony platforms (such as Asterisk and Freeswitch) and abstracts their complexity with the beauty of a well-designed, high-level suite of solutions.
|
data/Rakefile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
ENV['RUBY_FLAGS'] = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
|
3
|
+
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'rubygems'
|
6
|
+
|
7
|
+
require 'lib/adhearsion/version'
|
8
|
+
|
9
|
+
TestGlob = ['spec/**/test_*.rb']
|
10
|
+
|
11
|
+
GEMSPEC = eval File.read("adhearsion.gemspec")
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'rcov/rcovtask'
|
15
|
+
Rcov::RcovTask.new do |t|
|
16
|
+
t.test_files = Dir[*TestGlob]
|
17
|
+
t.output_dir = 'coverage'
|
18
|
+
t.verbose = true
|
19
|
+
t.rcov_opts.concat %w[--sort coverage --sort-reverse -x gems -x /var --no-validator-links]
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
STDERR.puts "Could not load rcov tasks -- rcov does not appear to be installed. Continuing anyway."
|
23
|
+
end
|
24
|
+
|
25
|
+
Rake::GemPackageTask.new(GEMSPEC).define
|
26
|
+
|
27
|
+
# YARD::Rake::YardocTask.new do |t|
|
28
|
+
# t.files = ['lib/**/*.rb'] # optional
|
29
|
+
# # t.options = ['--any', '--extra', '--opts'] # optional
|
30
|
+
# end
|
31
|
+
|
32
|
+
desc "Run the unit tests for Adhearsion"
|
33
|
+
task :spec do
|
34
|
+
Dir[*TestGlob].each do |file|
|
35
|
+
load file
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Used to regenerate the AMI source code files"
|
40
|
+
task :ragel do
|
41
|
+
`ragel -n -R lib/adhearsion/voip/asterisk/ami/machine.rl | rlgen-ruby -o lib/adhearsion/voip/asterisk/ami/machine.rb`
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Compares Adhearsion's files with those listed in adhearsion.gemspec"
|
45
|
+
task :check_gemspec_files do
|
46
|
+
|
47
|
+
files_from_gemspec = ADHEARSION_FILES
|
48
|
+
files_from_filesystem = Dir.glob(File.dirname(__FILE__) + "/**/*").map do |filename|
|
49
|
+
filename[0...Dir.pwd.length] == Dir.pwd ? filename[(Dir.pwd.length+1)..-1] : filename
|
50
|
+
end
|
51
|
+
files_from_filesystem.reject! { |f| File.directory? f }
|
52
|
+
|
53
|
+
puts
|
54
|
+
puts 'Pipe this command to "grep -v \'spec/\' | grep -v test" to ignore test files'
|
55
|
+
puts
|
56
|
+
puts '##########################################'
|
57
|
+
puts '## Files on filesystem not in the gemspec:'
|
58
|
+
puts '##########################################'
|
59
|
+
puts((files_from_filesystem - files_from_gemspec).map { |f| " " + f })
|
60
|
+
|
61
|
+
|
62
|
+
puts '##########################################'
|
63
|
+
puts '## Files in gemspec not in the filesystem:'
|
64
|
+
puts '##########################################'
|
65
|
+
puts((files_from_gemspec - files_from_filesystem).map { |f| " " + f })
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Test that the .gemspec file executes"
|
69
|
+
task :debug_gem do
|
70
|
+
require 'rubygems/specification'
|
71
|
+
gemspec = File.read('adhearsion.gemspec')
|
72
|
+
spec = nil
|
73
|
+
Thread.new { spec = eval("$SAFE = 3\n#{gemspec}") }.join
|
74
|
+
puts "SUCCESS: Gemspec runs at the $SAFE level 3."
|
75
|
+
end
|
data/adhearsion.gemspec
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
ADHEARSION_FILES = %w{
|
2
|
+
adhearsion.gemspec
|
3
|
+
LICENSE
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
app_generators/ahn/USAGE
|
7
|
+
app_generators/ahn/ahn_generator.rb
|
8
|
+
app_generators/ahn/templates/.ahnrc
|
9
|
+
app_generators/ahn/templates/README
|
10
|
+
app_generators/ahn/templates/Rakefile
|
11
|
+
app_generators/ahn/templates/components/simon_game/configuration.rb
|
12
|
+
app_generators/ahn/templates/components/simon_game/lib/simon_game.rb
|
13
|
+
app_generators/ahn/templates/components/simon_game/test/test_helper.rb
|
14
|
+
app_generators/ahn/templates/components/simon_game/test/test_simon_game.rb
|
15
|
+
app_generators/ahn/templates/config/startup.rb
|
16
|
+
app_generators/ahn/templates/dialplan.rb
|
17
|
+
bin/ahn
|
18
|
+
bin/ahnctl
|
19
|
+
bin/jahn
|
20
|
+
lib/adhearsion.rb
|
21
|
+
lib/adhearsion/blank_slate.rb
|
22
|
+
lib/adhearsion/cli.rb
|
23
|
+
lib/adhearsion/events_support.rb
|
24
|
+
lib/adhearsion/component_manager.rb
|
25
|
+
lib/adhearsion/core_extensions/all.rb
|
26
|
+
lib/adhearsion/core_extensions/array.rb
|
27
|
+
lib/adhearsion/core_extensions/custom_daemonizer.rb
|
28
|
+
lib/adhearsion/core_extensions/global.rb
|
29
|
+
lib/adhearsion/core_extensions/hash.rb
|
30
|
+
lib/adhearsion/core_extensions/metaprogramming.rb
|
31
|
+
lib/adhearsion/core_extensions/numeric.rb
|
32
|
+
lib/adhearsion/core_extensions/proc.rb
|
33
|
+
lib/adhearsion/core_extensions/publishable.rb
|
34
|
+
lib/adhearsion/core_extensions/relationship_properties.rb
|
35
|
+
lib/adhearsion/core_extensions/string.rb
|
36
|
+
lib/adhearsion/core_extensions/thread.rb
|
37
|
+
lib/adhearsion/core_extensions/thread_safety.rb
|
38
|
+
lib/adhearsion/core_extensions/time.rb
|
39
|
+
lib/adhearsion/distributed/gateways/dbus_gateway.rb
|
40
|
+
lib/adhearsion/distributed/gateways/osa_gateway.rb
|
41
|
+
lib/adhearsion/distributed/gateways/rest_gateway.rb
|
42
|
+
lib/adhearsion/distributed/gateways/soap_gateway.rb
|
43
|
+
lib/adhearsion/distributed/gateways/xmlrpc_gateway.rb
|
44
|
+
lib/adhearsion/distributed/peer_finder.rb
|
45
|
+
lib/adhearsion/distributed/remote_cli.rb
|
46
|
+
lib/adhearsion/hooks.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/generating.rb
|
59
|
+
lib/adhearsion/tasks/lint.rb
|
60
|
+
lib/adhearsion/tasks/testing.rb
|
61
|
+
lib/adhearsion/version.rb
|
62
|
+
lib/adhearsion/voip/asterisk.rb
|
63
|
+
lib/adhearsion/voip/asterisk/agi_server.rb
|
64
|
+
lib/adhearsion/voip/asterisk/ami.rb
|
65
|
+
lib/adhearsion/voip/asterisk/ami/actions.rb
|
66
|
+
lib/adhearsion/voip/asterisk/ami/machine.rb
|
67
|
+
lib/adhearsion/voip/asterisk/ami/machine.rl
|
68
|
+
lib/adhearsion/voip/asterisk/ami/parser.rb
|
69
|
+
lib/adhearsion/voip/asterisk/commands.rb
|
70
|
+
lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb
|
71
|
+
lib/adhearsion/voip/asterisk/config_generators/config_generator.rb
|
72
|
+
lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb
|
73
|
+
lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb
|
74
|
+
lib/adhearsion/voip/asterisk/config_manager.rb
|
75
|
+
lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb
|
76
|
+
lib/adhearsion/voip/call.rb
|
77
|
+
lib/adhearsion/voip/call_routing.rb
|
78
|
+
lib/adhearsion/voip/commands.rb
|
79
|
+
lib/adhearsion/voip/constants.rb
|
80
|
+
lib/adhearsion/voip/conveniences.rb
|
81
|
+
lib/adhearsion/voip/dial_plan.rb
|
82
|
+
lib/adhearsion/voip/dsl/dialing_dsl.rb
|
83
|
+
lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb
|
84
|
+
lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb
|
85
|
+
lib/adhearsion/voip/dsl/dialplan/dispatcher.rb
|
86
|
+
lib/adhearsion/voip/dsl/dialplan/parser.rb
|
87
|
+
lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb
|
88
|
+
lib/adhearsion/voip/dsl/numerical_string.rb
|
89
|
+
lib/adhearsion/voip/freeswitch/basic_connection_manager.rb
|
90
|
+
lib/adhearsion/voip/freeswitch/event_handler.rb
|
91
|
+
lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb
|
92
|
+
lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb
|
93
|
+
lib/adhearsion/voip/freeswitch/oes_server.rb
|
94
|
+
lib/adhearsion/voip/menu_state_machine/calculated_match.rb
|
95
|
+
lib/adhearsion/voip/menu_state_machine/matchers.rb
|
96
|
+
lib/adhearsion/voip/menu_state_machine/menu_builder.rb
|
97
|
+
lib/adhearsion/voip/menu_state_machine/menu_class.rb
|
98
|
+
}
|
99
|
+
|
100
|
+
Gem::Specification.new do |s|
|
101
|
+
s.name = "adhearsion"
|
102
|
+
s.version = "0.7.999"
|
103
|
+
|
104
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
105
|
+
s.authors = ["Jay Phillips"]
|
106
|
+
|
107
|
+
s.date = "2008-08-21"
|
108
|
+
s.description = "Adhearsion is an open-source telephony development framework"
|
109
|
+
s.email = "Jay -at- Codemecca.com"
|
110
|
+
s.executables = ["ahn", "ahnctl", "jahn"]
|
111
|
+
|
112
|
+
s.files = ADHEARSION_FILES
|
113
|
+
|
114
|
+
s.has_rdoc = false
|
115
|
+
s.homepage = "http://adhearsion.com"
|
116
|
+
s.require_paths = ["lib"]
|
117
|
+
s.rubyforge_project = "adhearsion"
|
118
|
+
s.rubygems_version = "1.2.0"
|
119
|
+
s.summary = "Adhearsion, open-source telephony development framework"
|
120
|
+
|
121
|
+
if s.respond_to? :specification_version then
|
122
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
123
|
+
s.specification_version = 2
|
124
|
+
|
125
|
+
if current_version >= 3 then
|
126
|
+
s.add_runtime_dependency("rubigen", [">= 1.0.6"])
|
127
|
+
s.add_runtime_dependency("log4r", [">= 1.0.5"])
|
128
|
+
else
|
129
|
+
s.add_dependency("rubigen", [">= 1.0.6"])
|
130
|
+
s.add_dependency("log4r", [">= 1.0.5"])
|
131
|
+
end
|
132
|
+
else
|
133
|
+
s.add_dependency("rubigen", [">= 1.0.6"])
|
134
|
+
s.add_dependency("log4r", [">= 1.0.5"])
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class AhnGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
4
|
+
Config::CONFIG['ruby_install_name'])
|
5
|
+
|
6
|
+
default_options :author => nil
|
7
|
+
|
8
|
+
attr_reader :name, :component
|
9
|
+
|
10
|
+
def initialize(runtime_args, runtime_options = {})
|
11
|
+
super
|
12
|
+
usage if args.empty?
|
13
|
+
@destination_root = File.expand_path(args.shift)
|
14
|
+
@name = base_name
|
15
|
+
@component = 'simon_game'
|
16
|
+
extract_options
|
17
|
+
end
|
18
|
+
|
19
|
+
def manifest
|
20
|
+
record do |m|
|
21
|
+
# Ensure appropriate folder(s) exists
|
22
|
+
m.directory ''
|
23
|
+
BASEDIRS.each { |path| m.directory path }
|
24
|
+
|
25
|
+
m.file *[".ahnrc"]*2
|
26
|
+
|
27
|
+
m.file *["components/simon_game/configuration.rb"]*2
|
28
|
+
m.file *["components/simon_game/lib/simon_game.rb"]*2
|
29
|
+
m.file *["components/simon_game/test/test_helper.rb"]*2
|
30
|
+
m.file *["components/simon_game/test/test_simon_game.rb"]*2
|
31
|
+
|
32
|
+
m.file *["config/startup.rb"]*2
|
33
|
+
m.file *["dialplan.rb"]*2
|
34
|
+
m.file *["events.rb"]*2
|
35
|
+
m.file *["README"]*2
|
36
|
+
m.file *["Rakefile"]*2
|
37
|
+
|
38
|
+
# m.dependency "install_rubigen_scripts", [destination_root, 'ahn', 'adhearsion', 'test_spec'],
|
39
|
+
# :shebang => options[:shebang], :collision => :force
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
def banner
|
45
|
+
<<-EOS
|
46
|
+
Creates a ...
|
47
|
+
|
48
|
+
USAGE: #{spec.name} name"
|
49
|
+
EOS
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_options!(opts)
|
53
|
+
opts.separator ''
|
54
|
+
opts.separator 'Options:'
|
55
|
+
# For each option below, place the default
|
56
|
+
# at the top of the file next to "default_options"
|
57
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
58
|
+
# "Some comment about this option",
|
59
|
+
# "Default: none") { |options[:author]| }
|
60
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
61
|
+
end
|
62
|
+
|
63
|
+
def extract_options
|
64
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
65
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
66
|
+
# raw instance variable value.
|
67
|
+
# @author = options[:author]
|
68
|
+
end
|
69
|
+
|
70
|
+
# Installation skeleton. Intermediate directories are automatically
|
71
|
+
# created so don't sweat their absence here.
|
72
|
+
BASEDIRS = %w(
|
73
|
+
components/simon_game/lib
|
74
|
+
components/simon_game/test
|
75
|
+
config
|
76
|
+
)
|
77
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Adhearsion Runtime Configuration.
|
2
|
+
|
3
|
+
# You can use the "gems" section to force Adhearsion to load a particular version of a gem.
|
4
|
+
# This is useful when a component require()s a gem, but you don't want it to use the latest one installed on the system.
|
5
|
+
# For example, if a component require()s activerecord, sucking in the latest on the system, and then you enable a Rails app
|
6
|
+
# which wants a particular version of activerecord, RubyGems will raise an error saying "you cannot activate two versions of
|
7
|
+
# the same gem". Note: specifying the version, source and require names is optional, but you must include a : after the gem name to make it a YAML key/value pair (with a nil value).
|
8
|
+
gems:
|
9
|
+
# twitter:
|
10
|
+
# hpricot:
|
11
|
+
# rack:
|
12
|
+
# # require() one library when initializing:
|
13
|
+
# require: rack
|
14
|
+
# memcache-client:
|
15
|
+
# version >= 1.5.2
|
16
|
+
# require:
|
17
|
+
# # require() an Array of libraries when initializing:
|
18
|
+
# - memcache
|
19
|
+
# - memcache_util
|
20
|
+
# activerecord:
|
21
|
+
# version: >= 2.1.0
|
22
|
+
# aasm:
|
23
|
+
# source: http://gems.github.com
|
24
|
+
|
25
|
+
paths:
|
26
|
+
|
27
|
+
# All paths are relative to this file's directory
|
28
|
+
init: config/startup.rb
|
29
|
+
|
30
|
+
dialplan: dialplan.rb
|
31
|
+
|
32
|
+
events: events.rb
|
33
|
+
|
34
|
+
models:
|
35
|
+
directory: models
|
36
|
+
pattern: "*.rb"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Start your new app with "ahn start /path/to/your/app"
|
2
|
+
|
3
|
+
If you wish to use Adhearsion to control Asterisk's dialplan,
|
4
|
+
change the contexts you wish to be affected in your
|
5
|
+
/etc/asterisk/extensions.conf file to the following:
|
6
|
+
|
7
|
+
[your_context_name]
|
8
|
+
exten => _X.,1,AGI(agi://1.2.3.4) ; This IP here
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'adhearsion'
|
3
|
+
require 'adhearsion/tasks'
|
4
|
+
|
5
|
+
desc "Writes a .gitignore file that ignores certain SCM annoyances such as log files"
|
6
|
+
task :gitignore do
|
7
|
+
ignore_file = "#{Dir.pwd}/.gitignore"
|
8
|
+
if File.exists? ignore_file
|
9
|
+
STDERR.puts "File #{ignore_file} already exists!"
|
10
|
+
else
|
11
|
+
File.open ignore_file, 'w' do |file|
|
12
|
+
# Add other files to the Array below
|
13
|
+
%w[ log ].each do |pattern|
|
14
|
+
file.puts pattern
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class SimonGame
|
2
|
+
add_call_context :as => :call_context
|
3
|
+
|
4
|
+
attr_accessor :number, :attempt
|
5
|
+
def initialize
|
6
|
+
initialize_number
|
7
|
+
initialize_attempt
|
8
|
+
end
|
9
|
+
|
10
|
+
def start
|
11
|
+
loop do
|
12
|
+
say_number
|
13
|
+
collect_attempt
|
14
|
+
verify_attempt
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def random_number
|
19
|
+
rand(10).to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_number
|
23
|
+
initialize_attempt
|
24
|
+
@number << random_number
|
25
|
+
end
|
26
|
+
|
27
|
+
def say_number
|
28
|
+
update_number
|
29
|
+
call_context.say_digits number
|
30
|
+
end
|
31
|
+
|
32
|
+
def collect_attempt
|
33
|
+
@attempt = call_context.input(number.size)
|
34
|
+
end
|
35
|
+
|
36
|
+
def verify_attempt
|
37
|
+
if attempt_correct?
|
38
|
+
call_context.play 'good'
|
39
|
+
else
|
40
|
+
call_context.play %W(#{number.size - 1} times wrong-try-again-smarty)
|
41
|
+
reset
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def attempt_correct?
|
46
|
+
attempt == number
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize_attempt
|
50
|
+
@attempt ||= ''
|
51
|
+
end
|
52
|
+
|
53
|
+
def initialize_number
|
54
|
+
@number ||= ''
|
55
|
+
end
|
56
|
+
|
57
|
+
def reset
|
58
|
+
@attempt, @number = '', ''
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../../../../../lib'
|
2
|
+
require 'adhearsion'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'flexmock/test_unit'
|
5
|
+
AHN_ROOT = Adhearsion::PathString.new(File.dirname(__FILE__) + '/../../..')
|
6
|
+
Adhearsion::ComponentManager.load
|
7
|
+
Adhearsion::ComponentManager.start
|
8
|
+
|
9
|
+
class Test::Unit::TestCase
|
10
|
+
Adhearsion::ComponentManager.components_with_call_context.each_pair do |component_class_name, component_configuration|
|
11
|
+
const_set(component_class_name, component_configuration.component_class)
|
12
|
+
const_get(component_class_name).send(:attr_accessor, :call_context)
|
13
|
+
end
|
14
|
+
end
|