ruby-agi 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +25 -6
- data/Release-Notes +9 -0
- data/lib/ruby-agi/agi.rb +35 -4
- data/lib/ruby-agi/asterisk_variable.rb +102 -28
- data/lib/ruby-agi/command.rb +11 -0
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,10 +1,29 @@
|
|
1
|
-
2006-01-
|
2
|
-
|
1
|
+
2006-01-16 (revision 23)
|
2
|
+
-- ruby-agi-1.1.0 released
|
3
|
+
-- method calleridnumber added and is generated from callerid
|
4
|
+
-- method calleridname gets name from callerid method,
|
5
|
+
currently I found asterisk returns nothing because of missing agi_calleridname
|
6
|
+
-- method jump_to added
|
7
|
+
|
8
|
+
2006-01-10 (revision 22)
|
9
|
+
-- following files added to svn repository
|
10
|
+
ruby-agi-1.0.1.gem
|
11
|
+
ruby-agi-1.0.2.gem
|
12
|
+
Release-Notes
|
13
|
+
ruby-agi-1.0.2.tgz
|
14
|
+
|
15
|
+
2006-01-09 (revision 21)
|
16
|
+
-- gemspec file updated to work properly with ruby-1.8.3
|
17
|
+
|
3
18
|
2006-01-08 (revision 20)
|
4
|
-
ruby-agi-1.0.1 released
|
19
|
+
-- ruby-agi-1.0.1 released
|
20
|
+
|
5
21
|
2006-01-08 (revision 19)
|
6
|
-
examples/call_log.rb added
|
22
|
+
-- examples/call_log.rb added
|
23
|
+
|
7
24
|
2006-01-08 (revision 18)
|
8
|
-
ruby-agi-0.0.2.gem removed from subversion repository
|
25
|
+
-- ruby-agi-0.0.2.gem removed from subversion repository
|
26
|
+
|
9
27
|
2006-01-08 (revision 17)
|
10
|
-
Started to maintain ChangeLog !!
|
28
|
+
-- Started to maintain ChangeLog !!
|
29
|
+
|
data/Release-Notes
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.1.0 (2006-01-17)
|
2
|
+
addition of method 'jump_to'
|
3
|
+
jump_to would take three arguments ex. jump_to(context, extension, priority)
|
4
|
+
enhanced callerid, calleridname and calleridnumber. calleridnumber is an addtional method to this release.
|
5
|
+
Regardless of Asterisk version above three caller variables would return uniform value.
|
6
|
+
Such as, callerid would return "John Smith" <1234567890> or empty string, if unidentified
|
7
|
+
calleridnumber would return number part of callerid (as string) ex. 1234567890 or empty string, if unidentified
|
8
|
+
calleridname would return name part of callerid ex. John Smith or emtpy string, if unidentified
|
9
|
+
|
1
10
|
1.0.2 (2006-01-09)
|
2
11
|
Because of a yaml bug in ruby-1.8.3, rubyforge server doesn't support any package that were built on ruby-1.8.3
|
3
12
|
This version is basically re-build of version 1.0.1 on ruby-1.8.4 instead of ruby-1.8.3
|
data/lib/ruby-agi/agi.rb
CHANGED
@@ -243,29 +243,45 @@ class AGI
|
|
243
243
|
end
|
244
244
|
|
245
245
|
#
|
246
|
-
#
|
246
|
+
# method to read callerid, Ex. "John Smith" <1234567890>
|
247
|
+
# regardless of asterisk version, method callerid would return "Caller Name" <Number>
|
247
248
|
#
|
248
249
|
# <b>Parameters</b>
|
249
250
|
# - none
|
251
|
+
#
|
250
252
|
# <b>Returns</b>
|
251
|
-
# - String
|
253
|
+
# - String : empty string for Unidentified
|
252
254
|
#
|
253
255
|
def callerid
|
254
256
|
return env.callerid
|
255
257
|
end
|
256
258
|
|
257
259
|
#
|
258
|
-
#
|
260
|
+
# method to read calleridname, Ex. John Smith
|
259
261
|
#
|
260
262
|
# <b>Parameters</b>
|
261
263
|
# - none
|
264
|
+
#
|
262
265
|
# <b>Returns</b>
|
263
|
-
# - String
|
266
|
+
# - String : empty string for Unidentified
|
264
267
|
#
|
265
268
|
def calleridname
|
266
269
|
return env.calleridname
|
267
270
|
end
|
268
271
|
|
272
|
+
#
|
273
|
+
# method to read calleridnumber, Ex. 1234567890
|
274
|
+
#
|
275
|
+
# <b>Parameters</b>
|
276
|
+
# - none
|
277
|
+
#
|
278
|
+
# <b>Returns</b>
|
279
|
+
# - String : empty string for Unidentified
|
280
|
+
#
|
281
|
+
def calleridnumber
|
282
|
+
return env.calleridnumber
|
283
|
+
end
|
284
|
+
|
269
285
|
#
|
270
286
|
# <method description>
|
271
287
|
#
|
@@ -843,5 +859,20 @@ class AGI
|
|
843
859
|
def dial(telephone_number=nil, protocol=nil, username=nil, context=nil, timeout=nil, options=nil)
|
844
860
|
return command.dial(telephone_number, protocol, username, context, timeout, options)
|
845
861
|
end
|
862
|
+
|
863
|
+
#
|
864
|
+
# method to jump in a specified context, extension and priority
|
865
|
+
#
|
866
|
+
# <b>Parameters</b>
|
867
|
+
# - context : name of the context
|
868
|
+
# - extension : name of the extension
|
869
|
+
# - priority : name of the priority
|
870
|
+
#
|
871
|
+
# <b>Returns</b>
|
872
|
+
# - none
|
873
|
+
#
|
874
|
+
def jump_to(context=nil, extension=nil, priority=nil)
|
875
|
+
command.jump_to(context, extension, priority)
|
876
|
+
end
|
846
877
|
end
|
847
878
|
|
@@ -23,6 +23,22 @@
|
|
23
23
|
# == Overview
|
24
24
|
#
|
25
25
|
|
26
|
+
# Followings are the list of AGI variables
|
27
|
+
# -- ruby-agi >> agi_request
|
28
|
+
# -- ruby-agi >> agi_channel
|
29
|
+
# -- ruby-agi >> agi_language
|
30
|
+
# -- ruby-agi >> agi_type
|
31
|
+
# -- ruby-agi >> agi_uniqueid
|
32
|
+
# -- ruby-agi >> agi_callerid
|
33
|
+
# -- ruby-agi >> agi_dnid
|
34
|
+
# -- ruby-agi >> agi_rdnis
|
35
|
+
# -- ruby-agi >> agi_context
|
36
|
+
# -- ruby-agi >> agi_extension
|
37
|
+
# -- ruby-agi >> agi_priority
|
38
|
+
# -- ruby-agi >> agi_enhanced
|
39
|
+
# -- ruby-agi >> agi_accountcode
|
40
|
+
|
41
|
+
|
26
42
|
require 'ruby-agi/agi.rb'
|
27
43
|
require 'ruby-agi/error.rb'
|
28
44
|
|
@@ -56,15 +72,14 @@ class AsteriskVariable < AGI
|
|
56
72
|
|
57
73
|
protected
|
58
74
|
def read_env(name)
|
59
|
-
val = env[name]
|
60
75
|
if debug?
|
61
76
|
semaphore do
|
62
77
|
$stderr.puts " -- ruby-agi << Read asterisk variable '#{name}'"
|
63
|
-
$stderr.puts " -- ruby-agi >> Asterisk variable #{name} = #{
|
78
|
+
$stderr.puts " -- ruby-agi >> Asterisk variable #{name} = #{env[name].to_s}"
|
64
79
|
end
|
65
80
|
end
|
66
81
|
|
67
|
-
return
|
82
|
+
return env[name]
|
68
83
|
end
|
69
84
|
|
70
85
|
public
|
@@ -94,32 +109,11 @@ class AsteriskVariable < AGI
|
|
94
109
|
|
95
110
|
public
|
96
111
|
def callerid
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
public
|
101
|
-
def calleridname
|
102
|
-
return read_env('agi_calleridname')
|
103
|
-
end
|
104
|
-
|
105
|
-
public
|
106
|
-
def callingpres
|
107
|
-
return read_env('agi_callingpres')
|
108
|
-
end
|
109
|
-
|
110
|
-
public
|
111
|
-
def callingani2
|
112
|
-
return read_env('agi_callingani2')
|
113
|
-
end
|
114
|
-
|
115
|
-
public
|
116
|
-
def callington
|
117
|
-
return read_env('agi_callington')
|
118
|
-
end
|
112
|
+
if @callerid.nil?
|
113
|
+
init_caller_variable
|
114
|
+
end
|
119
115
|
|
120
|
-
|
121
|
-
def callingtns
|
122
|
-
return read_env('agi_callingtns')
|
116
|
+
return @callerid
|
123
117
|
end
|
124
118
|
|
125
119
|
public
|
@@ -156,4 +150,84 @@ class AsteriskVariable < AGI
|
|
156
150
|
def accountcode
|
157
151
|
return read_env('agi_accountcode')
|
158
152
|
end
|
153
|
+
|
154
|
+
####################################################################
|
155
|
+
#### additional methods generated from existing basic methods ####
|
156
|
+
####################################################################
|
157
|
+
|
158
|
+
public
|
159
|
+
def calleridname
|
160
|
+
if @calleridname.nil?
|
161
|
+
init_caller_variable
|
162
|
+
end
|
163
|
+
|
164
|
+
return @calleridname
|
165
|
+
end
|
166
|
+
|
167
|
+
public
|
168
|
+
def calleridnumber
|
169
|
+
if @calleridnumber.nil?
|
170
|
+
init_caller_variable
|
171
|
+
end
|
172
|
+
|
173
|
+
return @calleridnumber
|
174
|
+
end
|
175
|
+
|
176
|
+
# following methods are not confirm that they are AGI variables
|
177
|
+
public
|
178
|
+
def callingpres
|
179
|
+
return read_env('agi_callingpres')
|
180
|
+
end
|
181
|
+
|
182
|
+
public
|
183
|
+
def callingani2
|
184
|
+
return read_env('agi_callingani2')
|
185
|
+
end
|
186
|
+
|
187
|
+
public
|
188
|
+
def callington
|
189
|
+
return read_env('agi_callington')
|
190
|
+
end
|
191
|
+
|
192
|
+
public
|
193
|
+
def callingtns
|
194
|
+
return read_env('agi_callingtns')
|
195
|
+
end
|
196
|
+
|
197
|
+
protected
|
198
|
+
def init_caller_variable
|
199
|
+
if read_env('callerid') == "unknown"
|
200
|
+
@callerid = ""
|
201
|
+
@calleridname = ""
|
202
|
+
@calleridnumber = ""
|
203
|
+
else
|
204
|
+
if read_env('calleridname').nil? # for asterisk that don't have agi variable 'agi_calleridname'
|
205
|
+
@callerid = read_env('callerid')
|
206
|
+
name = Regexp.new(/\".+\"/).match(@callerid)
|
207
|
+
number = Regexp.new(/\<\d+\>/).match(@callerid)
|
208
|
+
|
209
|
+
if name.nil?
|
210
|
+
@calleridname = ""
|
211
|
+
else
|
212
|
+
name = name.to_s
|
213
|
+
name.gsub!(/\"/, '')
|
214
|
+
@calleridname = name.strip
|
215
|
+
end
|
216
|
+
|
217
|
+
if number.nil?
|
218
|
+
@calleridnumber = ""
|
219
|
+
else
|
220
|
+
number = number.to_s
|
221
|
+
number.sub!(/\</, '')
|
222
|
+
number.sub!(/\>/, '')
|
223
|
+
@calleridnumber = number
|
224
|
+
end
|
225
|
+
else # for asterisk that have agi variable 'agi_calleridname'
|
226
|
+
@calleridnumber = read_env('callerid')
|
227
|
+
@calleridname = read_env('calleridname')
|
228
|
+
@callerid = "\"#{@calleridname}\" <#{@calleridnumber}>"
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
159
233
|
end
|
data/lib/ruby-agi/command.rb
CHANGED
@@ -894,4 +894,15 @@ class Command < AGI
|
|
894
894
|
|
895
895
|
return max_digit
|
896
896
|
end
|
897
|
+
|
898
|
+
############################################
|
899
|
+
### More synthetic methods ###
|
900
|
+
############################################
|
901
|
+
|
902
|
+
public
|
903
|
+
def jump_to(context, extension, priority)
|
904
|
+
set_context(context) if not context.nil?
|
905
|
+
set_extension(extension) if not extension.nil?
|
906
|
+
set_priority(priority) if not priority.nil?
|
907
|
+
end
|
897
908
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-agi
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0
|
7
|
-
date: 2006-01-
|
6
|
+
version: 1.1.0
|
7
|
+
date: 2006-01-17 00:00:00 -05:00
|
8
8
|
summary: Ruby Language API for Asterisk
|
9
9
|
require_paths:
|
10
10
|
- lib
|