ruby_ami 0.1.4 → 0.1.5
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.md +7 -0
- data/lib/ruby_ami/client.rb +22 -10
- data/lib/ruby_ami/version.rb +1 -1
- data/spec/ruby_ami/client_spec.rb +46 -9
- metadata +40 -40
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# develop
|
2
2
|
|
3
|
+
# 0.1.5 - 2011-12-22
|
4
|
+
* Bugfix: Work consistently all all versions of Asterisk
|
5
|
+
* Both 1.8 and 10
|
6
|
+
* Login actions connection with events turned on (in order to get FullyBooted event)
|
7
|
+
* Turn events off immediately after fully-booted
|
8
|
+
* Pass FullyBooted events from the actions connection up to the event handler
|
9
|
+
|
3
10
|
# 0.1.4 - 2011-12-1
|
4
11
|
* Bugfix: Actions connection should login with Events: System. This ensures that the FullyBooted event will come through on both connections.
|
5
12
|
|
data/lib/ruby_ami/client.rb
CHANGED
@@ -63,17 +63,24 @@ module RubyAMI
|
|
63
63
|
logger.trace "[RECV-ACTIONS]: #{message.inspect}" if logger
|
64
64
|
case message
|
65
65
|
when Stream::Connected
|
66
|
-
start_writing_actions
|
67
66
|
login_actions
|
68
67
|
when Stream::Disconnected
|
69
68
|
stop_writing_actions
|
70
69
|
unbind
|
71
70
|
when Event
|
72
71
|
action = @current_action_with_causal_events
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
if action
|
73
|
+
message.action = action
|
74
|
+
action << message
|
75
|
+
@current_action_with_causal_events = nil if action.complete?
|
76
|
+
else
|
77
|
+
if message.name == 'FullyBooted'
|
78
|
+
pass_event message
|
79
|
+
start_writing_actions
|
80
|
+
else
|
81
|
+
raise StandardError, "Got an unexpected event on actions socket! This AMI command may have a multi-message response. Try making Adhearsion treat it as causal action #{message.inspect}"
|
82
|
+
end
|
83
|
+
end
|
77
84
|
when Response, Error
|
78
85
|
action = sent_action_with_id message.action_id
|
79
86
|
raise StandardError, "Received an AMI response with an unrecognized ActionID!! This may be an bug! #{message.inspect}" unless action
|
@@ -105,6 +112,7 @@ module RubyAMI
|
|
105
112
|
transition_action_to_sent action
|
106
113
|
actions_stream.send_action action
|
107
114
|
action.state = :sent
|
115
|
+
action
|
108
116
|
end
|
109
117
|
|
110
118
|
def unbind
|
@@ -145,22 +153,26 @@ module RubyAMI
|
|
145
153
|
end
|
146
154
|
|
147
155
|
def login_actions
|
148
|
-
login_action do |response|
|
156
|
+
action = login_action do |response|
|
149
157
|
pass_event response if response.is_a? Error
|
150
|
-
|
158
|
+
send_action 'Events', 'EventMask' => 'Off'
|
159
|
+
end
|
160
|
+
|
161
|
+
register_pending_action action
|
162
|
+
Thread.new { _send_action action }
|
151
163
|
end
|
152
164
|
|
153
165
|
def login_events
|
154
|
-
login_action
|
166
|
+
login_action.tap do |action|
|
155
167
|
events_stream.send_action action
|
156
168
|
end
|
157
169
|
end
|
158
170
|
|
159
|
-
def login_action(
|
171
|
+
def login_action(&block)
|
160
172
|
Action.new 'Login',
|
161
173
|
'Username' => options[:username],
|
162
174
|
'Secret' => options[:password],
|
163
|
-
'Events' =>
|
175
|
+
'Events' => 'On',
|
164
176
|
&block
|
165
177
|
end
|
166
178
|
|
data/lib/ruby_ami/version.rb
CHANGED
@@ -47,7 +47,7 @@ module RubyAMI
|
|
47
47
|
Action.new 'Login',
|
48
48
|
'Username' => 'username',
|
49
49
|
'Secret' => 'password',
|
50
|
-
'Events' => '
|
50
|
+
'Events' => 'On'
|
51
51
|
end
|
52
52
|
|
53
53
|
before do
|
@@ -60,9 +60,7 @@ module RubyAMI
|
|
60
60
|
action.to_s.should == expected_login_action.to_s
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
subject.handle_message Stream::Connected.new
|
65
|
-
GirlFriday::WorkQueue.queue!
|
63
|
+
subject.handle_message(Stream::Connected.new).join
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
@@ -81,9 +79,7 @@ module RubyAMI
|
|
81
79
|
end
|
82
80
|
|
83
81
|
it 'should log in' do
|
84
|
-
mock_events_stream.expects(:send_action).with
|
85
|
-
action.to_s.should == expected_login_action.to_s
|
86
|
-
end
|
82
|
+
mock_events_stream.expects(:send_action).with expected_login_action
|
87
83
|
|
88
84
|
subject.handle_event Stream::Connected.new
|
89
85
|
|
@@ -136,6 +132,47 @@ module RubyAMI
|
|
136
132
|
end
|
137
133
|
end
|
138
134
|
|
135
|
+
describe 'when a FullyBooted event is received on the actions connection' do
|
136
|
+
let(:event) { Event.new 'FullyBooted' }
|
137
|
+
|
138
|
+
let(:mock_actions_stream) { mock 'Actions Stream' }
|
139
|
+
|
140
|
+
let :expected_login_action do
|
141
|
+
Action.new 'Login',
|
142
|
+
'Username' => 'username',
|
143
|
+
'Secret' => 'password',
|
144
|
+
'Events' => 'On'
|
145
|
+
end
|
146
|
+
|
147
|
+
let :expected_events_off_action do
|
148
|
+
Action.new 'Events', 'EventMask' => 'Off'
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should call the event handler' do
|
152
|
+
subject.handle_message event
|
153
|
+
event_handler.should == [event]
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should begin writing actions' do
|
157
|
+
subject.expects(:start_writing_actions).once
|
158
|
+
subject.handle_message event
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should turn off events' do
|
162
|
+
Action.any_instance.stubs(:response).returns true
|
163
|
+
subject.stubs(:actions_stream).returns mock_actions_stream
|
164
|
+
|
165
|
+
mock_actions_stream.expects(:send_action).once.with expected_login_action
|
166
|
+
mock_actions_stream.expects(:send_action).once.with expected_events_off_action
|
167
|
+
|
168
|
+
login_action = subject.handle_message(Stream::Connected.new).join
|
169
|
+
login_action.value.response = true
|
170
|
+
|
171
|
+
subject.handle_message event
|
172
|
+
sleep 0.5
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
139
176
|
describe 'sending actions' do
|
140
177
|
let(:action_name) { 'Login' }
|
141
178
|
let :headers do
|
@@ -257,7 +294,7 @@ module RubyAMI
|
|
257
294
|
describe 'from the queue' do
|
258
295
|
it 'should send actions to the stream and set their responses' do
|
259
296
|
subject.actions_stream.expects(:send_action).with expected_action
|
260
|
-
subject.handle_message
|
297
|
+
subject.handle_message Event.new('FullyBooted')
|
261
298
|
|
262
299
|
Thread.new do
|
263
300
|
GirlFriday::WorkQueue.immediate!
|
@@ -273,7 +310,7 @@ module RubyAMI
|
|
273
310
|
|
274
311
|
it 'should not send another action if the first action has not yet received a response' do
|
275
312
|
subject.actions_stream.expects(:send_action).once.with expected_action
|
276
|
-
subject.handle_message
|
313
|
+
subject.handle_message Event.new('FullyBooted')
|
277
314
|
actions = []
|
278
315
|
|
279
316
|
2.times do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_ami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156102080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.9
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156102080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: uuidtools
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156101320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156101320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: eventmachine
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156100660 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156100660
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: future-resource
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156099960 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156099960
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: girl_friday
|
60
|
-
requirement: &
|
60
|
+
requirement: &2156176300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2156176300
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: countdownlatch
|
71
|
-
requirement: &
|
71
|
+
requirement: &2156175620 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.0.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2156175620
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: i18n
|
82
|
-
requirement: &
|
82
|
+
requirement: &2156175020 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2156175020
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: bundler
|
93
|
-
requirement: &
|
93
|
+
requirement: &2156174340 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.0.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2156174340
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rspec
|
104
|
-
requirement: &
|
104
|
+
requirement: &2156173700 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 2.5.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2156173700
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: cucumber
|
115
|
-
requirement: &
|
115
|
+
requirement: &2156173120 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *2156173120
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: ci_reporter
|
126
|
-
requirement: &
|
126
|
+
requirement: &2156172600 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: 1.6.3
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *2156172600
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: yard
|
137
|
-
requirement: &
|
137
|
+
requirement: &2156172040 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ~>
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: 0.6.0
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *2156172040
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: rcov
|
148
|
-
requirement: &
|
148
|
+
requirement: &2156171500 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *2156171500
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: rake
|
159
|
-
requirement: &
|
159
|
+
requirement: &2156170860 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,10 +164,10 @@ dependencies:
|
|
164
164
|
version: '0'
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *2156170860
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: mocha
|
170
|
-
requirement: &
|
170
|
+
requirement: &2156170320 !ruby/object:Gem::Requirement
|
171
171
|
none: false
|
172
172
|
requirements:
|
173
173
|
- - ! '>='
|
@@ -175,10 +175,10 @@ dependencies:
|
|
175
175
|
version: '0'
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
|
-
version_requirements: *
|
178
|
+
version_requirements: *2156170320
|
179
179
|
- !ruby/object:Gem::Dependency
|
180
180
|
name: simplecov
|
181
|
-
requirement: &
|
181
|
+
requirement: &2156169760 !ruby/object:Gem::Requirement
|
182
182
|
none: false
|
183
183
|
requirements:
|
184
184
|
- - ! '>='
|
@@ -186,10 +186,10 @@ dependencies:
|
|
186
186
|
version: '0'
|
187
187
|
type: :development
|
188
188
|
prerelease: false
|
189
|
-
version_requirements: *
|
189
|
+
version_requirements: *2156169760
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
191
|
name: simplecov-rcov
|
192
|
-
requirement: &
|
192
|
+
requirement: &2156169160 !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|
195
195
|
- - ! '>='
|
@@ -197,10 +197,10 @@ dependencies:
|
|
197
197
|
version: '0'
|
198
198
|
type: :development
|
199
199
|
prerelease: false
|
200
|
-
version_requirements: *
|
200
|
+
version_requirements: *2156169160
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: guard-rspec
|
203
|
-
requirement: &
|
203
|
+
requirement: &2156168720 !ruby/object:Gem::Requirement
|
204
204
|
none: false
|
205
205
|
requirements:
|
206
206
|
- - ! '>='
|
@@ -208,7 +208,7 @@ dependencies:
|
|
208
208
|
version: '0'
|
209
209
|
type: :development
|
210
210
|
prerelease: false
|
211
|
-
version_requirements: *
|
211
|
+
version_requirements: *2156168720
|
212
212
|
description: A Ruby client library for the Asterisk Management Interface build on
|
213
213
|
eventmachine.
|
214
214
|
email:
|
@@ -268,7 +268,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
268
268
|
version: '0'
|
269
269
|
segments:
|
270
270
|
- 0
|
271
|
-
hash: -
|
271
|
+
hash: -3356605808277851002
|
272
272
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
273
273
|
none: false
|
274
274
|
requirements:
|
@@ -277,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
277
|
version: '0'
|
278
278
|
segments:
|
279
279
|
- 0
|
280
|
-
hash: -
|
280
|
+
hash: -3356605808277851002
|
281
281
|
requirements: []
|
282
282
|
rubyforge_project: ruby_ami
|
283
283
|
rubygems_version: 1.8.10
|