redial-ruby-agi 2.0.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.
Files changed (44) hide show
  1. data/ChangeLog +44 -0
  2. data/LICENSE +222 -0
  3. data/README.md +25 -0
  4. data/Rakefile +20 -0
  5. data/VERSION +1 -0
  6. data/examples/call_log.rb +18 -0
  7. data/lib/ruby-agi.rb +5 -0
  8. data/lib/ruby-agi/agi.rb +891 -0
  9. data/lib/ruby-agi/asterisk_variable.rb +242 -0
  10. data/lib/ruby-agi/command.rb +911 -0
  11. data/lib/ruby-agi/error.rb +48 -0
  12. data/lib/ruby-agi/return_status.rb +31 -0
  13. data/lib/ruby-agi/rs/answer.rb +68 -0
  14. data/lib/ruby-agi/rs/channel_status.rb +127 -0
  15. data/lib/ruby-agi/rs/exec.rb +69 -0
  16. data/lib/ruby-agi/rs/get_variable.rb +76 -0
  17. data/lib/ruby-agi/rs/hangup.rb +76 -0
  18. data/lib/ruby-agi/rs/noop.rb +68 -0
  19. data/lib/ruby-agi/rs/receive_char.rb +112 -0
  20. data/lib/ruby-agi/rs/receive_text.rb +73 -0
  21. data/lib/ruby-agi/rs/record_file.rb +184 -0
  22. data/lib/ruby-agi/rs/result.rb +47 -0
  23. data/lib/ruby-agi/rs/return_status.rb +98 -0
  24. data/lib/ruby-agi/rs/say_digits.rb +85 -0
  25. data/lib/ruby-agi/rs/say_number.rb +88 -0
  26. data/lib/ruby-agi/rs/say_phonetic.rb +88 -0
  27. data/lib/ruby-agi/rs/say_time.rb +90 -0
  28. data/lib/ruby-agi/rs/send_image.rb +83 -0
  29. data/lib/ruby-agi/rs/send_text.rb +83 -0
  30. data/lib/ruby-agi/rs/set_auto_hangup.rb +69 -0
  31. data/lib/ruby-agi/rs/set_caller_id.rb +72 -0
  32. data/lib/ruby-agi/rs/set_context.rb +71 -0
  33. data/lib/ruby-agi/rs/set_extension.rb +72 -0
  34. data/lib/ruby-agi/rs/set_music.rb +71 -0
  35. data/lib/ruby-agi/rs/set_priority.rb +69 -0
  36. data/lib/ruby-agi/rs/set_variable.rb +76 -0
  37. data/lib/ruby-agi/rs/stream_file.rb +138 -0
  38. data/lib/ruby-agi/rs/tdd_mode.rb +95 -0
  39. data/lib/ruby-agi/rs/verbose.rb +73 -0
  40. data/lib/ruby-agi/rs/wait_for_digit.rb +90 -0
  41. data/lib/ruby-agi/rs/wait_for_digits.rb +88 -0
  42. data/ruby-agi.gemspec +51 -0
  43. data/test/unit.rb +37 -0
  44. metadata +94 -0
@@ -0,0 +1,73 @@
1
+ #
2
+ # File: verbose.rb
3
+ #
4
+ # ruby-agi: Ruby Language API for Asterisk
5
+ #
6
+ # Copyright (C) <2006> 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
+ require 'ruby-agi/rs/return_status'
24
+
25
+ #
26
+ # Sends <message> to the console via verbose message system.
27
+ # The Asterisk verbosity system works as follows.
28
+ # The Asterisk user gets to set the desired verbosity at startup time
29
+ # or later using the console 'set verbose' command.
30
+ # Messages are displayed on the console if their verbose level
31
+ # is less than or equal to desired verbosity set by the user.
32
+ # More important messages should have a low verbose level;
33
+ # less important messages should have a high verbose level.
34
+ #
35
+ # Command Reference: VERBOSE <message> [level]
36
+ #
37
+ # 200 result=1
38
+ #
39
+
40
+ class ReturnStatus
41
+ end
42
+
43
+ class Verbose < ReturnStatus
44
+
45
+ def initialize(command, response)
46
+ super(command, response)
47
+ end
48
+
49
+ def success?
50
+ if @is_success.nil?
51
+ if result == '1'
52
+ @is_success = true
53
+ else
54
+ @is_success = false
55
+ end
56
+ end
57
+
58
+ return @is_success
59
+ end
60
+
61
+ def failure?
62
+ return (not success?)
63
+ end
64
+
65
+ def error?
66
+ return command_error?
67
+ end
68
+
69
+ def response
70
+ return message
71
+ end
72
+
73
+ end
@@ -0,0 +1,90 @@
1
+ #
2
+ # File: wait_for_digit.rb
3
+ #
4
+ # ruby-agi: Ruby Language API for Asterisk
5
+ #
6
+ # Copyright (C) <2006> 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
+ require 'ruby-agi/rs/return_status'
24
+
25
+ #
26
+ # wait for digit: Waits for a digit to be pressed
27
+ # Waits up to <timeout> milliseconds for channel to receive a DTMF digit.
28
+ #
29
+ # Command Reference: WAIT FOR DIGIT <timeout>
30
+ #
31
+ # failure: 200 result=-1
32
+ # timeout: 200 result=0
33
+ # success: 200 result=<digit>
34
+ # <digit> is the ascii code for the digit received.
35
+ #
36
+
37
+ class ReturnStatus
38
+ end
39
+
40
+ class WaitForDigit < ReturnStatus
41
+
42
+ def initialize(command, response)
43
+ super(command, response)
44
+ end
45
+
46
+ def failure?
47
+ if @is_failure.nil?
48
+ if result == '-1'
49
+ @is_failure = true
50
+ else
51
+ @is_failure = false
52
+ end
53
+ end
54
+
55
+ return @is_failure
56
+ end
57
+
58
+ def timeout?
59
+ if @is_timeout.nil?
60
+ if result == '0'
61
+ @is_timeout = true
62
+ else
63
+ @is_timeout = false
64
+ end
65
+ end
66
+
67
+ return @is_timeout
68
+ end
69
+
70
+ def digit
71
+ if success?
72
+ return result.to_i.chr
73
+ else
74
+ return nil
75
+ end
76
+ end
77
+
78
+ def success?
79
+ return ((not timeout?) and (not failure?))
80
+ end
81
+
82
+ def error?
83
+ return command_error?
84
+ end
85
+
86
+ def response
87
+ return message
88
+ end
89
+
90
+ end
@@ -0,0 +1,88 @@
1
+ #
2
+ # File: wait_for_digits.rb
3
+ #
4
+ # ruby-agi: Ruby Language API for Asterisk
5
+ #
6
+ # Copyright (C) <2006> 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
+ require 'ruby-agi/rs/return_status'
24
+
25
+ #
26
+ # class to handle return status from Command#wait_for_digits
27
+ # pressing '#' will always terminate the input process
28
+ #
29
+ # Command Reference: GET DATA <file to be streamed> [timeout] [max digits]
30
+ #
31
+ # failure: 200 result=-1
32
+ # timeout: 200 result=<digits> (timeout)
33
+ # success: 200 result=<digits>
34
+ # <digits> is the digits pressed.
35
+ #
36
+
37
+ class ReturnStatus
38
+ end
39
+
40
+ class WaitForDigits < ReturnStatus
41
+
42
+ def initialize(command, response)
43
+ super(command, response)
44
+ end
45
+
46
+ def success?
47
+ return ((not failure?) and (not timeout?))
48
+ end
49
+
50
+ def failure?
51
+ if @is_failure.nil?
52
+ if result == '-1'
53
+ @is_failure = true
54
+ else
55
+ @is_failure = false
56
+ end
57
+ end
58
+
59
+ return @is_failure
60
+ end
61
+
62
+ public
63
+ def timeout?
64
+ if @is_timeout.nil?
65
+ rgx = Regexp.new(/\(timeout\)$/)
66
+ if rgx.match(response)
67
+ @is_timeout = true
68
+ else
69
+ @is_timeout = false
70
+ end
71
+ end
72
+
73
+ return @is_timeout
74
+ end
75
+
76
+ def digits
77
+ return result
78
+ end
79
+
80
+ def error?
81
+ return ((not timeout?) and command_error?)
82
+ end
83
+
84
+ def response
85
+ return message
86
+ end
87
+
88
+ end
data/ruby-agi.gemspec ADDED
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ruby-agi}
5
+ s.version = "1.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-08-11}
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
+ "LICENSE",
20
+ "README",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "examples/call_log.rb",
24
+ "extconf.rb",
25
+ "lib/erichmond-ruby-agi.rb",
26
+ "lib/erichmond-ruby-agi/agi.rb",
27
+ "lib/erichmond-ruby-agi/asterisk_variable.rb",
28
+ "lib/erichmond-ruby-agi/command.rb",
29
+ "lib/erichmond-ruby-agi/error.rb",
30
+ "lib/erichmond-ruby-agi/return_status.rb",
31
+ "ruby-agi.gemspec"
32
+ ]
33
+ s.homepage = %q{http://github.com/erichmond/ruby-agi}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.4}
37
+ s.summary = %q{Ruby AGI interface into Asterisk}
38
+ s.test_files = [
39
+ "examples/call_log.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
47
+ else
48
+ end
49
+ else
50
+ end
51
+ end
data/test/unit.rb ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby
2
+
3
+ #
4
+ # File: test.rb
5
+ #
6
+ # ruby-agi: Ruby Language API for Asterisk
7
+ #
8
+ # Copyright (C) <2006> Mohammad Khan <info@beeplove.com>
9
+ #
10
+ # This program is free software; you can redistribute it and/or modify
11
+ # it under the terms of the GNU General Public License as published by
12
+ # the Free Software Foundation; either version 2 of the License, or
13
+ # (at your option) any later version.
14
+ #
15
+ # This program is distributed in the hope that it will be useful,
16
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ # GNU General Public License for more details.
19
+ #
20
+ # You should have received a copy of the GNU General Public License
21
+ # along with this program; if not, write to the Free Software
22
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
+ #
24
+
25
+ class TestAGI < Test::Unit::TestCase
26
+ def setup
27
+ @agi = AGI.new
28
+ end
29
+
30
+ def test_variables
31
+
32
+ end
33
+
34
+ def teardown
35
+
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redial-ruby-agi
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mohammad Khan
9
+ - Carlos Lenz
10
+ - Chris Kairalla
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2013-01-24 00:00:00.000000000 Z
15
+ dependencies: []
16
+ description: This is a fork of ruby-agi version 2.0.0 by Mohammad Khan. We've made
17
+ some fixes for compatibility, so we've created a gem for our own local use that
18
+ other people are welcome to use, if it suits them.
19
+ email: chris@mailtochris.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files:
23
+ - ChangeLog
24
+ - LICENSE
25
+ - README.md
26
+ files:
27
+ - ChangeLog
28
+ - LICENSE
29
+ - README.md
30
+ - Rakefile
31
+ - VERSION
32
+ - examples/call_log.rb
33
+ - lib/ruby-agi.rb
34
+ - lib/ruby-agi/agi.rb
35
+ - lib/ruby-agi/asterisk_variable.rb
36
+ - lib/ruby-agi/command.rb
37
+ - lib/ruby-agi/error.rb
38
+ - lib/ruby-agi/return_status.rb
39
+ - lib/ruby-agi/rs/answer.rb
40
+ - lib/ruby-agi/rs/channel_status.rb
41
+ - lib/ruby-agi/rs/exec.rb
42
+ - lib/ruby-agi/rs/get_variable.rb
43
+ - lib/ruby-agi/rs/hangup.rb
44
+ - lib/ruby-agi/rs/noop.rb
45
+ - lib/ruby-agi/rs/receive_char.rb
46
+ - lib/ruby-agi/rs/receive_text.rb
47
+ - lib/ruby-agi/rs/record_file.rb
48
+ - lib/ruby-agi/rs/result.rb
49
+ - lib/ruby-agi/rs/return_status.rb
50
+ - lib/ruby-agi/rs/say_digits.rb
51
+ - lib/ruby-agi/rs/say_number.rb
52
+ - lib/ruby-agi/rs/say_phonetic.rb
53
+ - lib/ruby-agi/rs/say_time.rb
54
+ - lib/ruby-agi/rs/send_image.rb
55
+ - lib/ruby-agi/rs/send_text.rb
56
+ - lib/ruby-agi/rs/set_auto_hangup.rb
57
+ - lib/ruby-agi/rs/set_caller_id.rb
58
+ - lib/ruby-agi/rs/set_context.rb
59
+ - lib/ruby-agi/rs/set_extension.rb
60
+ - lib/ruby-agi/rs/set_music.rb
61
+ - lib/ruby-agi/rs/set_priority.rb
62
+ - lib/ruby-agi/rs/set_variable.rb
63
+ - lib/ruby-agi/rs/stream_file.rb
64
+ - lib/ruby-agi/rs/tdd_mode.rb
65
+ - lib/ruby-agi/rs/verbose.rb
66
+ - lib/ruby-agi/rs/wait_for_digit.rb
67
+ - lib/ruby-agi/rs/wait_for_digits.rb
68
+ - ruby-agi.gemspec
69
+ - test/unit.rb
70
+ homepage: https://github.com/itp-redial/ruby-agi
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 1.8.24
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: Ruby AGI interface into Asterisk
94
+ test_files: []