ruby-asterisk 0.0.7 → 0.1.0
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.
- checksums.yaml +7 -0
- data/README.md +55 -0
- data/lib/ruby-asterisk.rb +121 -90
- data/lib/ruby-asterisk/request.rb +21 -21
- data/lib/ruby-asterisk/response.rb +125 -77
- data/lib/ruby-asterisk/version.rb +1 -1
- data/spec/ruby-asterisk/response_spec.rb +28 -0
- data/spec/ruby-asterisk/ruby_asterisk_spec.rb +8 -0
- metadata +48 -51
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53c6e14b4aa50cd5f5e4742021d1b806c58ee640
|
4
|
+
data.tar.gz: 21d66e82b5e2755110f83c6fcecd235560cd992b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: be06cc29301f21aafa7a9d9d72cdfff8cca8cd1822fa447096e60f3db791f3d3bc6cdae8eb3bf8c506d63c077cb8f433ffb55cc01d3856c5f296e81ce6f47ba4
|
7
|
+
data.tar.gz: ecca78c7fa306058acc211ff90d6d330b0009f3219d3315fd2123190491e678b12103a6e3d3f510edf388a6782efc41f41a3309b1ae4556a8cadd69e51e62ec6
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# RUBY-ASTERISK
|
2
2
|
|
3
|
+
[](https://codeclimate.com/github/emilianodellacasa/ruby-asterisk)
|
4
|
+
|
3
5
|
This gem add support to your Ruby or RubyOnRails projects to Asterisk Manager Interface
|
4
6
|
|
5
7
|
There was a project with the same name, but it appears to be discontinued so I decided to start a new project
|
@@ -90,6 +92,58 @@ To get the state of an extension use the following command
|
|
90
92
|
```ruby
|
91
93
|
@ami.extension_state(@exten,@context)
|
92
94
|
```
|
95
|
+
### SKINNY DEVICES AND LINES
|
96
|
+
|
97
|
+
To get list of skinny devices
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
@ami.skinny_devices
|
101
|
+
```
|
102
|
+
|
103
|
+
To get list of skinny lines
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
@ami.skinny_lines
|
107
|
+
```
|
108
|
+
|
109
|
+
### QUEUE PAUSE
|
110
|
+
|
111
|
+
To pause or unpause a member in a call queue
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
@ami.queue_pause("SIP/100", "true", "myqueue", "reason")
|
115
|
+
```
|
116
|
+
|
117
|
+
### PING
|
118
|
+
|
119
|
+
To ping asterisk AMI
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
@ami.ping
|
123
|
+
```
|
124
|
+
|
125
|
+
### EVENT MASK
|
126
|
+
|
127
|
+
To enable or disable sending events to this manager connection
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
@ami.event_mask("on")
|
131
|
+
```
|
132
|
+
|
133
|
+
### SIPpeers
|
134
|
+
|
135
|
+
To get a list of sip peers (equivalent to "sip show peers" call on the asterisk server). This can be used to get a buddy list.
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
@ami.sip_peers
|
139
|
+
```
|
140
|
+
|
141
|
+
### STATUS
|
142
|
+
|
143
|
+
To get a status of a single channel or for all channels
|
144
|
+
```ruby
|
145
|
+
@ami.status
|
146
|
+
```
|
93
147
|
|
94
148
|
### THE RESPONSE OBJECT
|
95
149
|
|
@@ -100,6 +154,7 @@ The response object contains all information about all data received from Asteri
|
|
100
154
|
- action_id
|
101
155
|
- message
|
102
156
|
- data
|
157
|
+
- raw_response
|
103
158
|
|
104
159
|
The data property contains all additional information obtained from Asterisk, like for example the list of active channels after a "core show channels" command.
|
105
160
|
|
data/lib/ruby-asterisk.rb
CHANGED
@@ -5,113 +5,144 @@ require "ruby-asterisk/response"
|
|
5
5
|
require 'net/telnet'
|
6
6
|
|
7
7
|
module RubyAsterisk
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
begin
|
20
|
-
@session = Net::Telnet::new("Host" => self.host,"Port" => self.port)
|
21
|
-
self.connected = true
|
22
|
-
rescue Exception => ex
|
23
|
-
false
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def disconnect
|
8
|
+
class AMI
|
9
|
+
attr_accessor :host, :port, :connected
|
10
|
+
|
11
|
+
def initialize(host,port)
|
12
|
+
self.host = host.to_s
|
13
|
+
self.port = port.to_i
|
14
|
+
self.connected = false
|
15
|
+
@session = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def connect
|
28
19
|
begin
|
29
|
-
@session.
|
30
|
-
|
31
|
-
self.connected = false
|
32
|
-
true
|
20
|
+
@session = Net::Telnet::new("Host" => self.host,"Port" => self.port)
|
21
|
+
self.connected = true
|
33
22
|
rescue Exception => ex
|
34
|
-
puts ex
|
35
23
|
false
|
36
24
|
end
|
37
25
|
end
|
38
26
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
Response.new("Login",request.response_data)
|
49
|
-
end
|
50
|
-
|
51
|
-
def command(command)
|
52
|
-
request = Request.new("Command",{ "Command" => command })
|
53
|
-
request.commands.each do |command|
|
54
|
-
@session.write(command)
|
55
|
-
end
|
56
|
-
@session.waitfor("String" => "ActionID: "+request.action_id, "Timeout" => 3) do |data|
|
57
|
-
request.response_data << data
|
27
|
+
def disconnect
|
28
|
+
begin
|
29
|
+
@session.close if self.connected
|
30
|
+
@session = nil
|
31
|
+
self.connected = false
|
32
|
+
true
|
33
|
+
rescue Exception => ex
|
34
|
+
puts ex
|
35
|
+
false
|
58
36
|
end
|
59
|
-
|
60
|
-
end
|
37
|
+
end
|
61
38
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
@session.waitfor("String" => "ActionID: "+request.action_id, "Timeout" => 3) do |data|
|
68
|
-
request.response_data << data
|
69
|
-
end
|
70
|
-
Response.new("CoreShowChannels",request.response_data)
|
71
|
-
end
|
39
|
+
def login(username,password)
|
40
|
+
self.connect unless self.connected
|
41
|
+
execute "Login", {"Username" => username, "Secret" => password, "Event" => "On"}
|
42
|
+
end
|
72
43
|
|
73
|
-
|
74
|
-
|
75
|
-
request.commands.each do |command|
|
76
|
-
@session.write(command)
|
77
|
-
end
|
78
|
-
@session.waitfor("String" => "ActionID: "+request.action_id, "Timeout" => 3) do |data|
|
79
|
-
request.response_data << data
|
80
|
-
end
|
81
|
-
Response.new("MeetMeList",request.response_data)
|
44
|
+
def command(command)
|
45
|
+
execute "Command", {"Command" => command}
|
82
46
|
end
|
83
47
|
|
84
|
-
|
85
|
-
|
86
|
-
request.commands.each do |command|
|
87
|
-
@session.write(command)
|
88
|
-
end
|
89
|
-
@session.waitfor("String" => "ActionID: "+request.action_id, "Timeout" => 3) do |data|
|
90
|
-
request.response_data << data
|
91
|
-
end
|
92
|
-
Response.new("ParkedCalls",request.response_data)
|
48
|
+
def core_show_channels
|
49
|
+
execute "CoreShowChannels"
|
93
50
|
end
|
94
51
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
52
|
+
def meet_me_list
|
53
|
+
execute "MeetMeList"
|
54
|
+
end
|
55
|
+
|
56
|
+
def parked_calls
|
57
|
+
execute "ParkedCalls"
|
58
|
+
end
|
59
|
+
|
60
|
+
def extension_state(exten, context, action_id=nil)
|
61
|
+
execute "ExtensionState", {"Exten" => exten, "Context" => context, "ActionID" => action_id}
|
104
62
|
end
|
105
63
|
|
106
|
-
|
107
|
-
|
108
|
-
|
64
|
+
def skinny_devices
|
65
|
+
execute "SKINNYdevices"
|
66
|
+
end
|
67
|
+
|
68
|
+
def skinny_lines
|
69
|
+
execute "SKINNYlines"
|
70
|
+
end
|
71
|
+
|
72
|
+
def status(channel=nil,action_id=nil)
|
73
|
+
execute "Status", {"Channel" => channel, "ActionID" => action_id}
|
74
|
+
end
|
75
|
+
|
76
|
+
def originate(caller,context,callee,priority,variable=nil)
|
77
|
+
execute "Originate", {"Channel" => caller, "Context" => context, "Exten" => callee, "Priority" => priority, "Callerid" => caller, "Timeout" => "30000", "Variable" => variable }
|
78
|
+
end
|
79
|
+
|
80
|
+
def channels
|
81
|
+
execute "Command", { "Command" => "show channels" }
|
82
|
+
end
|
83
|
+
|
84
|
+
def redirect(caller,context,callee,priority,variable=nil)
|
85
|
+
execute "Redirect", {"Channel" => caller, "Context" => context, "Exten" => callee, "Priority" => priority, "Callerid" => caller, "Timeout" => "30000", "Variable" => variable}
|
86
|
+
end
|
87
|
+
|
88
|
+
def queues
|
89
|
+
execute "Queues", {}
|
90
|
+
end
|
91
|
+
|
92
|
+
def queue_add(queue, exten, penalty=2, paused=false, member_name)
|
93
|
+
execute "QueueAdd", {"Queue" => queue, "Interface" => exten, "Penalty" => penalty, "Paused" => paused, "MemberName" => member_name}
|
94
|
+
end
|
95
|
+
|
96
|
+
def queue_pause(queue, exten)
|
97
|
+
execute "QueuePause", {"Interface" => exten, "Paused" => paused}
|
98
|
+
end
|
99
|
+
|
100
|
+
def queue_remove(queue, exten)
|
101
|
+
execute "QueueRemove", {"Queue" => queue, "Interface" => exten}
|
102
|
+
end
|
103
|
+
|
104
|
+
def queue_status
|
105
|
+
execute "QueueStatus"
|
106
|
+
end
|
107
|
+
|
108
|
+
def queue_summary(queue)
|
109
|
+
execute "QueueSummary", {"Queue" => queue}
|
110
|
+
end
|
111
|
+
|
112
|
+
def mailbox_status(exten, context="default")
|
113
|
+
execute "MailboxStatus", {"Mailbox" => "#{exten}@#{context}"}
|
114
|
+
end
|
115
|
+
|
116
|
+
def mailbox_count(exten, context="default")
|
117
|
+
execute "MailboxCount", {"Mailbox" => "#{exten}@#{context}"}
|
118
|
+
end
|
119
|
+
|
120
|
+
def queue_pause(interface,paused,queue,reason='none')
|
121
|
+
execute "QueuePause", {"Interface" => interface, "Paused" => paused, "Queue" => queue, "Reason" => reason}
|
122
|
+
end
|
123
|
+
|
124
|
+
def ping
|
125
|
+
execute "Ping"
|
126
|
+
end
|
127
|
+
|
128
|
+
def event_mask(event_mask="off")
|
129
|
+
execute "Events", {"EventMask" => event_mask}
|
130
|
+
end
|
131
|
+
|
132
|
+
def sip_peers
|
133
|
+
execute "SIPpeers"
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
def execute(command, options={})
|
138
|
+
request = Request.new(command, options)
|
139
|
+
request.commands.each do |command|
|
109
140
|
@session.write(command)
|
110
141
|
end
|
111
|
-
@session.waitfor("
|
142
|
+
@session.waitfor("Match" => /ActionID: #{request.action_id}.*?\n\n/m, "Timeout" => 10) do |data|
|
112
143
|
request.response_data << data
|
113
144
|
end
|
114
|
-
Response.new(
|
115
|
-
|
116
|
-
|
145
|
+
Response.new(command,request.response_data)
|
146
|
+
end
|
147
|
+
end
|
117
148
|
end
|
@@ -1,32 +1,32 @@
|
|
1
1
|
module RubyAsterisk
|
2
|
-
|
3
|
-
|
2
|
+
class Request
|
3
|
+
attr_accessor :action, :action_id, :parameters, :response_data
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
def initialize(action,parameters={})
|
6
|
+
self.action = action
|
7
|
+
self.action_id = self.generate_action_id
|
8
|
+
self.parameters = parameters
|
9
|
+
self.response_data = ""
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
def commands
|
13
|
+
_commands=["Action: "+self.action+"\r\n","ActionID: "+self.action_id+"\r\n"]
|
14
|
+
self.parameters.each do |key,value|
|
15
|
+
_commands<<key+": "+value+"\r\n" unless value.nil?
|
16
|
+
end
|
17
|
+
_commands[_commands.length-1]<<"\r\n"
|
18
|
+
_commands
|
19
|
+
end
|
20
20
|
|
21
|
-
|
21
|
+
protected
|
22
22
|
|
23
|
-
|
23
|
+
def generate_action_id
|
24
24
|
if RUBY_VERSION.start_with?("1.9")
|
25
|
-
|
25
|
+
Random.rand(999).to_s
|
26
26
|
else
|
27
27
|
rand(999).to_s
|
28
28
|
end
|
29
|
-
|
29
|
+
end
|
30
30
|
|
31
|
-
|
31
|
+
end
|
32
32
|
end
|
@@ -1,114 +1,162 @@
|
|
1
1
|
module RubyAsterisk
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
2
|
+
class Response
|
3
|
+
attr_accessor :type, :success, :action_id, :message, :data, :raw_response
|
4
|
+
|
5
|
+
def initialize(type,response)
|
6
|
+
self.raw_response = response
|
7
|
+
self.type = type
|
8
|
+
self.success = self._parse_successfull(response)
|
9
|
+
self.action_id = self._parse_action_id(response)
|
10
|
+
self.message = self._parse_message(response)
|
11
|
+
self.data = self._parse_data(response)
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def _parse_successfull(response)
|
17
|
+
response.include?("Response: Success")
|
18
|
+
end
|
19
|
+
|
20
|
+
def _parse_action_id(response)
|
21
|
+
self._parse(response,"ActionID:")
|
22
|
+
end
|
23
|
+
|
24
|
+
def _parse_message(response)
|
25
|
+
self._parse(response,"Message:")
|
26
|
+
end
|
27
|
+
|
28
|
+
def _parse(response,field)
|
29
|
+
_value = nil
|
30
|
+
response.each_line do |line|
|
30
31
|
if line.start_with?(field)
|
31
32
|
_value = line[line.rindex(":")+1..line.size].strip
|
32
33
|
end
|
33
34
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
_value
|
36
|
+
end
|
37
|
+
|
38
|
+
def _parse_data(response)
|
39
|
+
case self.type
|
40
|
+
when "CoreShowChannels"
|
41
|
+
self._parse_data_core_show_channels(response)
|
42
|
+
when "ParkedCalls"
|
43
|
+
self._parse_data_parked_calls(response)
|
44
|
+
when "Originate"
|
45
|
+
self._parse_originate(response)
|
46
|
+
when "MeetMeList"
|
46
47
|
self._parse_meet_me_list(response)
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
when "Status"
|
49
|
+
self._parse_status(response)
|
50
|
+
when "ExtensionState"
|
51
|
+
self._parse_extension_state(response)
|
52
|
+
when "SKINNYdevices"
|
53
|
+
self._parse_skinny_devices(response)
|
54
|
+
when "SKINNYlines"
|
55
|
+
self._parse_skinny_lines(response)
|
56
|
+
when "Command"
|
57
|
+
response
|
58
|
+
when "QueuePause"
|
59
|
+
self._parse_queue_pause(response)
|
60
|
+
when "Pong"
|
61
|
+
self._parse_pong(response)
|
62
|
+
when "Events"
|
63
|
+
self._parse_event_mask(response)
|
64
|
+
when "SIPpeers"
|
65
|
+
self._parse_sip_peers(response)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
def _parse_sip_peers(response)
|
71
|
+
self._parse_objects(response, :peers, "Event: PeerEntry")
|
50
72
|
end
|
51
73
|
|
52
|
-
|
74
|
+
def _parse_meet_me_list(response)
|
53
75
|
self._parse_objects(response,:rooms,"Event: MeetmeList")
|
54
76
|
end
|
55
77
|
|
56
|
-
|
57
|
-
|
58
|
-
|
78
|
+
def _parse_originate(response)
|
79
|
+
self._parse_objects(response,:dial,"Event: Dial")
|
80
|
+
end
|
59
81
|
|
60
|
-
|
61
|
-
|
62
|
-
|
82
|
+
def _parse_data_parked_calls(response)
|
83
|
+
self._parse_objects(response,:calls,"Event: ParkedCall")
|
84
|
+
end
|
63
85
|
|
64
|
-
|
65
|
-
|
66
|
-
|
86
|
+
def _parse_data_core_show_channels(response)
|
87
|
+
self._parse_objects(response,:channels,"Event: CoreShowChannel","Event: CoreShowChannelsComplete")
|
88
|
+
end
|
67
89
|
|
68
|
-
|
90
|
+
def _parse_extension_state(response)
|
69
91
|
_data = self._parse_objects(response,:hints,"Response:")
|
70
|
-
|
92
|
+
self._convert_status(_data)
|
93
|
+
end
|
94
|
+
|
95
|
+
def _parse_skinny_devices(response)
|
96
|
+
self._parse_objects(response,:skinnydevs,"Event: DeviceEntry")
|
97
|
+
end
|
98
|
+
|
99
|
+
def _parse_skinny_lines(response)
|
100
|
+
self._parse_objects(response,:skinnylines,"Event: LineEntry")
|
101
|
+
end
|
102
|
+
|
103
|
+
def _parse_queue_pause(response)
|
104
|
+
_data = self._parse_objects(response,:queue_pause,"Response:")
|
105
|
+
end
|
106
|
+
|
107
|
+
def _parse_pong(response)
|
108
|
+
_data = self._parse_objects(response,:pong, "Response:")
|
109
|
+
end
|
110
|
+
|
111
|
+
def _parse_event_mask(response)
|
112
|
+
_data = self._parse_objects(response, :event_mask, "Ping:")
|
113
|
+
end
|
114
|
+
|
115
|
+
def _parse_status(response)
|
116
|
+
self._parse_objects(response, :status, "Event: Status")
|
71
117
|
end
|
72
118
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
119
|
+
def _convert_status(_data)
|
120
|
+
_data[:hints].each do |hint|
|
121
|
+
case hint["Status"]
|
122
|
+
when "-1"
|
123
|
+
hint["DescriptiveStatus"] = "Extension not found"
|
124
|
+
when "0"
|
125
|
+
hint["DescriptiveStatus"] = "Idle"
|
126
|
+
when "1"
|
81
127
|
hint["DescriptiveStatus"] = "In Use"
|
82
|
-
|
128
|
+
when "2"
|
83
129
|
hint["DescriptiveStatus"] = "Busy"
|
84
|
-
|
130
|
+
when "4"
|
85
131
|
hint["DescriptiveStatus"] = "Unavailable"
|
86
|
-
|
132
|
+
when "8"
|
87
133
|
hint["DescriptiveStatus"] = "Ringing"
|
88
|
-
|
134
|
+
when "16"
|
89
135
|
hint["DescriptiveStatus"] = "On Hold"
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
136
|
+
end
|
137
|
+
end
|
138
|
+
_data
|
139
|
+
end
|
94
140
|
|
95
|
-
|
96
|
-
|
141
|
+
def _parse_objects(response,symbol_name,search_for,stop_with=nil)
|
142
|
+
_data = { symbol_name => [] }
|
97
143
|
parsing = false
|
98
144
|
object = nil
|
99
145
|
response.each_line do |line|
|
100
|
-
|
146
|
+
line.strip!
|
147
|
+
if line.strip.empty? or (!stop_with.nil? and line.start_with?(stop_with))
|
101
148
|
parsing = false
|
102
149
|
elsif line.start_with?(search_for)
|
103
150
|
_data[symbol_name] << object unless object.nil?
|
104
151
|
object = {}
|
105
152
|
parsing = true
|
106
153
|
elsif parsing
|
107
|
-
|
154
|
+
tokens = line.split(':', 2)
|
155
|
+
object[tokens[0].strip]=tokens[1].strip unless tokens[1].nil?
|
108
156
|
end
|
109
157
|
end
|
110
158
|
_data[symbol_name] << object unless object.nil?
|
111
159
|
_data
|
112
|
-
|
113
|
-
|
160
|
+
end
|
161
|
+
end
|
114
162
|
end
|
@@ -2,6 +2,16 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
describe RubyAsterisk::Response do
|
4
4
|
|
5
|
+
def sip_peers_response
|
6
|
+
"Response: Success
|
7
|
+
Message: Peer status list will follow
|
8
|
+
|
9
|
+
Event: PeerEntry
|
10
|
+
Channeltype: SIP
|
11
|
+
ObjectName: 9915057
|
12
|
+
IPport: 5060"
|
13
|
+
end
|
14
|
+
|
5
15
|
def empty_core_show_channels_response
|
6
16
|
"Event: CoreShowChannelsComplete
|
7
17
|
EventList: Complete
|
@@ -127,6 +137,11 @@ describe RubyAsterisk::Response do
|
|
127
137
|
@response = RubyAsterisk::Response.new("Originate",originate_response)
|
128
138
|
@response.data[:dial][0]["UniqueID"].should eq("1335457364.68")
|
129
139
|
end
|
140
|
+
|
141
|
+
it "should have a field with original raw response" do
|
142
|
+
@response = RubyAsterisk::Response.new("Originate",originate_response)
|
143
|
+
@response.raw_response.should eq(originate_response)
|
144
|
+
end
|
130
145
|
end
|
131
146
|
|
132
147
|
describe "receiving a MeetMeList request" do
|
@@ -154,4 +169,17 @@ describe RubyAsterisk::Response do
|
|
154
169
|
end
|
155
170
|
end
|
156
171
|
end
|
172
|
+
|
173
|
+
describe "receiving a SIPPeers request" do
|
174
|
+
it "should parse correctly data coming from Asterisk abous sip peers" do
|
175
|
+
@response = RubyAsterisk::Response.new("SIPpeers",sip_peers_response)
|
176
|
+
@response.data[:peers].should_not be_empty
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should correctly fill the fields" do
|
180
|
+
@response = RubyAsterisk::Response.new("SIPpeers",sip_peers_response)
|
181
|
+
@response.data[:peers][0]["ObjectName"].should eq("9915057")
|
182
|
+
@response.data[:peers][0]["IPport"].should eq("5060")
|
183
|
+
end
|
184
|
+
end
|
157
185
|
end
|
@@ -139,4 +139,12 @@ describe RubyAsterisk do
|
|
139
139
|
@session.extension_state("9100","HINT").should be_kind_of(RubyAsterisk::Response)
|
140
140
|
end
|
141
141
|
end
|
142
|
+
|
143
|
+
describe ".sip_peers" do
|
144
|
+
it "should return a response object" do
|
145
|
+
@session.login("mark","mysecret")
|
146
|
+
@session.sip_peers.should be_kind_of(RubyAsterisk::Response)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
142
150
|
end
|
metadata
CHANGED
@@ -1,49 +1,51 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-asterisk
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.7
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Emiliano Della Casa
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
16
14
|
name: rake
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
24
20
|
type: :development
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rspec
|
28
21
|
prerelease: false
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
35
34
|
type: :development
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Add support to your ruby or rails projects to Asterisk Manager Interface
|
42
|
+
(AMI)
|
43
|
+
email:
|
39
44
|
- e.dellacasa@engim.eu
|
40
45
|
executables: []
|
41
|
-
|
42
46
|
extensions: []
|
43
|
-
|
44
47
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
files:
|
48
|
+
files:
|
47
49
|
- .gitignore
|
48
50
|
- .rspec
|
49
51
|
- CHANGELOG
|
@@ -61,30 +63,25 @@ files:
|
|
61
63
|
- spec/spec_helper.rb
|
62
64
|
homepage: http://github.com/emilianodellacasa/ruby-asterisk
|
63
65
|
licenses: []
|
64
|
-
|
66
|
+
metadata: {}
|
65
67
|
post_install_message:
|
66
68
|
rdoc_options: []
|
67
|
-
|
68
|
-
require_paths:
|
69
|
+
require_paths:
|
69
70
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: "0"
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
82
81
|
requirements: []
|
83
|
-
|
84
82
|
rubyforge_project: ruby-asterisk
|
85
|
-
rubygems_version:
|
83
|
+
rubygems_version: 2.0.3
|
86
84
|
signing_key:
|
87
|
-
specification_version:
|
85
|
+
specification_version: 4
|
88
86
|
summary: Asterisk Manager Interface in Ruby
|
89
87
|
test_files: []
|
90
|
-
|