agi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +223 -0
- data/README +19 -0
- data/Rakefile +20 -0
- data/VERSION +1 -0
- data/agi.gemspec +49 -0
- data/examples/call_log.rb +18 -0
- data/extconf.rb +2 -0
- data/lib/agi.rb +5 -0
- data/lib/agi/agi.rb +891 -0
- data/lib/agi/asterisk_variable.rb +239 -0
- data/lib/agi/command.rb +908 -0
- data/lib/agi/error.rb +45 -0
- data/lib/agi/return_status.rb +92 -0
- metadata +59 -0
data/lib/agi/error.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# File: error.rb
|
3
|
+
#
|
4
|
+
# agi: Ruby Language API for Asterisk
|
5
|
+
#
|
6
|
+
# Copyright (C) <2005> Mohammad Khan <info@beeplove.com>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
# all the subclass of Exception is defined here
|
24
|
+
|
25
|
+
|
26
|
+
class Error < Exception
|
27
|
+
end
|
28
|
+
|
29
|
+
class DigitError < Exception
|
30
|
+
end
|
31
|
+
|
32
|
+
class HangupError < Exception
|
33
|
+
end
|
34
|
+
|
35
|
+
#class TimeoutError < Exception
|
36
|
+
#end
|
37
|
+
|
38
|
+
class ChannelError < Exception
|
39
|
+
end
|
40
|
+
|
41
|
+
class CommandError < Exception
|
42
|
+
end
|
43
|
+
|
44
|
+
class AGIError < Exception
|
45
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#
|
2
|
+
# File: return_status.rb
|
3
|
+
#
|
4
|
+
# agi: Ruby Language API for Asterisk
|
5
|
+
#
|
6
|
+
# Copyright (C) <2005> Mohammad Khan <info@beeplove.com>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
|
24
|
+
# every method of this class would return string or boolean
|
25
|
+
# methods of command class usually return ReturnStatus object
|
26
|
+
|
27
|
+
class ReturnStatus
|
28
|
+
|
29
|
+
def initialize(command, message)
|
30
|
+
@command = command.chomp
|
31
|
+
@message = message
|
32
|
+
@result = nil
|
33
|
+
@digit = nil
|
34
|
+
@digits = nil
|
35
|
+
@return_code = nil
|
36
|
+
@command_error = false
|
37
|
+
|
38
|
+
if message.nil?
|
39
|
+
@messsage = "No responses !!"
|
40
|
+
else
|
41
|
+
str = @message.split(' ')
|
42
|
+
@return_code = str[0]
|
43
|
+
if @return_code == '200'
|
44
|
+
@result = str[1].split('=')[1]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
public
|
50
|
+
def to_s
|
51
|
+
return @command.to_s + ' >> ' + @message.to_s
|
52
|
+
end
|
53
|
+
|
54
|
+
public
|
55
|
+
def result
|
56
|
+
return @result.to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
public
|
60
|
+
def digit
|
61
|
+
if (@result == '0')
|
62
|
+
return nil
|
63
|
+
else
|
64
|
+
return @result.to_i.chr
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
public
|
69
|
+
def digits
|
70
|
+
return @result.to_s
|
71
|
+
end
|
72
|
+
|
73
|
+
public
|
74
|
+
def message
|
75
|
+
return @message.to_s
|
76
|
+
end
|
77
|
+
|
78
|
+
public
|
79
|
+
def command_error?
|
80
|
+
return (result.nil? or (not (@return_code == '200')))
|
81
|
+
end
|
82
|
+
|
83
|
+
public
|
84
|
+
def timeout?
|
85
|
+
rgx = Regexp.new(/\(timeout\)/)
|
86
|
+
if rgx.match(@message)
|
87
|
+
return true
|
88
|
+
else
|
89
|
+
return false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: agi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexey Gordienko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2915-09-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This is a fork of ruby-agi version 1.1.2 by Mohammad Khan.
|
14
|
+
email: alx@anadyr.org
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files:
|
18
|
+
- LICENSE
|
19
|
+
- README
|
20
|
+
files:
|
21
|
+
- LICENSE
|
22
|
+
- README
|
23
|
+
- Rakefile
|
24
|
+
- VERSION
|
25
|
+
- agi.gemspec
|
26
|
+
- examples/call_log.rb
|
27
|
+
- extconf.rb
|
28
|
+
- lib/agi.rb
|
29
|
+
- lib/agi/agi.rb
|
30
|
+
- lib/agi/asterisk_variable.rb
|
31
|
+
- lib/agi/command.rb
|
32
|
+
- lib/agi/error.rb
|
33
|
+
- lib/agi/return_status.rb
|
34
|
+
homepage: http://github.com/gordienko/agi
|
35
|
+
licenses: []
|
36
|
+
metadata: {}
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options:
|
39
|
+
- "--charset=UTF-8"
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.4.5.1
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Ruby AGI interface into Asterisk
|
58
|
+
test_files:
|
59
|
+
- examples/call_log.rb
|