Client/Item/Audio.pm

filter: Statementstmt 88.8% 40 / 45 Branchbran 43.7% 7 / 16 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 8 / 8 Podpod 33.3% 1 / 3 totaltotal 68.6% 59 / 86 CC 12 SCAR 19.9
CC
12
Cov
71%
execute
12.5
getErrorMessageFile
6.6
BEGIN
1.0
CRAP 7.3
« Client/Item.pm ↑ Summary Client/Item/SubDialog.pm »
1  
2 package VoiceXML::Client::Item::Audio;
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 =head1 COPYRIGHT AND LICENSE
10  
11
12 Copyright (C) 2007,2008 by Pat Deegan.
13 All rights reserved
14 http://voicexml.psychogenic.com
15  
16 This library is released under the terms of the GNU GPL version 3, making it available only for
17 free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details).
18 Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to
19 acquire a distinct license for their application. This approach encourages the use of free software
20 while allowing for proprietary solutions that support further development.
21  
22  
23 This file is part of VoiceXML::Client.
24  
25
26
27 VoiceXML::Client is free software: you can redistribute it and/or modify
28 it under the terms of the GNU General Public License as published by
29 the Free Software Foundation, either version 3 of the License, or
30 (at your option) any later version.
31  
32 VoiceXML::Client is distributed in the hope that it will be useful,
33 but WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 GNU General Public License for more details.
36  
37 You should have received a copy of the GNU General Public License
38 along with VoiceXML::Client. If not, see <http://www.gnu.org/licenses/>.
39  
40  
41 =cut
42  
43  
44  
45 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47  
48 3 ▶use vars qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
49 $VERSION
50 3 };
51  
52 3 $VERSION = $VoiceXML::Client::Item::VERSION;
53  
54  
55  
56  
57 7 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
58 7 my $self = shift;
59
60 7 $self->{'src'} = $self->{'XMLElement'}->attribute('src');
61 7 $self->{'expr'} = $self->{'XMLElement'}->attribute('expr');
62
63
64 7 return 1;
65 }
66  
67  
68 3 ▶sub execute {
Subroutine execute: called CC=8 SCAR=25.2
Pod undocumented
69 3 my $self = shift;
70 3 my $handle = shift;
71 3 my $optParams = shift;
72
73 3 my $fileToPlay;
74 3 ▶ if ($self->{'src'})
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'src'}) { } 3 0 3
elsif ($self->{'expr'}) { } 0 0 0
75 {
76 3 $fileToPlay = $self->{'src'};
77 } elsif ($self->{'expr'})
78 {
79 0 $fileToPlay = VoiceXML::Client::Item::Util->evaluateExpression($self, $self->{'expr'});
80
81 } else {
82 0 warn "Audio::execute() called but no src or expr set";
83 }
84
85 3 ▶ VoiceXML::Client::Util::log_msg("Audio element playing $fileToPlay") if ($VoiceXML::Client::Debug);
Branch: 1 branch
BranchTrueFalseTotal
if $VoiceXML::Client::Debug 0 3 3
86
87 3 my $errorFileToPlay;
88 3 ▶ if ($fileToPlay)
Branch: 1 branch
BranchTrueFalseTotal
if ($fileToPlay) { } 3 0 3
89 {
90 3 ▶ if (-e $fileToPlay && -r $fileToPlay)
Branch: 1 branch
BranchTrueFalseTotal
if (-e $fileToPlay and -r $fileToPlay) { } 0 3 3
Condition33%1/3
-e $fileToPlay and -r $fileToPlay
!ll&&!rl&&r
300
MC/DC0%0/2
-e $fileToPlay and -r $fileToPlay
-e $fileToPlay -r $fileToPlay
Truth table33%1/3
A and B
A= -e $fileToPlayB= -r $fileToPlay
ABresult
0X0
100
111
91 {
92 0 $handle->play($fileToPlay);
93 } else {
94 3 VoiceXML::Client::Util::log_msg("Audio element could not find file '$fileToPlay'");
95 3 $errorFileToPlay = $self->getErrorMessageFile();
96 }
97 } else {
98 0 VoiceXML::Client::Util::log_msg("Audio element has no file to play set");
99 0 $errorFileToPlay = $self->getErrorMessageFile();
100 }
101
102 3 ▶ $handle->play($errorFileToPlay) if ($errorFileToPlay);
Branch: 1 branch
BranchTrueFalseTotal
if $errorFileToPlay 0 3 3
103
104 3 return $self->executeChildren($handle, $optParams);
105 }
106  
107 3 ▶sub getErrorMessageFile {
Subroutine getErrorMessageFile: called CC=5 SCAR=18.9
Pod undocumented
108 3 my $self = shift;
109 3 my $params = shift;
110
111 return $params->{'errormsgfile'}
112 3 ▶ if (exists $params->{'errormsgfile'} && $params->{'errormsgfile'} && -r $params->{'errormsgfile'});
Branch: 1 branch
BranchTrueFalseTotal
if exists $params->{"errormsgfile"} and $params->{"errormsgfile"} and -r $params->{"errormsgfile"} 0 3 3
Condition33%2/6
exists $params->{"errormsgfile"} and $params->{"errormsgfile"} and -r $params->{"errormsgfile"}
!ll&&!rl&&r
300
exists $params->{"errormsgfile"} and $params->{"errormsgfile"}
!ll&&!rl&&r
300
MC/DC0%0/3
exists $params->{"errormsgfile"} and $params->{"errormsgfile"} and -r $params->{"errormsgfile"}
exists $params->{"errormsgfile"} $params->{"errormsgfile"} -r $params->{"errormsgfile"}
Truth table25%1/4
A and B and C
A= exists $params->{"errormsgfile"}B= $params->{"errormsgfile"}C= -r $params->{"errormsgfile"}
ABCresult
0XX0
10X0
1100
1111
113  
114 3 ▶ VoiceXML::Client::Util::log_msg("Audio element can't locate error message file") if ($VoiceXML::Client::Debug);
Branch: 1 branch
BranchTrueFalseTotal
if $VoiceXML::Client::Debug 0 3 3
115
116 3 return undef;
117 }
118  
119 3 1;
« Client/Item.pm ↑ Summary Client/Item/SubDialog.pm »