adhearsion-asr 1.2.0 → 1.3.0

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: d793ad00c79ebd46c18281cde5693d24d4ffc9e9
4
- data.tar.gz: df0fac47487a8518063c7a27e353e04a755b82b4
3
+ metadata.gz: ca0404794461dacc1ea767edf9c7a73ce39037e7
4
+ data.tar.gz: f8e0d64f713d2ac76a4aa4a88bb8b1a8f331f119
5
5
  SHA512:
6
- metadata.gz: 575c331ebf7da9bc3b433ca2520eb503adba3410cb9ccea69274456f1343845de3c60d305a7130decd2adf15c7d14721cea2b131c739127fa91b4794318c36e9
7
- data.tar.gz: f649369e4e60fe0ec247ca2eff8fe8c0efedea114b487f064a1921e9d69354ab334ecef329b3d32938d636a964d1dec3ee7d94a2e28f58d893ea7f8d56eb180d
6
+ metadata.gz: 15ee7ed592699c1b0790cb87b5265477eb0db3f60e82ca7223ba933a747e7cfdb6c8afe1f472873a56222266ad50e74a9f1631a4f2a7be4ea71ed4a3bbc12a4a
7
+ data.tar.gz: 77799f2386d1743d73837d49ab6f5cd4675018d84621f72b5c21edab5eec599633221b21233ef61b36b826b8e05d3a2c679a36ed7eec04623162bd97cc27fa25
data/.hound.yml ADDED
@@ -0,0 +1,2 @@
1
+ LineLength:
2
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # [develop](https://github.com/adhearsion/adhearsion-asr)
2
2
 
3
+ # [v1.3.0](https://github.com/adhearsion/adhearsion-asr/compare/1.2.0...1.3.0) - [2015-04-24](https://rubygems.org/gems/adhearsion-asr/versions/1.3.0)
4
+ * Bugfix: Correctly handle nil prompts
5
+ * Feature: Allow disabling timeouts with -1
6
+
3
7
  # [v1.2.0](https://github.com/adhearsion/adhearsion-asr/compare/1.1.1...1.2.0) - [2014-03-03](https://rubygems.org/gems/adhearsion-asr/versions/1.2.0)
4
8
  * Feature: Allow setting `:mode` option to `:voice` for ASR menus
5
9
  * Bugfix: Raise `Adhearsion::Hangup` to terminate controller execution when the call actor is dead
@@ -34,7 +34,7 @@ module AdhearsionASR
34
34
  #
35
35
  def ask(*args)
36
36
  options = args.last.kind_of?(Hash) ? args.pop : {}
37
- prompts = args.flatten
37
+ prompts = args.flatten.compact
38
38
 
39
39
  if block_given?
40
40
  logger.warn "You passed a block to #ask, but this functionality is not available in adhearsion-asr. If you're looking for the block validator functionality, you should avoid using it in favour of grammars, and it is deprecated in Adhearsion Core."
@@ -106,11 +106,11 @@ module AdhearsionASR
106
106
  def menu(*args, &block)
107
107
  raise ArgumentError, "You must specify a block to build the menu" unless block
108
108
  options = args.last.kind_of?(Hash) ? args.pop : {}
109
- prompts = args.flatten
109
+ prompts = args.flatten.compact
110
110
 
111
111
  menu_builder = MenuBuilder.new(options, &block)
112
112
 
113
- output_document = output_formatter.ssml_for_collection(prompts)
113
+ output_document = prompts.empty? ? nil : output_formatter.ssml_for_collection(prompts)
114
114
 
115
115
  menu_builder.execute output_document, self
116
116
  end
@@ -5,9 +5,9 @@ module AdhearsionASR
5
5
  def initialize(output_document, grammars, options)
6
6
  input_options = {
7
7
  mode: options[:mode] || :dtmf,
8
- initial_timeout: (options[:timeout] || Plugin.config.timeout) * 1000,
9
- inter_digit_timeout: (options[:timeout] || Plugin.config.timeout) * 1000,
10
- max_silence: (options[:timeout] || Plugin.config.timeout) * 1000,
8
+ initial_timeout: timeout(options[:timeout] || Plugin.config.timeout),
9
+ inter_digit_timeout: timeout(options[:timeout] || Plugin.config.timeout),
10
+ max_silence: timeout(options[:timeout] || Plugin.config.timeout),
11
11
  min_confidence: Plugin.config.min_confidence,
12
12
  grammars: grammars,
13
13
  recognizer: Plugin.config.recognizer,
@@ -64,5 +64,9 @@ module AdhearsionASR
64
64
  logger.debug "Ask completed with result #{result.inspect}"
65
65
  end
66
66
  end
67
+
68
+ def timeout(value)
69
+ value > 0 ? value * 1000 : value
70
+ end
67
71
  end
68
72
  end
@@ -1,3 +1,3 @@
1
1
  module AdhearsionASR
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -17,19 +17,6 @@ module AdhearsionASR
17
17
  double call, write_command: true, id: call_id
18
18
  end
19
19
 
20
- def expect_message_waiting_for_utterance(message, fail = false)
21
- expectation = controller.should_receive(:write_and_await_utterance).with message
22
- if fail
23
- expectation.and_raise fail
24
- else
25
- expectation.and_return message
26
- end
27
- end
28
-
29
- def expect_message_of_type_waiting_for_utterance(message)
30
- controller.should_receive(:write_and_await_utterance).with(message.class).and_return message
31
- end
32
-
33
20
  def expect_component_execution(component, fail = false)
34
21
  expectation = controller.should_receive(:execute_component_and_await_completion).ordered.with(component)
35
22
  if fail
@@ -123,6 +110,15 @@ module AdhearsionASR
123
110
  subject.ask prompts, limit: 5
124
111
  end
125
112
 
113
+ context "with nil prompts" do
114
+ let(:prompts) { [nil, 'http://example.com/nice-to-meet-you.mp3', 'http://example.com/press-some-buttons.mp3'] }
115
+
116
+ it "executes a Prompt component with the correct prompts and grammar" do
117
+ expect_component_execution expected_prompt
118
+ subject.ask prompts, limit: 5
119
+ end
120
+ end
121
+
126
122
  context "with no prompts" do
127
123
  it "executes an Input component with the correct grammar" do
128
124
  Punchblock::Component::Input.any_instance.stub complete_event: double(reason: reason)
@@ -131,6 +127,14 @@ module AdhearsionASR
131
127
  end
132
128
  end
133
129
 
130
+ context "with only nil prompts" do
131
+ it "executes an Input component with the correct grammar" do
132
+ Punchblock::Component::Input.any_instance.stub complete_event: double(reason: reason)
133
+ expect_component_execution Punchblock::Component::Input.new(expected_input_options)
134
+ subject.ask nil, limit: 5
135
+ end
136
+ end
137
+
134
138
  context "with a block passed" do
135
139
  it "executes but logs a warning about the block validator" do
136
140
  expect_component_execution expected_prompt
@@ -313,6 +317,22 @@ module AdhearsionASR
313
317
  end
314
318
  end
315
319
 
320
+ context "with a negative timeout specified" do
321
+ let(:expected_grxml) { digit_limit_grammar }
322
+
323
+ before do
324
+ expected_input_options.merge! initial_timeout: -1,
325
+ inter_digit_timeout: -1,
326
+ max_silence: -1
327
+ end
328
+
329
+ it "executes a Prompt with correct timeout (initial, inter-digit & max-silence)" do
330
+ expect_component_execution expected_prompt
331
+
332
+ subject.ask prompts, limit: 5, timeout: -1
333
+ end
334
+ end
335
+
316
336
  context "with a different default timeout" do
317
337
  let(:expected_grxml) { digit_limit_grammar }
318
338
 
@@ -478,7 +498,7 @@ module AdhearsionASR
478
498
  result.confidence.should == 1
479
499
  result.utterance.should == '123'
480
500
  result.interpretation.should == 'Foo'
481
- result.nlsml.should == nlsml.root
501
+ result.nlsml.should == nlsml
482
502
  end
483
503
 
484
504
  context "with speech input" do
@@ -659,6 +679,37 @@ module AdhearsionASR
659
679
  doo.should == :bar
660
680
  end
661
681
 
682
+ context "with nil prompts" do
683
+ let(:prompts) { [nil, 'http://example.com/nice-to-meet-you.mp3', 'http://example.com/press-some-buttons.mp3'] }
684
+
685
+ it "executes a Prompt component with the correct prompts and grammar" do
686
+ expect_component_execution expected_prompt
687
+ subject.menu prompts do
688
+ match(1) {}
689
+ end
690
+ end
691
+ end
692
+
693
+ context "with no prompts" do
694
+ it "executes an Input component with the correct grammar" do
695
+ Punchblock::Component::Input.any_instance.stub complete_event: double(reason: reason)
696
+ expect_component_execution Punchblock::Component::Input.new(expected_input_options)
697
+ subject.menu do
698
+ match(1) {}
699
+ end
700
+ end
701
+ end
702
+
703
+ context "with only nil prompts" do
704
+ it "executes an Input component with the correct grammar" do
705
+ Punchblock::Component::Input.any_instance.stub complete_event: double(reason: reason)
706
+ expect_component_execution Punchblock::Component::Input.new(expected_input_options)
707
+ subject.menu nil do
708
+ match(1) {}
709
+ end
710
+ end
711
+ end
712
+
662
713
  context "with interruptible: false" do
663
714
  let(:expected_barge_in) { false }
664
715
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhearsion-asr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Langfeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adhearsion
@@ -130,6 +130,7 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
+ - ".hound.yml"
133
134
  - ".rspec"
134
135
  - ".travis.yml"
135
136
  - CHANGELOG.md
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  version: '0'
170
171
  requirements: []
171
172
  rubyforge_project: adhearsion-asr
172
- rubygems_version: 2.2.0
173
+ rubygems_version: 2.4.5
173
174
  signing_key:
174
175
  specification_version: 4
175
176
  summary: Adds speech recognition support to Adhearsion as a plugin