| 1 | |||||||||||||||||||||||||||||
| 2 | package VoiceXML::Client::Item::Grammar::Rule; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use base qw (VoiceXML::Client::Item); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use VoiceXML::Client::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | Copyright (C) 2007,2008 by Pat Deegan. | ||||||||||||||||||||||||||||
| 12 | All rights reserved | ||||||||||||||||||||||||||||
| 13 | http://voicexml.psychogenic.com | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | This library is released under the terms of the GNU GPL version 3, making it available only for | ||||||||||||||||||||||||||||
| 16 | free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details). | ||||||||||||||||||||||||||||
| 17 | Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to | ||||||||||||||||||||||||||||
| 18 | acquire a distinct license for their application. This approach encourages the use of free software | ||||||||||||||||||||||||||||
| 19 | while allowing for proprietary solutions that support further development. | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | This file is part of VoiceXML::Client. | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | VoiceXML::Client is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 27 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 28 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||
| 29 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | VoiceXML::Client is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 32 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 33 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||
| 34 | GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||
| 37 | along with VoiceXML::Client. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | my $id = $self->{'XMLElement'}->attribute('id'); | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | return 0 unless (defined $id); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | $self->{'id'} = $id; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | $self->{'validinputs'} = {}; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | my $oneof = $self->{'XMLElement'}->getElement('one-of'); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | unless ($oneof) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | 0 | warn "Rule $id does not have a oneof element... ignoring"; | |||||||||||||||||||||||||||
| 64 | 0 | return 0; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $items = $oneof->getAllChildren('item') || []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$oneof->getAllChildren('item') || []
MC/DC0%0/1
$oneof->getAllChildren('item') || []
$oneof->getAllChildren('item')
Truth table0%0/2
A
A= $oneof->getAllChildren('item')
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | unless (scalar @{$items}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | warn "Rule $id one-of does not have any items as children... ignoring"; | |||||||||||||||||||||||||||
| 74 | 0 | return 0; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | foreach my $itm (@{$items}) | |||||||||||||||||||||||||||
| 78 | { | ||||||||||||||||||||||||||||
| 79 | 0 | ▶ | my $val = $itm->getValue() || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$itm->getValue || ''
MC/DC0%0/1
$itm->getValue || ''
$itm->getValue
Truth table0%0/2
A
A= $itm->getValue
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | $val =~ s/\s+//smg; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | $self->{'validinputs'}->{$val} = 1; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | $self->{'parent'}->registerRule($id, $self); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # done... no need to proceed any further recording kids here... | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | return 0; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub isValidInput { | ||||||||||||||||||||||||||
|
Subroutine
isValidInput: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | my $input = shift || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | warn "CHECKING RULE $self->{'id'}"; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return 1 if (exists $self->{'validinputs'}->{$input} && $self->{'validinputs'}->{$input}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"validinputs"}{$input} and $self->{"validinputs"}{$input}
MC/DC0%0/2
exists $self->{"validinputs"}{$input} and $self->{"validinputs"}{$input}
exists $self->{"validinputs"}{$input}
$self->{"validinputs"}{$input}
Truth table0%0/3
A and B
A= exists $self->{"validinputs"}{$input}B= $self->{"validinputs"}{$input}
| |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | return 0; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 3 | 1; | |||||||||||||||||||||||||||