adhearsion 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -42
- data/EVENTS +11 -0
- data/README.txt +5 -0
- data/Rakefile +94 -84
- data/adhearsion.gemspec +148 -0
- data/app_generators/ahn/USAGE +5 -0
- data/app_generators/ahn/ahn_generator.rb +87 -0
- data/app_generators/ahn/templates/.ahnrc +34 -0
- data/app_generators/ahn/templates/README +8 -0
- data/app_generators/ahn/templates/Rakefile +23 -0
- 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/restful_rpc/README.markdown +11 -0
- data/app_generators/ahn/templates/components/restful_rpc/config.yml +34 -0
- data/app_generators/ahn/templates/components/restful_rpc/example-client.rb +48 -0
- data/app_generators/ahn/templates/components/restful_rpc/restful_rpc.rb +87 -0
- data/app_generators/ahn/templates/components/restful_rpc/spec/restful_rpc_spec.rb +263 -0
- data/app_generators/ahn/templates/components/simon_game/simon_game.rb +56 -0
- data/app_generators/ahn/templates/config/startup.rb +50 -0
- data/app_generators/ahn/templates/dialplan.rb +3 -0
- data/app_generators/ahn/templates/events.rb +32 -0
- data/bin/ahn +28 -0
- data/bin/ahnctl +68 -0
- data/bin/jahn +42 -0
- data/examples/asterisk_manager_interface/standalone.rb +51 -0
- data/lib/adhearsion.rb +35 -953
- data/lib/adhearsion/cli.rb +223 -0
- data/lib/adhearsion/component_manager.rb +208 -0
- data/lib/adhearsion/component_manager/component_tester.rb +55 -0
- data/lib/adhearsion/component_manager/spec_framework.rb +24 -0
- data/lib/adhearsion/events_support.rb +84 -0
- data/lib/adhearsion/foundation/all.rb +9 -0
- data/lib/adhearsion/foundation/blank_slate.rb +5 -0
- data/lib/adhearsion/foundation/custom_daemonizer.rb +45 -0
- data/lib/adhearsion/foundation/event_socket.rb +203 -0
- data/lib/adhearsion/foundation/future_resource.rb +36 -0
- data/lib/adhearsion/foundation/global.rb +1 -0
- data/lib/adhearsion/foundation/metaprogramming.rb +17 -0
- data/lib/adhearsion/foundation/numeric.rb +13 -0
- data/lib/adhearsion/foundation/pseudo_guid.rb +10 -0
- data/lib/adhearsion/foundation/relationship_properties.rb +42 -0
- data/lib/adhearsion/foundation/string.rb +26 -0
- data/lib/adhearsion/foundation/synchronized_hash.rb +96 -0
- data/lib/adhearsion/foundation/thread_safety.rb +7 -0
- data/lib/adhearsion/host_definitions.rb +67 -0
- data/lib/adhearsion/initializer.rb +373 -0
- data/lib/adhearsion/initializer/asterisk.rb +81 -0
- data/lib/adhearsion/initializer/configuration.rb +254 -0
- data/lib/adhearsion/initializer/database.rb +49 -0
- data/lib/adhearsion/initializer/drb.rb +31 -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 +16 -0
- data/lib/adhearsion/tasks/database.rb +5 -0
- data/lib/adhearsion/tasks/deprecations.rb +59 -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 +4 -0
- data/lib/adhearsion/voip/asterisk/agi_server.rb +81 -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/manager_interface.rb +562 -0
- 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/special_dial_plan_managers.rb +80 -0
- data/lib/adhearsion/voip/asterisk/super_manager.rb +19 -0
- data/lib/adhearsion/voip/call.rb +440 -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 +218 -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
- data/lib/theatre.rb +151 -0
- 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
- metadata +160 -140
- data/.version +0 -1
- data/TODO +0 -71
- data/ahn +0 -223
- data/apps/default/Rakefile +0 -65
- data/apps/default/config/adhearsion.sqlite3 +0 -0
- data/apps/default/config/adhearsion.yml +0 -95
- data/apps/default/config/database.rb +0 -50
- data/apps/default/config/database.yml +0 -12
- data/apps/default/config/helpers/drb_server.yml +0 -43
- data/apps/default/config/helpers/factorial.alien.c.yml +0 -1
- data/apps/default/config/helpers/growler.yml +0 -21
- data/apps/default/config/helpers/lookup.yml +0 -1
- data/apps/default/config/helpers/manager_proxy.yml +0 -8
- data/apps/default/config/helpers/micromenus.yml +0 -1
- data/apps/default/config/helpers/micromenus/collab.rb +0 -60
- data/apps/default/config/helpers/micromenus/images/arrow-off.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/arrow-on.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/error.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/folder-off.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/folder-on.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/folder.png +0 -0
- data/apps/default/config/helpers/micromenus/images/ggbridge.jpg +0 -0
- data/apps/default/config/helpers/micromenus/images/green.png +0 -0
- data/apps/default/config/helpers/micromenus/images/microbrowser.bg.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/red.png +0 -0
- data/apps/default/config/helpers/micromenus/images/tux.bmp +0 -0
- data/apps/default/config/helpers/micromenus/images/url-off.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/url-on.gif +0 -0
- data/apps/default/config/helpers/micromenus/images/yellow.png +0 -0
- data/apps/default/config/helpers/micromenus/javascripts/animation.js +0 -1341
- data/apps/default/config/helpers/micromenus/javascripts/carousel.js +0 -1238
- data/apps/default/config/helpers/micromenus/javascripts/columnav.js +0 -306
- data/apps/default/config/helpers/micromenus/javascripts/connection.js +0 -965
- data/apps/default/config/helpers/micromenus/javascripts/container.js +0 -4727
- data/apps/default/config/helpers/micromenus/javascripts/container_core.js +0 -2915
- data/apps/default/config/helpers/micromenus/javascripts/dom.js +0 -892
- data/apps/default/config/helpers/micromenus/javascripts/dragdrop.js +0 -2958
- data/apps/default/config/helpers/micromenus/javascripts/event.js +0 -1771
- data/apps/default/config/helpers/micromenus/javascripts/yahoo.js +0 -433
- data/apps/default/config/helpers/micromenus/stylesheets/carousel.css +0 -78
- data/apps/default/config/helpers/micromenus/stylesheets/columnav.css +0 -135
- data/apps/default/config/helpers/micromenus/stylesheets/microbrowsers.css +0 -42
- data/apps/default/config/helpers/multi_messenger.yml +0 -9
- data/apps/default/config/helpers/weather.yml +0 -1
- data/apps/default/config/helpers/xbmc.yml +0 -2
- data/apps/default/config/migration.rb +0 -59
- data/apps/default/extensions.rb +0 -41
- data/apps/default/helpers/factorial.alien.c +0 -32
- data/apps/default/helpers/growler.rb +0 -53
- data/apps/default/helpers/lookup.rb +0 -44
- data/apps/default/helpers/manager_proxy.rb +0 -112
- data/apps/default/helpers/micromenus.rb +0 -514
- data/apps/default/helpers/multi_messenger.rb +0 -53
- data/apps/default/helpers/oscar_wilde_quotes.rb +0 -197
- data/apps/default/helpers/weather.rb +0 -85
- data/apps/default/helpers/xbmc.rb +0 -39
- data/apps/default/logs/adhearsion.log +0 -0
- data/apps/default/logs/database.log +0 -0
- data/lib/constants.rb +0 -24
- data/lib/core_extensions.rb +0 -180
- data/lib/drb_server.rb +0 -101
- data/lib/logging.rb +0 -85
- data/lib/phone_number.rb +0 -85
- data/lib/rami.rb +0 -823
- data/lib/servlet_container.rb +0 -174
- data/lib/sexy_migrations.rb +0 -70
- data/test/asterisk_module_test.rb +0 -14
- data/test/core_extensions_test.rb +0 -26
- data/test/dial_test.rb +0 -43
- data/test/specs/numerical_string_spec.rb +0 -53
- data/test/test_micromenus.rb +0 -0
data/lib/servlet_container.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
# Adhearsion, open source technology integrator
|
2
|
-
# Copyright (C) 2006,2007 Jay Phillips
|
3
|
-
#
|
4
|
-
# This library is free software; you can redistribute it and/or
|
5
|
-
# modify it under the terms of the GNU Lesser General Public
|
6
|
-
# License as published by the Free Software Foundation; either
|
7
|
-
# version 2.1 of the License, or (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This library is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU Lesser General Public
|
15
|
-
# License along with this library; if not, write to the Free Software
|
16
|
-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
17
|
-
|
18
|
-
class ServletContainer
|
19
|
-
|
20
|
-
# TODO: Port more efficient server here. Erlang perhaps?
|
21
|
-
class NativeServer;end
|
22
|
-
|
23
|
-
require 'gserver'
|
24
|
-
class RubyServer < GServer
|
25
|
-
def initialize(port, *args)
|
26
|
-
@stdlog = $STDOUT
|
27
|
-
log "Starting server on port #{port}"
|
28
|
-
audit = true
|
29
|
-
super(port, *args)
|
30
|
-
end
|
31
|
-
|
32
|
-
def read_variables io
|
33
|
-
vars = {}
|
34
|
-
while line = io.gets.chomp
|
35
|
-
break if line.empty? # Empty lines signify no more variables
|
36
|
-
variable = line.split(/:\s*/)
|
37
|
-
new_name, new_value = variable.first[4..-1].downcase, variable.last
|
38
|
-
|
39
|
-
if new_name == 'extension' then vars['extension'] = PhoneNumber.new new_value
|
40
|
-
elsif new_name == 'context' then vars['context'] = new_value.gsub '-', '_'
|
41
|
-
elsif new_name == 'request'
|
42
|
-
uri = URI.parse new_value
|
43
|
-
query = {}
|
44
|
-
if uri.query
|
45
|
-
hash = {}
|
46
|
-
uri.query.split('&').each do |a|
|
47
|
-
k,v = a.split('=')
|
48
|
-
query[k] = v
|
49
|
-
end
|
50
|
-
context = query['context']
|
51
|
-
end
|
52
|
-
vars['request'], vars['uri'], vars['query'] = new_value, uri, query
|
53
|
-
else
|
54
|
-
vars[new_name.to_s] = if new_value =~ /^\d+$/
|
55
|
-
if new_value.starts_with?('0') then NumericalString.new(new_value)
|
56
|
-
else new_value.to_i
|
57
|
-
end
|
58
|
-
else new_value
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
vars['context'] = vars['query']['context'] if vars['query']['context']
|
64
|
-
vars
|
65
|
-
end
|
66
|
-
|
67
|
-
# GServer allows all functionality to be packed into this one serve() method.
|
68
|
-
def serve io
|
69
|
-
io.sync = true
|
70
|
-
Thread.current[:io] = io
|
71
|
-
begin
|
72
|
-
call_variables = read_variables io
|
73
|
-
Thread.current[:VARS] = call_variables
|
74
|
-
Thread.current[:container] = Contexts::Container.new
|
75
|
-
|
76
|
-
if call_variables.extension == 'h'
|
77
|
-
# We've received a notification that a channel's hung up!
|
78
|
-
Thread.list.each do |thread|
|
79
|
-
if thread[:VARS] && thread[:VARS]['uniqueid'] == call_variables['uniqueid']
|
80
|
-
thread[:hungup?] = true
|
81
|
-
# Could kill() the Thread here but it may need to finish. We're merciful people.
|
82
|
-
log "Received notification that channel #{call_variables['channel']} has been hung up."
|
83
|
-
return
|
84
|
-
end
|
85
|
-
end
|
86
|
-
elsif ['t', 'failed'].include? call_variables['extension']
|
87
|
-
# Timeout notifications. Not implemented yet...
|
88
|
-
io.close
|
89
|
-
return
|
90
|
-
end
|
91
|
-
|
92
|
-
log "Executing call with variables: " + call_variables.inspect
|
93
|
-
|
94
|
-
call_variables.each do |k,v|
|
95
|
-
Thread.current[:container].run_inside do
|
96
|
-
meta_def(k) { v }
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# Execute all before_call hooks
|
101
|
-
[$BEFORE_CALL_HIGH, $BEFORE_CALL, $BEFORE_CALL_LOW].flatten.compact.each(&:call)
|
102
|
-
+lambda { answer if CONFIG['answer_before_call'] }
|
103
|
-
|
104
|
-
# A call hook may decree that the call shouldn't be processed further (e.g. if
|
105
|
-
# it processed the call itself). This is done be rewriting the context variable.
|
106
|
-
unless Thread.current[:VARS]['context'] == :interrupted
|
107
|
-
|
108
|
-
begin
|
109
|
-
|
110
|
-
Contexts.new.instance_eval do
|
111
|
-
# Interpret the extensions.rb file!
|
112
|
-
eval File.read("extensions.rb")
|
113
|
-
end
|
114
|
-
rescue => detail
|
115
|
-
log "Exception raised in extensions.rb! " << detail.message
|
116
|
-
# TODO: Make error reports more intutive. Use notifications DSL?
|
117
|
-
detail.backtrace.each do |msg| log " " * 8 << msg end
|
118
|
-
end
|
119
|
-
|
120
|
-
log "Parsing of extensions.rb complete"
|
121
|
-
|
122
|
-
begin
|
123
|
-
target_context = call_variables['context']
|
124
|
-
if target_context
|
125
|
-
Thread.current[:container].run_inside do
|
126
|
-
begin
|
127
|
-
unless target_context.kind_of? Proc
|
128
|
-
target_context = send(target_context.to_s.to_sym)
|
129
|
-
end
|
130
|
-
+target_context
|
131
|
-
rescue ControlPassingException => new_target
|
132
|
-
target_context = new_target.target
|
133
|
-
retry
|
134
|
-
rescue => e
|
135
|
-
error e.inspect + "\n " + e.backtrace * "\n "
|
136
|
-
+lambda {
|
137
|
-
play 'an-error-has-occurred', 'were-sorry'
|
138
|
-
hangup if CONFIG.key?('hangup_after_error') && CONFIG['hangup_after_error']
|
139
|
-
}
|
140
|
-
end
|
141
|
-
end
|
142
|
-
else
|
143
|
-
io.close
|
144
|
-
log "ASTERISK REQUESTED ROUTING FOR A CONTEXT UNDEFINED IN extensions.rb!!! REQUEST IGNORED!!!"
|
145
|
-
return
|
146
|
-
end
|
147
|
-
rescue => detail
|
148
|
-
error "ERROR: #{detail.class.name} => #{detail.inspect}"
|
149
|
-
detail.backtrace.each do |msg| error " " * 8 << msg end
|
150
|
-
end
|
151
|
-
log "Call routing complete"
|
152
|
-
end
|
153
|
-
rescue => detail
|
154
|
-
error "Call thread raised an exception! #{detail.message}"
|
155
|
-
detail.backtrace.each { |msg| error " " * 8 << msg }
|
156
|
-
end
|
157
|
-
|
158
|
-
[$AFTER_CALL_HIGH, $AFTER_CALL, $AFTER_CALL_LOW].flatten.compact.each(&:call)
|
159
|
-
+lambda { hangup if CONFIG['hangup_after_call'] }
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def initialize(port=4573, host='0.0.0.0', native=false)
|
164
|
-
@server = (native ? NativeServer : RubyServer).new port, host, Infinity
|
165
|
-
@server.start
|
166
|
-
end
|
167
|
-
|
168
|
-
|
169
|
-
def shutdown
|
170
|
-
@server.shutdown
|
171
|
-
end
|
172
|
-
|
173
|
-
attr_reader :server
|
174
|
-
end
|
data/lib/sexy_migrations.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# Taken from svn://errtheblog.com/svn/plugins/sexy_migrations/lib/sexy_migrations.rb
|
2
|
-
module SexyMigrations
|
3
|
-
module Table
|
4
|
-
attr_reader :fk_references
|
5
|
-
|
6
|
-
def foreign_key(*args)
|
7
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
8
|
-
args.each do |col|
|
9
|
-
column(id = "#{col}_id", :integer, options)
|
10
|
-
(@fk_references ||= []) << [id, options[:ref].to_s] if options[:ref]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
alias :fkey :foreign_key
|
14
|
-
alias :fkeys :foreign_key
|
15
|
-
alias :foreign_keys :foreign_key
|
16
|
-
|
17
|
-
def timestamps(*extras)
|
18
|
-
(Array(extras) + %w(created_at updated_at)).each do |stamp|
|
19
|
-
datetime stamp
|
20
|
-
end
|
21
|
-
end
|
22
|
-
alias :timestamps! :timestamps
|
23
|
-
alias :auto_dates :timestamps
|
24
|
-
alias :auto_dates! :timestamps
|
25
|
-
|
26
|
-
def polymorphic(name)
|
27
|
-
integer "#{name}_id"
|
28
|
-
string "#{name}_type"
|
29
|
-
end
|
30
|
-
alias :polymorphic! :polymorphic
|
31
|
-
|
32
|
-
def method_missing(name, *args)
|
33
|
-
return super unless type = simplified_type(name)
|
34
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
35
|
-
args.each { |col| column(col, type, options) }
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
def simplified_type(type)
|
40
|
-
ActiveRecord::ConnectionAdapters::Column.new(:type_check, false, type.to_s).type
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
module Schema
|
45
|
-
def create_table(name, options = {}, &block)
|
46
|
-
table_definition = ActiveRecord::ConnectionAdapters::TableDefinition.new(self)
|
47
|
-
table_definition.primary_key(options[:primary_key] || "id") unless options[:id] == false
|
48
|
-
|
49
|
-
table_definition.instance_eval &block
|
50
|
-
|
51
|
-
if options[:force]
|
52
|
-
drop_table(name, options) rescue nil
|
53
|
-
end
|
54
|
-
|
55
|
-
create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE "
|
56
|
-
create_sql << "#{name} ("
|
57
|
-
create_sql << table_definition.to_sql
|
58
|
-
create_sql << ") #{options[:options]}"
|
59
|
-
|
60
|
-
# if any fk contraints, add them
|
61
|
-
if table_definition.fk_references
|
62
|
-
create_sql << "; "
|
63
|
-
table_definition.fk_references.each do |fk|
|
64
|
-
create_sql << "ALTER TABLE #{name} ADD FOREIGN KEY (#{fk[0]}) REFERENCES #{fk[1]} (id); "
|
65
|
-
end
|
66
|
-
end
|
67
|
-
execute create_sql
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
context "The PBX object" do
|
2
|
-
specify "should properize properly" do
|
3
|
-
PBX.properize("123").should == 'SIP/123'
|
4
|
-
PBX.properize(1_555_444_1234).should == 'SIP/15554441234'
|
5
|
-
PBX.properize(:jay).should == 'SIP/jay'
|
6
|
-
PBX.properize("jay").should == 'SIP/jay'
|
7
|
-
PBX.properize("SIP/123").should == 'SIP/123'
|
8
|
-
PBX.properize("IAX2/jay").should == 'IAX2/jay'
|
9
|
-
PBX.properize((100..110).to_a).should == 'SIP/100&SIP/101&SIP/102&SIP/103&SIP/104&SIP/105&SIP/106&SIP/107&SIP/108&SIP/109&SIP/110'
|
10
|
-
PBX.properize(["SIP/123", "SIP/456"]).should == 'SIP/123&SIP/456'
|
11
|
-
# TODO: Should mock up dialing a user
|
12
|
-
# TODO: Should mock up dialing a group
|
13
|
-
end
|
14
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
class CoreExtensionsTest < Test::Unit::TestCase
|
3
|
-
def test_hash
|
4
|
-
value = "I've changed my plea to guilty because freedom is wasted on me. -- Morrissey"
|
5
|
-
|
6
|
-
x = Hash.new
|
7
|
-
|
8
|
-
x[:kewlz0rz] = value
|
9
|
-
assert_equal x[:kewlz0rz], value
|
10
|
-
assert_equal x.kewlz0rz, value
|
11
|
-
|
12
|
-
x.sweetness = value
|
13
|
-
assert_equal x.sweetness, value
|
14
|
-
|
15
|
-
x['awesome'] = value
|
16
|
-
assert_equal x['awesome'], value
|
17
|
-
assert_equal x.awesome, value
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_regexp_hack
|
22
|
-
assert_false(/123/ === 123)
|
23
|
-
# TODO: Also test that running this in the dialplan DSL
|
24
|
-
# produces different results.
|
25
|
-
end
|
26
|
-
end
|
data/test/dial_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
class DialTest < Test::Unit::TestCase
|
3
|
-
|
4
|
-
def initialize name
|
5
|
-
class << self
|
6
|
-
include Asterisk
|
7
|
-
end
|
8
|
-
super name
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_protocol_sugar
|
12
|
-
num = 1337
|
13
|
-
name = "lordxenu"
|
14
|
-
namesym = name.to_sym
|
15
|
-
|
16
|
-
sipnum, sipname = "SIP/#{num}", "SIP/#{name}"
|
17
|
-
iaxnum, iaxname = "IAX2/#{num}", "IAX2/#{name}"
|
18
|
-
zapnum, zapname = "Zap/#{num}", "Zap/#{name}"
|
19
|
-
|
20
|
-
sipnumtests = [SIP/num, SIP(num), SIP[num]]
|
21
|
-
iaxnumtests = [IAX/num, IAX(num), IAX[num], IAX2/num, IAX2(num), IAX2[num]]
|
22
|
-
zapnumtests = [ZAP/num, ZAP(num), ZAP[num], Zap/num, Zap(num), Zap[num]]
|
23
|
-
|
24
|
-
sipnametests = [SIP/name, SIP(name), SIP[name], SIP/namesym, SIP(namesym), SIP[namesym]]
|
25
|
-
iaxnametests = [IAX/name, IAX(name), IAX[name], IAX/namesym, IAX(namesym), IAX[namesym],
|
26
|
-
IAX2/name, IAX2(name), IAX2[name], IAX2/namesym, IAX2(namesym), IAX2[namesym]]
|
27
|
-
zapnametests = [ZAP/name, ZAP(name), ZAP[name], ZAP/namesym, ZAP(namesym), ZAP[namesym]]
|
28
|
-
|
29
|
-
sipnumtests.each do |test| assert_equal test, sipnum end
|
30
|
-
iaxnumtests.each do |test| assert_equal test, iaxnum end
|
31
|
-
zapnumtests.each do |test| assert_equal test, zapnum end
|
32
|
-
|
33
|
-
sipnametests.each do |test| assert_equal test, sipname end
|
34
|
-
iaxnametests.each do |test| assert_equal test, iaxname end
|
35
|
-
zapnametests.each do |test| assert_equal test, zapname end
|
36
|
-
end
|
37
|
-
|
38
|
-
#def test_dialing_complex_arrays
|
39
|
-
#end
|
40
|
-
|
41
|
-
#def test_dialing_hashes
|
42
|
-
#end
|
43
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'phone_number.rb')
|
2
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'constants.rb')
|
3
|
-
|
4
|
-
context "A NumericalString" do
|
5
|
-
specify "should be accessable as a Fixnum to a case statement" do
|
6
|
-
(123 === NumericalString.new("123")).should == true
|
7
|
-
(987 === NumericalString.new("0987")).should == true
|
8
|
-
end
|
9
|
-
specify "should be accessable as a String to a case statement" do
|
10
|
-
("123" === NumericalString.new("123")).should == true
|
11
|
-
("0987" === NumericalString.new("0987")).should == true
|
12
|
-
end
|
13
|
-
|
14
|
-
specify "should satisfy Ranges" do
|
15
|
-
(100..200).should === NumericalString.new("150")
|
16
|
-
(100..200).should === NumericalString.new("0150")
|
17
|
-
((100..200) === NumericalString.new("1000000")).should === false
|
18
|
-
end
|
19
|
-
|
20
|
-
specify "should satify regular expressions" do
|
21
|
-
/^\d+$/.should === NumericalString.new("027316287")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
#
|
25
|
-
# case extension
|
26
|
-
# when US_NUMBER
|
27
|
-
# when (100..200)
|
28
|
-
# when _('12Z')
|
29
|
-
# when 123
|
30
|
-
# when "123"
|
31
|
-
# end
|
32
|
-
|
33
|
-
context "A PhoneNumber" do
|
34
|
-
specify "should have an ISN pattern-matching method" do
|
35
|
-
!! PhoneNumber.new("0115544332211").isn?.should == false
|
36
|
-
!! PhoneNumber.new("1*548").isn?.should === false
|
37
|
-
end
|
38
|
-
|
39
|
-
specify "should have a US local number pattern-matching method" do
|
40
|
-
!! PhoneNumber.new("18887776665555").local_number?.should == false
|
41
|
-
!! PhoneNumber.new("18887776665555").national_number?.should == true
|
42
|
-
|
43
|
-
!! PhoneNumber.new("8887776665555").local_number?.should == false
|
44
|
-
!! PhoneNumber.new("8887776665555").national_number?.should == true
|
45
|
-
|
46
|
-
!! PhoneNumber.new("4445555").local_number?.should == true
|
47
|
-
!! PhoneNumber.new("4445555").national_number?.should == false
|
48
|
-
end
|
49
|
-
|
50
|
-
specify "should convert from vanity numbers properly" do
|
51
|
-
PhoneNumber.from_vanity("1-800-FUDGEME").should == "18003834363"
|
52
|
-
end
|
53
|
-
end
|
data/test/test_micromenus.rb
DELETED
File without changes
|