erichmond-ruby-agi 0.1.1
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 +38 -0
- data/DOWNLOAD +3 -0
- data/INSTALL +11 -0
- data/LICENSE +223 -0
- data/README +14 -0
- data/Rakefile +20 -0
- data/Release-Notes +11 -0
- data/VERSION +1 -0
- data/examples/call_log.rb +18 -0
- data/extconf.rb +2 -0
- data/lib/ruby-agi/agi.rb +891 -0
- data/lib/ruby-agi/asterisk_variable.rb +239 -0
- data/lib/ruby-agi/command.rb +908 -0
- data/lib/ruby-agi/error.rb +45 -0
- data/lib/ruby-agi/return_status.rb +92 -0
- data/lib/ruby-agi.rb +5 -0
- data/ruby-agi.gemspec +54 -0
- metadata +73 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# File: error.rb
|
3
|
+
#
|
4
|
+
# ruby-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
|
+
# ruby-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
|
data/lib/ruby-agi.rb
ADDED
data/ruby-agi.gemspec
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ruby-agi}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Mohammad Khan", "Carlos Lenz", "Eric Richmond"]
|
9
|
+
s.date = %q{2009-07-20}
|
10
|
+
s.description = %q{This is a fork of ruby-agi version 1.1.2 by Mohammad Khan. We've made some fixes for rails compatibility, and preferred the v1.1.2 codebase over the 2.0.0 codebase, so we've created a gem for our own local use that other people are welcome to use, if it suits them.}
|
11
|
+
s.email = %q{eric@newvo.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"ChangeLog",
|
14
|
+
"LICENSE",
|
15
|
+
"README"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
"ChangeLog",
|
19
|
+
"DOWNLOAD",
|
20
|
+
"INSTALL",
|
21
|
+
"LICENSE",
|
22
|
+
"README",
|
23
|
+
"Rakefile",
|
24
|
+
"Release-Notes",
|
25
|
+
"VERSION",
|
26
|
+
"examples/call_log.rb",
|
27
|
+
"extconf.rb",
|
28
|
+
"lib/ruby-agi.rb",
|
29
|
+
"lib/ruby-agi/agi.rb",
|
30
|
+
"lib/ruby-agi/asterisk_variable.rb",
|
31
|
+
"lib/ruby-agi/command.rb",
|
32
|
+
"lib/ruby-agi/error.rb",
|
33
|
+
"lib/ruby-agi/return_status.rb",
|
34
|
+
"ruby-agi.gemspec"
|
35
|
+
]
|
36
|
+
s.homepage = %q{http://github.com/erichmond/ruby-agi}
|
37
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = %q{1.3.4}
|
40
|
+
s.summary = %q{Ruby AGI interface into Asterisk}
|
41
|
+
s.test_files = [
|
42
|
+
"examples/call_log.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
else
|
51
|
+
end
|
52
|
+
else
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: erichmond-ruby-agi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mohammad Khan
|
8
|
+
- Carlos Lenz
|
9
|
+
- Eric Richmond
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2009-07-20 00:00:00 -07:00
|
15
|
+
default_executable:
|
16
|
+
dependencies: []
|
17
|
+
|
18
|
+
description: This is a fork of ruby-agi version 1.1.2 by Mohammad Khan. We've made some fixes for rails compatibility, and preferred the v1.1.2 codebase over the 2.0.0 codebase, so we've created a gem for our own local use that other people are welcome to use, if it suits them.
|
19
|
+
email: eric@newvo.com
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files:
|
25
|
+
- ChangeLog
|
26
|
+
- LICENSE
|
27
|
+
- README
|
28
|
+
files:
|
29
|
+
- ChangeLog
|
30
|
+
- DOWNLOAD
|
31
|
+
- INSTALL
|
32
|
+
- LICENSE
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- Release-Notes
|
36
|
+
- VERSION
|
37
|
+
- examples/call_log.rb
|
38
|
+
- extconf.rb
|
39
|
+
- lib/ruby-agi.rb
|
40
|
+
- lib/ruby-agi/agi.rb
|
41
|
+
- lib/ruby-agi/asterisk_variable.rb
|
42
|
+
- lib/ruby-agi/command.rb
|
43
|
+
- lib/ruby-agi/error.rb
|
44
|
+
- lib/ruby-agi/return_status.rb
|
45
|
+
- ruby-agi.gemspec
|
46
|
+
has_rdoc: false
|
47
|
+
homepage: http://github.com/erichmond/ruby-agi
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options:
|
50
|
+
- --charset=UTF-8
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.2.0
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Ruby AGI interface into Asterisk
|
72
|
+
test_files:
|
73
|
+
- examples/call_log.rb
|