Skip to content

Commit

Permalink
Merge pull request #20 from benlangfeld/feature/phone_single_extension
Browse files Browse the repository at this point in the history
[BUGFIX] Phone number grammar should only allow a single instance of '*'/'x'
  • Loading branch information
benlangfeld committed Oct 4, 2013
2 parents aa12647 + 7c1db74 commit e42306f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,4 +1,5 @@
# [develop](https://github.com/benlangfeld/ruby_speech)
* Bugfix: Phone number grammar should only allow a single instance of '*'/'x'

# [2.3.0](https://github.com/benlangfeld/ruby_speech/compare/v2.2.2...v2.3.0) - [2013-09-30](https://rubygems.org/gems/ruby_speech/versions/2.3.0)
* Feature: Allow generation of a boolean, date, digits, currency, number, phone or time grammar including from URIs
Expand Down
15 changes: 12 additions & 3 deletions lib/ruby_speech/grxml/builtins.rb
Expand Up @@ -146,12 +146,21 @@ def self.phone(options = nil)
RubySpeech::GRXML.draw mode: :dtmf, root: 'number' do
rule id: 'number', scope: 'public' do
item repeat: '1-' do
one_of do
0.upto(9) { |d| item { d.to_s } }
item { '*' }
ruleref uri: '#digit'
end
item repeat: '0-1' do
item { '*' }
item repeat: '0-' do
ruleref uri: '#digit'
end
end
end

rule id: 'digit' do
one_of do
0.upto(9) { |d| item { d.to_s } }
end
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/ruby_speech/grxml/builtins_spec.rb
Expand Up @@ -143,11 +143,11 @@
it { should match('0').and_interpret_as('dtmf-0') }
it { should match('0123').and_interpret_as('dtmf-0 dtmf-1 dtmf-2 dtmf-3') }
it { should match('0123*456').and_interpret_as('dtmf-0 dtmf-1 dtmf-2 dtmf-3 dtmf-star dtmf-4 dtmf-5 dtmf-6') }
it { should match('0123*456*789').and_interpret_as('dtmf-0 dtmf-1 dtmf-2 dtmf-3 dtmf-star dtmf-4 dtmf-5 dtmf-6 dtmf-star dtmf-7 dtmf-8 dtmf-9') }

it { should potentially_match('') }

it { should not_match('#') }
it { should not_match('0123*456*789') }
end

describe "time" do
Expand Down

0 comments on commit e42306f

Please sign in to comment.