constraint.pm

filter: Statementstmt 57.1% 12 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 57.1% 16 / 28 CC 2 SCAR 11.0
CC
2
Cov
52%
getMessage
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« tag.pm ↑ Summary actionbar.pm »
1 package HTML::GUI::constraint;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use HTML::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 HTML::GUI::constraint - constraint managing
11  
12 =head1 VERSION
13  
14 Version 0.01
15  
16 =cut
17  
18 2 our $VERSION = '0.01';
19  
20  
21  
22 =head1 CONSTRAINT
23  
24 Module for managing the contraints
25  
26 =cut
27  
28 #a list of the messages to use in case a constraint is violated
29  
30 2 my %errorMessages = (
31 required => 'The input "<TMPL_VAR NAME=widgetLabel>" is mandatory.' ,
32 default => 'The constraint "<TMPL_VAR NAME=constraint-name>" is violated. Please correct it.'
33 );
34  
35 =head1 PUBLIC METHODS
36  
37 =pod
38  
39 =head3 getMessage
40
41 returns the message corresponding to $constrName filled
42 with the values of $params
43  
44 Parameters :
45 constrName : a string containing the name of the constraint
46 params : hash ref containing the values to fill the message
47  
48 =cut
49  
50 0 ▶sub getMessage{
Subroutine getMessage: not called CC=2 SCAR=17.9
Pod documented
51 0 my ($params)=@_;
52 0 my $tplTxt = '';
53 0 my $constrName = $params->{'constraint-name'};
54 0 ▶ if (exists $errorMessages{$constrName}){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $errorMessages{$constrName}) { } 0 0 0
55 0 $tplTxt = $errorMessages{$constrName};
56 }else{
57 0 $tplTxt = $errorMessages{default};
58 }
59 0 my $tplObj = HTML::Template->new( scalarref => \$tplTxt,
60 option => 'value',
61 die_on_bad_params => 0,
62 );
63 0 $tplObj->param($params);
64 0 return $tplObj->output();
65  
66 }
67  
68 =head1 AUTHOR
69  
70 Jean-Christian Hassler, C<< <jhassler at free.fr> >>
71  
72 =head1 BUGS
73  
74 Please report any bugs or feature requests to
75 C<bug-gui-libhtml-constraint at rt.cpan.org>, or through the web interface at
76 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-GUI-widget>.
77 I will be notified, and then you'll automatically be notified of progress on
78 your bug as I make changes.
79  
80 =head1 SUPPORT
81  
82 You can find documentation for this module with the perldoc command.
83  
84 perldoc HTML::GUI::widget
85  
86 You can also look for information at:
87  
88 =over 4
89  
90 =item * AnnoCPAN: Annotated CPAN documentation
91  
92 L<http://annocpan.org/dist/HTML-GUI-widget>
93  
94 =item * CPAN Ratings
95  
96 L<http://cpanratings.perl.org/d/HTML-GUI-widget>
97  
98 =item * RT: CPAN's request tracker
99  
100 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-GUI-widget>
101  
102 =item * Search CPAN
103  
104 L<http://search.cpan.org/dist/HTML-GUI-widget>
105  
106 =back
107  
108 =head1 ACKNOWLEDGEMENTS
109  
110 =head1 COPYRIGHT & LICENSE
111  
112 Copyright 2007 Jean-Christian Hassler, all rights reserved.
113  
114 This program is free software; you can redistribute it and/or modify it
115 under the same terms as Perl itself.
116  
117 =cut
118  
119 2 1; # End of HTML::GUI::constraint
« tag.pm ↑ Summary actionbar.pm »