Client/Item/SubDialog.pm

filter: Statementstmt 78.1% 43 / 55 Branchbran 43.7% 7 / 16 Conditioncond 18.1% 2 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 87.5% 7 / 8 Podpod 33.3% 1 / 3 totaltotal 60.0% 60 / 100 CC 13 SCAR 19.4
CC
13
Cov
63%
evaluateCondition
12.0
execute
8.8
init
7.3
CRAP 7.0
« Client/Item/Audio.pm ↑ Summary Client/Item/Prompt.pm »
1  
2 package VoiceXML::Client::Item::SubDialog;
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 3 ▶use VoiceXML::Client::Item::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 =head1 COPYRIGHT AND LICENSE
11  
12
13 Copyright (C) 2007,2008 by Pat Deegan.
14 All rights reserved
15 http://voicexml.psychogenic.com
16  
17 This library is released under the terms of the GNU GPL version 3, making it available only for
18 free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details).
19 Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to
20 acquire a distinct license for their application. This approach encourages the use of free software
21 while allowing for proprietary solutions that support further development.
22  
23  
24 This file is part of VoiceXML::Client.
25  
26
27
28 VoiceXML::Client is free software: you can redistribute it and/or modify
29 it under the terms of the GNU General Public License as published by
30 the Free Software Foundation, either version 3 of the License, or
31 (at your option) any later version.
32  
33 VoiceXML::Client is distributed in the hope that it will be useful,
34 but WITHOUT ANY WARRANTY; without even the implied warranty of
35 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 GNU General Public License for more details.
37  
38 You should have received a copy of the GNU General Public License
39 along with VoiceXML::Client. If not, see <http://www.gnu.org/licenses/>.
40  
41  
42 =cut
43  
44  
45  
46 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 3 ▶use vars qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
49 $VERSION
50 3 };
51  
52 3 $VERSION = '1.02';
53  
54  
55  
56  
57 1 ▶sub init {
Subroutine init: called CC=5 SCAR=19.8
Pod documented
58 1 my $self = shift;
59
60 1 my $src = $self->{'XMLElement'}->attribute('src');
61
62 1 ▶ unless ( (defined $src) && length($src))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $src and length $src) 0 1 1
Condition33%1/3
defined $src and length $src
!ll&&!rl&&r
001
MC/DC0%0/2
defined $src and length $src
defined $src length $src
Truth table33%1/3
A and B
A= defined $srcB= length $src
ABresult
0X0
100
111
63 {
64 0 VoiceXML::Client::Util::log_msg("subdialog item must have 'src' set.");
65 0 return undef;
66 }
67
68 1 $self->{'src'} = $src;
69
70 1 my $cond = $self->{'XMLElement'}->attribute('cond');
71 1 ▶ if (defined $cond && length($cond))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cond and length $cond) 0 1 1
Condition33%1/3
defined $cond and length $cond
!ll&&!rl&&r
010
MC/DC0%0/2
defined $cond and length $cond
defined $cond length $cond
Truth table33%1/3
A and B
A= defined $condB= length $cond
ABresult
0X0
100
111
72 {
73 0 $self->{'cond'} = $cond;
74 }
75
76
77 1 return 1;
78
79
80 }
81  
82 1 ▶sub execute {
Subroutine execute: called CC=7 SCAR=21.8
Pod undocumented
83 1 my $self = shift;
84 1 my $handle = shift;
85 1 my $optParams = shift;
86
87
88 1 my $vxmlDoc = $self->getParentVXMLDocument();
89
90 1 ▶ if (exists $self->{'cond'})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"cond"}) 0 1 1
91 {
92 return $VoiceXML::Client::Flow::Directive{'CONTINUE'}
93 0 ▶ unless ($self->evaluateCondition($self->{'cond'}, $vxmlDoc));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->evaluateCondition($self->{"cond"}, $vxmlDoc) 0 0 0
94 }
95
96
97 1 my $src = $self->{'src'};
98
99 1 my $formID;
100 1 ▶ if ($src =~ m/^#(.+)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($src =~ /^#(.+)/) { } 1 0 1
101 {
102 1 $formID = $1;
103 } else {
104 0 VoiceXML::Client::Util::log_msg("Subdialog::execute() can only handle #internal src for now");
105 0 return $VoiceXML::Client::Flow::Directive{'CONTINUE'};
106 }
107
108 1 my $form = $vxmlDoc->getForm($formID);
109
110 1 ▶ if (! $form )
Branch: 1 branch
BranchTrueFalseTotal
unless ($form) 0 1 1
111 {
112
113 0 VoiceXML::Client::Util::log_msg("Subdialog::execute() can not find form $formID in document");
114 0 return $VoiceXML::Client::Flow::Directive{'CONTINUE'};
115 }
116
117 1 ▶ if ($self->{'parent'})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"parent"}) 1 0 1
118 {
119 1 $self->{'parent'}->proceedToNextChild();
120 }
121
122 1 ▶ VoiceXML::Client::Util::log_msg("Subdialog jumping to form $formID") if ($VoiceXML::Client::Debug);
Branch: 1 branch
BranchTrueFalseTotal
if $VoiceXML::Client::Debug 0 1 1
123
124 1 my $parentForm = $self->getParentForm();
125 1 $parentForm->clearAutoGuard();
126
127 1 $form->enterSub();
128 1 $vxmlDoc->nextFormId($formID);
129
130 1 return $VoiceXML::Client::Flow::Directive{'JUMP'};
131
132
133 }
134  
135  
136 0 ▶sub evaluateCondition {
Subroutine evaluateCondition: not called CC=3 SCAR=24.8
Pod undocumented
137 0 my $self = shift;
138 0 ▶ my $condition = shift || '';
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
139 0 ▶ my $vxmlDoc = shift || $self->getParentVXMLDocument();
Condition0%0/3
shift() || $self->getParentVXMLDocument
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || $self->getParentVXMLDocument
shift() $self->getParentVXMLDocument
Truth table0%0/3
A || B
A= shift()B= $self->getParentVXMLDocument
ABresult
1X1
011
000
140
141  
142 0 return VoiceXML::Client::Item::Util->evaluateCondition($self, $condition, $vxmlDoc);
143
144 }
145
146  
147  
148  
149 3 1;
« Client/Item/Audio.pm ↑ Summary Client/Item/Prompt.pm »