adhearsion-asr 1.1.1 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d7e97002dde733bc1e12c3c68a741e4642d38f7
4
- data.tar.gz: f77c5dc898935b8b471b8d973289c79aea2b1e32
3
+ metadata.gz: d793ad00c79ebd46c18281cde5693d24d4ffc9e9
4
+ data.tar.gz: df0fac47487a8518063c7a27e353e04a755b82b4
5
5
  SHA512:
6
- metadata.gz: f6ca17cd388bd6c8d997aa7a66485bba6efccb3e6b7f4a45cd5b31d6b08386de3b5f84e45751c70683c61e5d4e6974e998dd095bd09b1af31dd2b836ed5f28ef
7
- data.tar.gz: d4ba8f56d484aa5c752616ea978363dea2d35704295584449ae54db10dd94bafa07e81225aef40b3e9edd8b16a532006aad55ad6e558c705832823e4fda30759
6
+ metadata.gz: 575c331ebf7da9bc3b433ca2520eb503adba3410cb9ccea69274456f1343845de3c60d305a7130decd2adf15c7d14721cea2b131c739127fa91b4794318c36e9
7
+ data.tar.gz: f649369e4e60fe0ec247ca2eff8fe8c0efedea114b487f064a1921e9d69354ab334ecef329b3d32938d636a964d1dec3ee7d94a2e28f58d893ea7f8d56eb180d
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
4
  - 2.0.0
6
5
  - 2.1.0
@@ -9,6 +8,7 @@ rvm:
9
8
  - ruby-head
10
9
  matrix:
11
10
  allow_failures:
11
+ - rvm: rbx-2.1.1
12
12
  - rvm: ruby-head
13
13
  notifications:
14
14
  irc: "irc.freenode.org#adhearsion"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # [develop](https://github.com/adhearsion/adhearsion-asr)
2
2
 
3
+ # [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
+ * Feature: Allow setting `:mode` option to `:voice` for ASR menus
5
+ * Bugfix: Raise `Adhearsion::Hangup` to terminate controller execution when the call actor is dead
6
+
3
7
  # [v1.1.1](https://github.com/adhearsion/adhearsion-asr/compare/1.1.0...1.1.1) - [2014-01-28](https://rubygems.org/gems/adhearsion-asr/versions/1.1.1)
4
8
  * Bugfix: Handle stop completion reason smoothly
5
9
 
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
-
5
- gem 'activesupport', '~> 3.0' if RUBY_VERSION == "1.9.2"
@@ -94,6 +94,7 @@ module AdhearsionASR
94
94
  # @option options [Integer] :tries Number of tries allowed before failure
95
95
  # @option options [Integer] :timeout Timeout in seconds before the first and between each input digit
96
96
  # @option options [Boolean] :interruptible If the prompt should be interruptible or not. Defaults to true
97
+ # @option options [String, Symbol] :mode Input mode to accept. May be :voice or :dtmf.
97
98
  # @option options [Hash] :input_options A hash of options passed directly to the Punchblock Input constructor
98
99
  # @option options [Hash] :output_options A hash of options passed directly to the Punchblock Output constructor
99
100
  #
@@ -84,7 +84,7 @@ module AdhearsionASR
84
84
  raise ArgumentError, "You must specify one or more matches." if @matchers.count < 1
85
85
  matchers = @matchers
86
86
 
87
- RubySpeech::GRXML.draw mode: :dtmf, root: 'options', tag_format: 'semantics/1.0-literals' do
87
+ RubySpeech::GRXML.draw mode: (@options[:mode] || :dtmf), root: 'options', tag_format: 'semantics/1.0-literals' do
88
88
  rule id: 'options', scope: 'public' do
89
89
  item do
90
90
  one_of do
@@ -4,7 +4,7 @@ module AdhearsionASR
4
4
  class PromptBuilder
5
5
  def initialize(output_document, grammars, options)
6
6
  input_options = {
7
- mode: :dtmf,
7
+ mode: options[:mode] || :dtmf,
8
8
  initial_timeout: (options[:timeout] || Plugin.config.timeout) * 1000,
9
9
  inter_digit_timeout: (options[:timeout] || Plugin.config.timeout) * 1000,
10
10
  max_silence: (options[:timeout] || Plugin.config.timeout) * 1000,
@@ -32,6 +32,8 @@ module AdhearsionASR
32
32
  controller.execute_component_and_await_completion @prompt
33
33
 
34
34
  result @prompt.complete_event.reason
35
+ rescue Adhearsion::Call::ExpiredError
36
+ raise Adhearsion::Call::Hangup
35
37
  end
36
38
 
37
39
  private
@@ -1,3 +1,3 @@
1
1
  module AdhearsionASR
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -50,6 +50,7 @@ module AdhearsionASR
50
50
  end
51
51
 
52
52
  before do
53
+ Adhearsion::Plugin.configure_plugins if Adhearsion::Plugin.respond_to?(:configure_plugins)
53
54
  Adhearsion::Plugin.init_plugins
54
55
  end
55
56
 
@@ -438,6 +439,14 @@ module AdhearsionASR
438
439
  end
439
440
  end
440
441
 
442
+ context "when the call is dead when trying to execute the prompt" do
443
+ before { call.terminate }
444
+
445
+ it "should raise Adhearsion::Call::Hangup" do
446
+ expect { subject.ask prompts, limit: 5 }.to raise_error Adhearsion::Call::Hangup
447
+ end
448
+ end
449
+
441
450
  context "when a utterance is received" do
442
451
  let(:expected_grxml) { digit_limit_grammar }
443
452
 
@@ -616,7 +625,7 @@ module AdhearsionASR
616
625
  context "with no matches" do
617
626
  it "should raise ArgumentError" do
618
627
  expect do
619
- subject.menu do
628
+ subject.menu "Hello?" do
620
629
  end
621
630
  end.to raise_error(ArgumentError, /specify one or more matches/)
622
631
  end
@@ -804,6 +813,47 @@ module AdhearsionASR
804
813
  end
805
814
  end
806
815
 
816
+ context "when using ASR mode" do
817
+ before do
818
+ expected_input_options.merge! mode: :voice
819
+ end
820
+
821
+ let :expected_grxml do
822
+ RubySpeech::GRXML.draw mode: 'voice', root: 'options', tag_format: 'semantics/1.0-literals' do
823
+ rule id: 'options', scope: 'public' do
824
+ item do
825
+ one_of do
826
+ item do
827
+ tag { '0' }
828
+ 'Hello world'
829
+ end
830
+ end
831
+ end
832
+ end
833
+ end
834
+ end
835
+
836
+ it "executes a Prompt with correct input mode, and the correct grammar mode" do
837
+ expect_component_execution expected_prompt
838
+
839
+ subject.menu prompts, mode: :voice do
840
+ match("Hello world") {}
841
+ end
842
+ end
843
+ end
844
+
845
+ context "when the call is dead when trying to execute the prompt" do
846
+ before { call.terminate }
847
+
848
+ it "should raise Adhearsion::Call::Hangup" do
849
+ expect do
850
+ subject.menu prompts do
851
+ match(1) {}
852
+ end
853
+ end.to raise_error Adhearsion::Call::Hangup
854
+ end
855
+ end
856
+
807
857
  context "when input completes with an error" do
808
858
  let(:reason) { Punchblock::Event::Complete::Error.new details: 'foobar' }
809
859
 
data/spec/spec_helper.rb CHANGED
@@ -10,4 +10,11 @@ RSpec.configure do |config|
10
10
  config.run_all_when_everything_filtered = true
11
11
 
12
12
  config.backtrace_clean_patterns = [/rspec/]
13
+
14
+ config.before do
15
+ @current_datetime = DateTime.now
16
+ DateTime.stub now: @current_datetime
17
+
18
+ Punchblock.stub new_request_id: 'foo'
19
+ end
13
20
  end
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.1.1
4
+ version: 1.2.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-01-28 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adhearsion