punchblock 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/lib/punchblock/client.rb +1 -1
- data/lib/punchblock/command_node.rb +1 -0
- data/lib/punchblock/connection/xmpp.rb +7 -0
- data/lib/punchblock/event.rb +1 -0
- data/lib/punchblock/event/input_timers_started.rb +9 -0
- data/lib/punchblock/translator/asterisk/ami_error_converter.rb +2 -2
- data/lib/punchblock/translator/asterisk/component/record.rb +7 -1
- data/lib/punchblock/version.rb +1 -1
- data/spec/punchblock/client_spec.rb +8 -0
- data/spec/punchblock/connection/xmpp_spec.rb +30 -0
- data/spec/punchblock/event/input_timers_started_spec.rb +23 -0
- data/spec/punchblock/translator/asterisk/component/record_spec.rb +9 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a847554d66bf45ee14cc93803271b60890cfff96
|
4
|
+
data.tar.gz: 43d698af41a3b374c3b39bacdf29dbce822020bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c9373c2cb2e3831e1938924197c8c141fda152423a4f985e9f3c84c38f099185cdeaeed8275f8e111c2d9f77dd39c4caad635b9031fe63786b09eb3fb53d6df
|
7
|
+
data.tar.gz: 6474dd87f25053eb002212c18744f2c216cc153c4d9df1b7938f4e45faa224988b6f5ff296b4729bbd0c538887e43897aac1c9fff83f3eccc995fc726793a313
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# [develop](https://github.com/adhearsion/punchblock)
|
2
2
|
|
3
|
+
# [v2.3.0](https://github.com/adhearsion/punchblock/compare/v2.2.2...v2.3.0) - [2014-01-30](https://rubygems.org/gems/punchblock/versions/2.3.0)
|
4
|
+
* Feature: Add input-timers-started event
|
5
|
+
* Feature: Allow client to send XMPP messages through Blather
|
6
|
+
* Bugfix: Ensure that max duration expiration of Asterisk recordings does not crash the translator when it extends past the call's destruction
|
7
|
+
|
3
8
|
# [v2.2.2](https://github.com/adhearsion/punchblock/compare/v2.2.1...v2.2.2) - [2014-01-21](https://rubygems.org/gems/punchblock/versions/2.2.2)
|
4
9
|
* Bugfix: Delay sending Answered event on call until AsyncAGI is invoked
|
5
10
|
|
data/lib/punchblock/client.rb
CHANGED
@@ -10,7 +10,7 @@ module Punchblock
|
|
10
10
|
|
11
11
|
attr_reader :connection, :component_registry
|
12
12
|
|
13
|
-
delegate :run, :stop, :to => :connection
|
13
|
+
delegate :run, :stop, :send_message, :to => :connection
|
14
14
|
|
15
15
|
# @param [Hash] options
|
16
16
|
# @option options [Connection::XMPP] :connection The Punchblock connection to use for this session
|
@@ -69,6 +69,13 @@ module Punchblock
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
def send_message(call_id, domain, body, options = {})
|
73
|
+
jid = Blather::JID.new(call_id, domain || root_domain).to_s
|
74
|
+
message = Blather::Stanza::Message.new(jid, body, :normal)
|
75
|
+
message.subject = options[:subject]
|
76
|
+
client.write message
|
77
|
+
end
|
78
|
+
|
72
79
|
##
|
73
80
|
# Fire up the connection
|
74
81
|
#
|
data/lib/punchblock/event.rb
CHANGED
@@ -4,12 +4,12 @@ module Punchblock
|
|
4
4
|
module Translator
|
5
5
|
class Asterisk
|
6
6
|
module AMIErrorConverter
|
7
|
-
def self.convert
|
7
|
+
def self.convert(result = ->(e) { raise ChannelGoneError, e.message } )
|
8
8
|
yield
|
9
9
|
rescue RubyAMI::Error => e
|
10
10
|
case e.message
|
11
11
|
when 'No such channel', /Channel (\S+) does not exist./
|
12
|
-
|
12
|
+
result.call e if result
|
13
13
|
else
|
14
14
|
raise e
|
15
15
|
end
|
@@ -33,7 +33,7 @@ module Punchblock
|
|
33
33
|
ami_client.send_action 'Monitor', 'Channel' => call.channel, 'File' => filename, 'Format' => @format, 'Mix' => true
|
34
34
|
unless max_duration == -1
|
35
35
|
call.after max_duration/1000 do
|
36
|
-
|
36
|
+
stop
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -69,6 +69,12 @@ module Punchblock
|
|
69
69
|
|
70
70
|
private
|
71
71
|
|
72
|
+
def stop
|
73
|
+
AMIErrorConverter.convert(nil) do
|
74
|
+
ami_client.send_action 'StopMonitor', 'Channel' => call.channel
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
72
78
|
def filename
|
73
79
|
File.join RECORDING_BASE_PATH, id
|
74
80
|
end
|
data/lib/punchblock/version.rb
CHANGED
@@ -32,6 +32,14 @@ module Punchblock
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe '#send_message' do
|
36
|
+
it 'should send a message' do
|
37
|
+
args = [ "someone", "example.org", "Hello World!" ]
|
38
|
+
connection.should_receive(:send_message).with(*args).once
|
39
|
+
subject.send_message *args
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
35
43
|
it 'should handle connection events' do
|
36
44
|
subject.should_receive(:handle_event).with(mock_event).once
|
37
45
|
connection.event_handler.call mock_event
|
@@ -124,6 +124,36 @@ module Punchblock
|
|
124
124
|
connection.not_ready!
|
125
125
|
end
|
126
126
|
|
127
|
+
describe '#send_message' do
|
128
|
+
it 'should send a "normal" message to the given user and domain' do
|
129
|
+
client = connection.send :client
|
130
|
+
client.should_receive(:write).once.with do |stanza|
|
131
|
+
stanza.to.should be == 'someone@example.org'
|
132
|
+
stanza.should be_a Blather::Stanza::Message
|
133
|
+
stanza.type.should == :normal
|
134
|
+
stanza.body.should be == 'Hello World!'
|
135
|
+
stanza.subject.should be_nil
|
136
|
+
end
|
137
|
+
connection.send_message 'someone', 'example.org', 'Hello World!'
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should default to the root domain' do
|
141
|
+
client = connection.send :client
|
142
|
+
client.should_receive(:write).once.with do |stanza|
|
143
|
+
stanza.to.should be == 'someone@rayo.net'
|
144
|
+
end
|
145
|
+
connection.send_message "someone", nil, nil
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should send a message with the given subject' do
|
149
|
+
client = connection.send :client
|
150
|
+
client.should_receive(:write).once.with do |stanza|
|
151
|
+
stanza.subject.should be == "Important Message"
|
152
|
+
end
|
153
|
+
connection.send_message nil, nil, nil, :subject => "Important Message"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
127
157
|
describe '#handle_presence' do
|
128
158
|
let :complete_xml do
|
129
159
|
<<-MSG
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Punchblock
|
6
|
+
class Event
|
7
|
+
describe InputTimersStarted do
|
8
|
+
it 'registers itself' do
|
9
|
+
RayoNode.class_from_registration(:'input-timers-started', 'urn:xmpp:rayo:prompt:1').should be == described_class
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "from a stanza" do
|
13
|
+
let(:stanza) { "<input-timers-started xmlns='urn:xmpp:rayo:prompt:1' />" }
|
14
|
+
|
15
|
+
subject { RayoNode.from_xml parse_stanza(stanza).root, '9f00061', '1' }
|
16
|
+
|
17
|
+
it { should be_instance_of described_class }
|
18
|
+
|
19
|
+
it_should_behave_like 'event'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -297,6 +297,15 @@ module Punchblock
|
|
297
297
|
sleep 1.2
|
298
298
|
end
|
299
299
|
|
300
|
+
it "should not kill the translator if the channel is down" do
|
301
|
+
ami_client.should_receive :send_action
|
302
|
+
error = RubyAMI::Error.new.tap { |e| e.message = 'No such channel' }
|
303
|
+
ami_client.should_receive(:send_action).once.with('StopMonitor', 'Channel' => channel).and_raise error
|
304
|
+
subject.execute
|
305
|
+
sleep 1.2
|
306
|
+
translator.should be_alive
|
307
|
+
end
|
308
|
+
|
300
309
|
it "sends the correct complete event" do
|
301
310
|
full_filename = "file://#{Record::RECORDING_BASE_PATH}/#{subject.id}.wav"
|
302
311
|
subject.execute
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: punchblock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Goecke
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-01-
|
13
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -429,6 +429,7 @@ files:
|
|
429
429
|
- lib/punchblock/event/complete.rb
|
430
430
|
- lib/punchblock/event/dtmf.rb
|
431
431
|
- lib/punchblock/event/end.rb
|
432
|
+
- lib/punchblock/event/input_timers_started.rb
|
432
433
|
- lib/punchblock/event/joined.rb
|
433
434
|
- lib/punchblock/event/offer.rb
|
434
435
|
- lib/punchblock/event/ringing.rb
|
@@ -504,6 +505,7 @@ files:
|
|
504
505
|
- spec/punchblock/event/complete_spec.rb
|
505
506
|
- spec/punchblock/event/dtmf_spec.rb
|
506
507
|
- spec/punchblock/event/end_spec.rb
|
508
|
+
- spec/punchblock/event/input_timers_started_spec.rb
|
507
509
|
- spec/punchblock/event/joined_spec.rb
|
508
510
|
- spec/punchblock/event/offer_spec.rb
|
509
511
|
- spec/punchblock/event/ringing_spec.rb
|
@@ -592,6 +594,7 @@ test_files:
|
|
592
594
|
- spec/punchblock/event/complete_spec.rb
|
593
595
|
- spec/punchblock/event/dtmf_spec.rb
|
594
596
|
- spec/punchblock/event/end_spec.rb
|
597
|
+
- spec/punchblock/event/input_timers_started_spec.rb
|
595
598
|
- spec/punchblock/event/joined_spec.rb
|
596
599
|
- spec/punchblock/event/offer_spec.rb
|
597
600
|
- spec/punchblock/event/ringing_spec.rb
|