electric_slide 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.lgtm +2 -0
- data/CHANGELOG.md +6 -0
- data/MAINTAINERS +2 -0
- data/lib/electric_slide/agent.rb +4 -3
- data/lib/electric_slide/call_queue.rb +6 -5
- data/lib/electric_slide/version.rb +1 -1
- data/spec/electric_slide/agent_spec.rb +18 -1
- data/spec/electric_slide/call_queue_spec.rb +11 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a85c9a483bad9fb21fb302c8914f74323d5f41b
|
4
|
+
data.tar.gz: 596262ea3479ca13f5031a46fe84210732b1c558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 606297daca9e364dd4ddfa7daa47578183ff6d359fcb1d4b66daacbba7786d36e4cbd36aa180c6c80fbd75645c390b55ecbb5dcf862df6f98ccb3c7cab844f8e
|
7
|
+
data.tar.gz: 1771312a5bbda69e0b2fe802cb3510ee66cc34c158d36b69ec11efc5a0f960c4a955c3869269c333ec81ec2300ceb325d66b0b40e7750d13c76a32476e622b67
|
data/.lgtm
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
# [develop](https://github.com/adhearsion/electric_slide)
|
2
|
+
|
3
|
+
# [0.4.0](https://github.com/adhearsion/electric_slide/compare/v0.3.0...v0.4.0) - [2015-12-17](https://rubygems.org/gems/adhearsion/versions/0.4.0)
|
4
|
+
* Change `ElectricSlide::Agent` `#presence=` method name to `#update_presence`. It will also accept one more parameter called `extra_params`, a hash that holds application specific parameters that are passed to the presence change callback.
|
5
|
+
* `ElectricSlide::CallQueue#add_agent` will no longer wait for a connection attempt to complete before returning
|
6
|
+
|
7
|
+
# [0.3.0](https://github.com/adhearsion/electric_slide/compare/v0.2.0...v0.3.0) - [2015-12-01](https://rubygems.org/gems/adhearsion/versions/0.3.0)
|
2
8
|
* Trigger an agent "presence change" callback when the agent is removed from the queue
|
3
9
|
* Bugfix: Fix `NameError` exception when referencing namespaced constant `Adhearsion::Call::ExpiredError` in injected `Adhearsion::Call#active?` method
|
4
10
|
* Provide Electric Slide with a way to check if a queue with a given set of attributes is valid/can be instantiated before Electric Slide adds it to the supervision group. The supervisor will crash if its attempt to create the queue raises an exception.
|
data/MAINTAINERS
ADDED
data/lib/electric_slide/agent.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
class ElectricSlide
|
4
4
|
class Agent
|
5
|
-
attr_accessor :id, :address, :
|
5
|
+
attr_accessor :id, :address, :call, :queue
|
6
|
+
attr_reader :presence
|
6
7
|
|
7
8
|
# @param [Hash] opts Agent parameters
|
8
9
|
# @option opts [String] :id The Agent's ID
|
@@ -14,10 +15,10 @@ class ElectricSlide
|
|
14
15
|
@presence = opts[:presence] || :available
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
+
def update_presence(new_presence, extra_params = {})
|
18
19
|
old_presence = @presence
|
19
20
|
@presence = new_presence
|
20
|
-
callback :presence_change, queue, @call, new_presence, old_presence
|
21
|
+
callback :presence_change, queue, @call, new_presence, old_presence, extra_params
|
21
22
|
end
|
22
23
|
|
23
24
|
def callback(type, *args)
|
@@ -131,7 +131,7 @@ class ElectricSlide
|
|
131
131
|
def checkout_agent
|
132
132
|
agent = @strategy.checkout_agent
|
133
133
|
if agent
|
134
|
-
agent.
|
134
|
+
agent.update_presence(:on_call)
|
135
135
|
end
|
136
136
|
agent
|
137
137
|
end
|
@@ -179,7 +179,7 @@ class ElectricSlide
|
|
179
179
|
# Fake the presence callback since this is a new agent
|
180
180
|
agent.callback :presence_change, self, agent.call, agent.presence, :unavailable
|
181
181
|
|
182
|
-
check_for_connections
|
182
|
+
async.check_for_connections
|
183
183
|
end
|
184
184
|
|
185
185
|
# Marks an agent as available to take a call. To be called after an agent completes a call
|
@@ -192,7 +192,7 @@ class ElectricSlide
|
|
192
192
|
|
193
193
|
return false unless get_agent(agent.id)
|
194
194
|
|
195
|
-
agent.
|
195
|
+
agent.update_presence(new_presence)
|
196
196
|
agent.address = address if address
|
197
197
|
|
198
198
|
case agent.presence
|
@@ -216,9 +216,10 @@ class ElectricSlide
|
|
216
216
|
|
217
217
|
# Removes an agent from the queue entirely
|
218
218
|
# @param [Agent] agent The {Agent} to be removed from the queue
|
219
|
+
# @param [Hash] extra_params Application specific extra params
|
219
220
|
# @return [Agent, Nil] The Agent object if removed, Nil otherwise
|
220
|
-
def remove_agent(agent)
|
221
|
-
agent.
|
221
|
+
def remove_agent(agent, extra_params = {})
|
222
|
+
agent.update_presence(:unavailable, extra_params)
|
222
223
|
@strategy.delete agent
|
223
224
|
@agents.delete agent
|
224
225
|
logger.info "Removing agent #{agent} from the queue"
|
@@ -44,6 +44,23 @@ describe ElectricSlide::Agent do
|
|
44
44
|
called = false
|
45
45
|
ElectricSlide::Agent.on_presence_change { |queue, agent_call, presence| called = true }
|
46
46
|
agent = ElectricSlide::Agent.new presence: :unavailable
|
47
|
-
agent.
|
47
|
+
agent.update_presence(:busy)
|
48
|
+
|
49
|
+
expect(called).to be_truthy
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'sends `extra_params` and `old_presence` to the presence change callback' do
|
53
|
+
presence_change_attributes = []
|
54
|
+
ElectricSlide::Agent.on_presence_change do |*attrs|
|
55
|
+
presence_change_attributes = attrs
|
56
|
+
end
|
57
|
+
|
58
|
+
agent = ElectricSlide::Agent.new presence: :unavailable
|
59
|
+
agent.update_presence(:busy, triggered_by: 'auto')
|
60
|
+
|
61
|
+
queue, agent_call, presence, old_presence, extra_params = presence_change_attributes
|
62
|
+
|
63
|
+
expect(old_presence).to eq :unavailable
|
64
|
+
expect(extra_params[:triggered_by]).to eq 'auto'
|
48
65
|
end
|
49
66
|
end
|
@@ -137,7 +137,7 @@ describe ElectricSlide::CallQueue do
|
|
137
137
|
# prevent the agent from being returned to the queue so the queued
|
138
138
|
# call isn't grabbed by the agent again, changing queued call state
|
139
139
|
# before the example can check it
|
140
|
-
agent.
|
140
|
+
agent.update_presence(:unavailable)
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'unsets the `:agent` call variable on the queued call' do
|
@@ -264,7 +264,15 @@ describe ElectricSlide::CallQueue do
|
|
264
264
|
}.to change(queue, :checkout_agent).from(nil).to(agent)
|
265
265
|
end
|
266
266
|
|
267
|
-
it "connects the agent to waiting queued calls"
|
267
|
+
it "connects the agent to waiting queued calls" do
|
268
|
+
call = Adhearsion::OutboundCall.new
|
269
|
+
queue.enqueue call
|
270
|
+
|
271
|
+
queue.add_agent agent
|
272
|
+
sleep 0.5
|
273
|
+
expect(agent.presence).to eq(:on_call)
|
274
|
+
expect(call[:agent]).to eq(agent)
|
275
|
+
end
|
268
276
|
|
269
277
|
context 'when given an agent already in the queue' do
|
270
278
|
before do
|
@@ -352,7 +360,7 @@ describe ElectricSlide::CallQueue do
|
|
352
360
|
called = false
|
353
361
|
ElectricSlide::Agent.on_presence_change { |queue, agent_call, presence| called = true }
|
354
362
|
queue.remove_agent agent
|
355
|
-
expect(called).to
|
363
|
+
expect(called).to be_truthy
|
356
364
|
end
|
357
365
|
|
358
366
|
it 'takes the agent out of the call rotation' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: electric_slide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Klang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adhearsion
|
@@ -158,12 +158,14 @@ extensions: []
|
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
160
|
- ".gitignore"
|
161
|
+
- ".lgtm"
|
161
162
|
- ".rspec"
|
162
163
|
- ".travis.yml"
|
163
164
|
- CHANGELOG.md
|
164
165
|
- Gemfile
|
165
166
|
- Guardfile
|
166
167
|
- LICENSE
|
168
|
+
- MAINTAINERS
|
167
169
|
- README.markdown
|
168
170
|
- Rakefile
|
169
171
|
- config/ahn_acd.yml
|
@@ -200,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
202
|
version: '0'
|
201
203
|
requirements: []
|
202
204
|
rubyforge_project:
|
203
|
-
rubygems_version: 2.
|
205
|
+
rubygems_version: 2.4.5
|
204
206
|
signing_key:
|
205
207
|
specification_version: 2
|
206
208
|
summary: Automatic Call Distributor for Adhearsion
|