File Coverage

blib/lib/WebDyne/Err/Constant.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition 1 2 50.0
subroutine 6 6 100.0
pod 0 1 0.0
total 26 28 92.8


line stmt bran cond sub pod time code
1             #
2             # This file is part of WebDyne.
3             #
4             # This software is Copyright (c) 2017 by Andrew Speer .
5             #
6             # This is free software, licensed under:
7             #
8             # The GNU General Public License, Version 2, June 1991
9             #
10             # Full license text is available at:
11             #
12             #
13             #
14             package WebDyne::Err::Constant;
15              
16              
17             # Pragma
18             #
19 2     2   11 use strict qw(vars);
  2         3  
  2         61  
20 2     2   9 use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT_OK @EXPORT %Constant);
  2         3  
  2         113  
21 2     2   11 use warnings;
  2         2  
  2         48  
22 2     2   9 no warnings qw(uninitialized);
  2         2  
  2         70  
23             local $^W=0;
24              
25              
26             # Need the File::Spec module
27             #
28 2     2   9 use File::Spec;
  2         4  
  2         418  
29              
30              
31             # Version information
32             #
33             $VERSION='1.248';
34              
35              
36             # Hash of constants
37             #
38             %Constant=(
39              
40              
41             # Where we keep the error template
42             #
43             WEBDYNE_ERR_TEMPLATE => File::Spec->catfile(&class_dn(__PACKAGE__), 'error.psp'),
44              
45              
46             # If set to 1, error messages will be sent as text/plain, not
47             # HTML. If ERROR_EXIT set, child will quit after an error
48             #
49             WEBDYNE_ERROR_TEXT => 0,
50             WEBDYNE_ERROR_EXIT => 0,
51              
52              
53             );
54              
55              
56             sub class_dn {
57              
58              
59             # Get class dir
60             #
61 2     2 0 3 my $class=shift();
62              
63              
64             # Get package file name so we can look up in inc
65             #
66 2         11 (my $class_fn="${class}.pm")=~s/::/\//g;
67 2   50     10 $class_fn=$INC{$class_fn} ||
68             die("unable to find location for $class in \%INC");
69              
70              
71             # Split
72             #
73 2         61 my $class_dn=(File::Spec->splitpath($class_fn))[1];
74              
75             }
76              
77              
78             # Export constants to namespace, place in export tags
79             #
80             require Exporter;
81             require WebDyne::Constant;
82             @ISA=qw(Exporter WebDyne::Constant);
83             +__PACKAGE__->local_constant_load(\%Constant);
84             foreach (keys %Constant) {${$_}=$Constant{$_}}
85             @EXPORT=map {'$' . $_} keys %Constant;
86             @EXPORT_OK=@EXPORT;
87             %EXPORT_TAGS=(all => [@EXPORT_OK]);
88             $_=\%Constant;