File Coverage

blib/lib/VoiceXML/Client/Item/Goto.pm
Criterion Covered Total %
statement 29 35 82.8
branch 6 14 42.8
condition 2 4 50.0
subroutine 6 6 100.0
pod 1 2 50.0
total 44 61 72.1


line stmt bran cond sub pod time code
1              
2             package VoiceXML::Client::Item::Goto;
3              
4              
5 3     3   17 use base qw (VoiceXML::Client::Item);
  3         6  
  3         227  
6 3     3   19 use VoiceXML::Client::Util;
  3         6  
  3         83  
7              
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 .
39              
40              
41             =cut
42              
43              
44              
45 3     3   15 use strict;
  3         7  
  3         92  
46              
47 3         1147 use vars qw{
48             $VERSION
49 3     3   15 };
  3         5  
50              
51             $VERSION = $VoiceXML::Client::Item::VERSION;
52              
53              
54              
55              
56             sub init {
57 1     1 1 2 my $self = shift;
58            
59 1   50     6 $self->{'next'} = $self->{'XMLElement'}->attribute('next') || '';
60 1   50     30 $self->{'nextitem'} = $self->{'XMLElement'}->attribute('nextitem') || '';
61            
62 1 50       20 VoiceXML::Client::Util::log_msg("GOTO created " . $self->{'next'} . '/' . $self->{'nextitem'})
63             if ($VoiceXML::Client::Debug > 1);
64              
65 1         3 return 1;
66            
67             }
68              
69              
70             sub execute {
71 1     1 0 2 my $self = shift;
72 1         1 my $handle = shift;
73 1         3 my $optParms = shift;
74            
75 1 50       5 VoiceXML::Client::Util::log_msg("Executing ") if ($VoiceXML::Client::Debug > 1);
76            
77 1         9 my $vxmlDoc = $self->getParentVXMLDocument();
78            
79 1 50       6 if ($self->{'next'})
80             {
81             # a uri to go to...
82 0         0 $vxmlDoc->nextDocument($self->{'next'});
83            
84            
85 0 0       0 VoiceXML::Client::Util::log_msg("GOTO Setting next document to " . $self->{'next'}) if ($VoiceXML::Client::Debug);
86 0         0 return $VoiceXML::Client::Flow::Directive{'NEXTDOC'};
87             }
88            
89 1 50       4 if ($self->{'nextitem'})
90             {
91 1         10 my $parentForm = $self->getParentForm();
92            
93            
94 1 50       6 if ($parentForm->nextItem($self->{'nextitem'}))
95             {
96 0         0 $vxmlDoc->nextFormId($parentForm->id());
97             } else {
98 1         6 $vxmlDoc->nextFormId($self->{'nextitem'});
99             }
100            
101 1 50       5 VoiceXML::Client::Util::log_msg("GOTO Setting next item to " . $self->{'nextitem'}) if ($VoiceXML::Client::Debug);
102            
103 1         4 return $VoiceXML::Client::Flow::Directive{'JUMP'};
104             }
105            
106            
107 0           VoiceXML::Client::Util::log_msg("Goto::execute called but no next/nextitem set?");
108            
109 0           return $VoiceXML::Client::Flow::Directive{'ABORT'};
110             }
111            
112              
113              
114             1;