adhearsion_cpa 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78576498fddf76d14a2756d853529647a08bc674
4
- data.tar.gz: 01259071cfe35b2c4daa379e5e61dcdf569019a7
3
+ metadata.gz: 6387c07bc6e12199e7d38d9fa3bc9a4fe2e162db
4
+ data.tar.gz: 7c4a94002bc0895b8875737c71dd536794cfeed0
5
5
  SHA512:
6
- metadata.gz: ac156ed89e74dd1a0d1bed7a8ff5e09aace7226596ce73d554d39f27694190c636fa40716ab9e5f465a28bb621654b2cd61e77f11811c5405db84014b179109c
7
- data.tar.gz: 28a92b969d343b08517ab4194cd0d30e64e1b53347df14332123345e42977342e79bb016f4f2e1ac95a5d7ca3bdfe5b04459301a3dce614f9da1260be73f58a2
6
+ metadata.gz: 17a7ef5743d71f74032f239dec6b59ea3206835787510dcd2833b3837bdd4036e806c8a837080104100de7d44da0bdfe3536c1dcce4132135375de67be1e4107
7
+ data.tar.gz: b0d349199378a252a840ea2658b2bfea1e91458baffe875f679a5b13d75844ffa59b85ea0d5b3e219ac06a55d2ba42e4a8f908ea93bccd9c3a5a5e2c35e29c2d
@@ -1,2 +1,8 @@
1
+ # DEVELOP
2
+
3
+ # 0.1.1
4
+ * [BUGFIX] Don't error out on async calls if a timeout isn't set
5
+ * [BUGFIX] Make async calls work with both terminating and nonterminating CPA components
6
+
1
7
  # 0.1.0
2
8
  * Initial release
@@ -23,7 +23,7 @@ module AdhearsionCpa
23
23
  # Begin asynchronous tone detection, and run the block when the tone is detected
24
24
  #
25
25
  # @example Asynchronous wait for a dtmf
26
- # detect_tone :dtmf, timeout: -1 { |detected| logger.info "Beep! Customer pushed #{detected.inspect}"}
26
+ # detect_tone :dtmf { |detected| logger.info "Beep! Customer pushed #{detected.inspect}"}
27
27
  # @example Asynchronous wait for dtmf presses, running the block multiple times if multiple signals are detected
28
28
  def detect_tone!(*arguments)
29
29
  options = arguments.last.is_a?(Hash) && arguments.count > 1 ? arguments.pop : {}
@@ -11,9 +11,15 @@ module AdhearsionCpa
11
11
  @tones = tones
12
12
  process options
13
13
 
14
- component.register_event_handler Punchblock::Component::Input::Signal do |event|
15
- yield event if block_given?
16
- end if async?
14
+ if async?
15
+ component.register_event_handler Punchblock::Component::Input::Signal do |event|
16
+ yield event if block_given?
17
+ end
18
+
19
+ component.register_event_handler Punchblock::Event::Complete do |event|
20
+ yield event.reason if block_given? && event.reason.is_a?(Punchblock::Component::Input::Signal)
21
+ end
22
+ end
17
23
 
18
24
  call.write_and_await_response component if call_alive?
19
25
 
@@ -22,7 +28,7 @@ module AdhearsionCpa
22
28
  if component_running?
23
29
  component.stop!
24
30
  end
25
- end
31
+ end if timeout
26
32
 
27
33
  component
28
34
  else
@@ -1,3 +1,3 @@
1
1
  module AdhearsionCpa
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -7,8 +7,8 @@ module AdhearsionCpa
7
7
  subject { Adhearsion::CallController.new mock_call }
8
8
 
9
9
  let(:expected_component) { Punchblock::Component::Input.new mode: :cpa, grammars: expected_grammars }
10
- let(:mock_complete_event) { double 'Event', reason: mock_signal }
11
- let(:mock_signal) { double 'Signal', type: "dtmf" }
10
+ let(:mock_complete_event) { double Punchblock::Event::Complete, reason: mock_signal }
11
+ let(:mock_signal) { double Punchblock::Component::Input::Signal, type: "dtmf" }
12
12
 
13
13
  describe "#detect_tone" do
14
14
  context "when watching for a beep" do
@@ -95,12 +95,16 @@ module AdhearsionCpa
95
95
  and_return mock_component
96
96
 
97
97
  mock_component.should_receive(:register_event_handler).with Punchblock::Component::Input::Signal do |&block|
98
- @on_detect_block = block
98
+ @on_detect_signal_block = block
99
99
  end
100
+ mock_component.should_receive(:register_event_handler).with Punchblock::Event::Complete do |&block|
101
+ @on_detect_complete_block = block
102
+ end
103
+
100
104
  mock_call.should_receive(:write_and_await_response).with mock_component
101
105
  end
102
106
 
103
- context "watches in the background" do
107
+ context "with :terminate set to true" do
104
108
  let(:expected_grammars) do
105
109
  [ Punchblock::Component::Input::Grammar.new(url: "urn:xmpp:rayo:cpa:dtmf:1?terminate=true") ]
106
110
  end
@@ -108,15 +112,16 @@ module AdhearsionCpa
108
112
  it "detects the dtmf" do
109
113
  detector = subject.detect_tone!(:dtmf, timeout: 0.02) { |tone| tone.type }
110
114
  detector.should == mock_component
115
+ mock_signal.should_receive(:is_a?).with(Punchblock::Component::Input::Signal).and_return true
111
116
  mock_signal.should_receive :type
112
- @on_detect_block.call mock_signal
117
+ @on_detect_complete_block.call mock_complete_event
113
118
 
114
119
  mock_component.should_receive :stop!
115
120
  sleep 0.04
116
121
  end
117
122
  end
118
123
 
119
- context " with :terminate set to false" do
124
+ context "with :terminate set to false" do
120
125
  let(:expected_grammars) do
121
126
  [ Punchblock::Component::Input::Grammar.new(url: "urn:xmpp:rayo:cpa:dtmf:1") ]
122
127
  end
@@ -126,11 +131,25 @@ module AdhearsionCpa
126
131
  detector.should == mock_component
127
132
 
128
133
  mock_signal.should_receive(:type).twice
129
- @on_detect_block.call mock_signal
130
- @on_detect_block.call mock_signal
134
+ @on_detect_signal_block.call mock_signal
135
+ @on_detect_signal_block.call mock_signal
131
136
 
132
137
  mock_component.should_receive :stop!
133
- sleep 0.04
138
+ sleep 0.1
139
+ end
140
+
141
+ context "without a timeout" do
142
+ it "doesn't ever stop.." do
143
+ detector = subject.detect_tone!(:dtmf, terminate: false) { |tone| tone.type }
144
+ detector.should == mock_component
145
+
146
+ mock_signal.should_receive(:type).twice
147
+ @on_detect_signal_block.call mock_signal
148
+ @on_detect_signal_block.call mock_signal
149
+
150
+ mock_component.should_not_receive :stop!
151
+ sleep 0.04
152
+ end
134
153
  end
135
154
  end
136
155
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhearsion_cpa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Aiken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-18 00:00:00.000000000 Z
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adhearsion
@@ -172,4 +172,3 @@ summary: A plugin for adding cpa to Adhearsion
172
172
  test_files:
173
173
  - spec/adhearsion_cpa/controller_methods_spec.rb
174
174
  - spec/spec_helper.rb
175
- has_rdoc: