Usul/Constants.pm

filter: Statementstmt 98.4% 63 / 64 Branchbran 75.0% 12 / 16 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 96.5% 28 / 29 Podpod 100% 21 / 21 totaltotal 90.0% 126 / 140 CC 11 SCAR 7.0
CC
11
Cov
90%
Config_Extn
4.3
Log_Levels
4.3
Assert
3.0
CRAP 2.0
« Usul/Crypt.pm ↑ Summary Usul/Config/Programs.pm »
1 package Class::Usul::Constants;
2  
3 27 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 27 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 27 ▶use parent 'Exporter::Tiny';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 27 ▶use Class::Usul::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 27 ▶use File::DataClass::Constants ( );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 27 ▶use File::Spec::Functions qw( tmpdir );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 27 ▶use IPC::SRLock::Constants ( );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 27 ▶my $Assert = sub {};
Subroutine __ANON__: called CC=1 SCAR=0.0
13 27 my $Config_Extn = '.json';
14 27 my $Exception_Class = 'Class::Usul::Exception';
15 27 my $Log_Levels = [ qw( alert debug error fatal info warn ) ];
16  
17 27 __PACKAGE__->Exception_Class( $Exception_Class ); # Trigger redispatch
18  
19 27 our @EXPORT = qw( ARRAY AS_PARA AS_PASSWORD ASSERT BRK CODE COMMA CONFIG_EXTN
20 DEFAULT_CONFHOME DEFAULT_ENVDIR DEFAULT_ENCODING
21 DEFAULT_L10N_DOMAIN DIGEST_ALGORITHMS ENCODINGS
22 EXCEPTION_CLASS FAILED FALSE HASH LANG LBRACE
23 LOCALIZE LOG_LEVELS NO NUL OK PERL_EXTNS PHASE
24 PREFIX QUIT QUOTED_RE SEP SPC TRUE UMASK UNDEFINED_RV
25 UNTAINT_CMDLINE UNTAINT_IDENTIFIER UNTAINT_PATH
26 UUID_PATH WIDTH YES );
27  
28 sub ARRAY () { 'ARRAY' }
29 sub BRK () { ': ' }
30 sub CODE () { 'CODE' }
31 sub COMMA () { ',' }
32 sub FAILED () { 1 }
33 sub FALSE () { 0 }
34 sub HASH () { 'HASH' }
35 sub LANG () { 'en' }
36 sub LBRACE () { '{' }
37 sub LOCALIZE () { '[_' }
38 sub NO () { 'n' }
39 sub NUL () { q() }
40 sub OK () { 0 }
41 sub PHASE () { 2 }
42 sub QUIT () { 'q' }
43 sub SEP () { '/' }
44 sub SPC () { ' ' }
45 sub TRUE () { 1 }
46 sub UMASK () { '027' }
47 sub WIDTH () { 80 }
48 sub YES () { 'y' }
49  
50 1 ▶sub AS_PARA () { { cl => 1, fill => 1, nl => 1 } }
Subroutine AS_PARA: called CC=1 SCAR=0.0
Pod documented
51 1 ▶sub AS_PASSWORD () { ( q(), 1, 0, 0, 1 ) }
Subroutine AS_PASSWORD: called CC=1 SCAR=0.0
Pod documented
52 4 ▶sub ASSERT () { __PACKAGE__->Assert }
Subroutine ASSERT: called CC=1 SCAR=0.0
Pod documented
53 21 ▶sub CONFIG_EXTN () { __PACKAGE__->Config_Extn }
Subroutine CONFIG_EXTN: called CC=1 SCAR=0.0
Pod documented
54 40 ▶sub DEFAULT_CONFHOME () { tmpdir }
Subroutine DEFAULT_CONFHOME: called CC=1 SCAR=0.0
Pod documented
55 sub DEFAULT_ENCODING () { 'UTF-8' }
56 21 ▶sub DEFAULT_ENVDIR () { [ q(), qw( etc default ) ] }
Subroutine DEFAULT_ENVDIR: called CC=1 SCAR=0.0
Pod documented
57 sub DEFAULT_L10N_DOMAIN () { 'default' }
58 3 ▶sub DIGEST_ALGORITHMS () { ( qw( SHA-512 SHA-256 SHA-1 MD5 ) ) }
Subroutine DIGEST_ALGORITHMS: called CC=1 SCAR=0.0
Pod documented
59 1 ▶sub ENCODINGS () { ( qw( ascii iso-8859-1 UTF-8 guess ) ) }
Subroutine ENCODINGS: called CC=1 SCAR=0.0
Pod documented
60 316 ▶sub EXCEPTION_CLASS () { __PACKAGE__->Exception_Class }
Subroutine EXCEPTION_CLASS: called CC=1 SCAR=0.0
Pod documented
61 417 ▶sub LOG_LEVELS () { @{ __PACKAGE__->Log_Levels } }
Subroutine LOG_LEVELS: called CC=1 SCAR=0.0
Pod documented
62 10 ▶sub PERL_EXTNS () { ( qw( .pl .pm .t ) ) }
Subroutine PERL_EXTNS: called CC=1 SCAR=0.0
Pod documented
63 21 ▶sub PREFIX () { [ q(), 'opt' ] }
Subroutine PREFIX: called CC=1 SCAR=0.0
Pod documented
64 3 ▶sub QUOTED_RE () { qr{ (?:(?:\")(?:[^\\\"]*(?:\\.[^\\\"]*)*)(?:\")|(?:\')(?:[^\\\']*(?:\\.[^\\\']*)*)(?:\')|(?:\`)(?:[^\\\`]*(?:\\.[^\\\`]*)*)(?:\`)) }mx }
Subroutine QUOTED_RE: called CC=1 SCAR=0.0
Pod documented
65 sub UNDEFINED_RV () { -1 }
66 58 ▶sub UNTAINT_CMDLINE () { qr{ \A ([^\$&;<>\`|]+) \z }mx }
Subroutine UNTAINT_CMDLINE: called CC=1 SCAR=0.0
Pod documented
67 16 ▶sub UNTAINT_IDENTIFIER () { qr{ \A ([a-zA-Z0-9_]+) \z }mx }
Subroutine UNTAINT_IDENTIFIER: called CC=1 SCAR=0.0
Pod documented
68 1276 ▶sub UNTAINT_PATH () { qr{ \A ([^\$%&\*;<>\`|]+) \z }mx }
Subroutine UNTAINT_PATH: called CC=1 SCAR=0.0
Pod documented
69 0 ▶sub UUID_PATH () { [ q(), qw( proc sys kernel random uuid ) ] }
Subroutine UUID_PATH: not called CC=1 SCAR=6.9
Pod documented
70  
71 5 ▶sub Assert {
Subroutine Assert: called CC=3 SCAR=11.0
Pod documented
72 5 ▶ my ($self, $subr) = @_; defined $subr or return $Assert;
Branch: 1 branch
BranchTrueFalseTotal
defined $subr or return $Assert 1 4 5
73  
74 1 ▶ ref $subr eq 'CODE' or EXCEPTION_CLASS->throw
Branch: 1 branch
BranchTrueFalseTotal
ref $subr eq "CODE" or &EXCEPTION_CLASS()->throw("Assert subroutine $subr is not a code reference") 1 0 1
75 ( "Assert subroutine ${subr} is not a code reference" );
76  
77 1 return $Assert = $subr;
78 }
79  
80 22 ▶sub Config_Extn {
Subroutine Config_Extn: called CC=4 SCAR=14.6
Pod documented
81 22 ▶ my ($self, $extn) = @_; defined $extn or return $Config_Extn;
Branch: 1 branch
BranchTrueFalseTotal
defined $extn or return $Config_Extn 1 21 22
82  
83 1 ▶ (length $extn < 255 and $extn !~ m{ \n }mx) or EXCEPTION_CLASS->throw
Branch: 1 branch
BranchTrueFalseTotal
length $extn < 255 and not $extn =~ / \n /mx or &EXCEPTION_CLASS()->throw("Config extension $extn is not a simple string") 1 0 1
Condition33%1/3
length $extn < 255 and not $extn =~ / \n /mx
!ll&&!rl&&r
001
MC/DC0%0/2
length $extn < 255 and not $extn =~ / \n /mx
length $extn < 255 not $extn =~ / \n /mx
Truth table33%1/3
A and not(B)
A= length $extn < 255B= not $extn =~ / \n /mx
ABresult
0X0
100
111
84 ( "Config extension ${extn} is not a simple string" );
85  
86 1 return $Config_Extn = $extn;
87 }
88  
89 343 ▶sub Exception_Class {
Subroutine Exception_Class: called CC=3 SCAR=11.0
Pod documented
90 343 ▶ my ($self, $class) = @_; defined $class or return $Exception_Class;
Branch: 1 branch
BranchTrueFalseTotal
defined $class or return $Exception_Class 27 316 343
91  
92 27 ▶ $class->can( 'throw' ) or $Exception_Class->throw
Branch: 1 branch
BranchTrueFalseTotal
$class->can("throw") or $Exception_Class->throw("Exception class $class is not loaded or has no throw method") 27 0 27
93 ( "Exception class ${class} is not loaded or has no throw method" );
94  
95 27 File::DataClass::Constants->Exception_Class( $class );
96 27 IPC::SRLock::Constants->Exception_Class( $class );
97  
98 27 return $Exception_Class = $class;
99 }
100  
101 418 ▶sub Log_Levels {
Subroutine Log_Levels: called CC=4 SCAR=14.6
Pod documented
102 418 ▶ my ($self, $levels) = @_; defined $levels or return $Log_Levels;
Branch: 1 branch
BranchTrueFalseTotal
defined $levels or return $Log_Levels 1 417 418
103  
104 1 ▶ ref $levels eq 'ARRAY' and defined $levels->[ 0 ] or EXCEPTION_CLASS->throw
Branch: 1 branch
BranchTrueFalseTotal
ref $levels eq "ARRAY" and defined $levels->[0] or &EXCEPTION_CLASS()->throw("Log levels must be an array reference with one defined value") 1 0 1
Condition33%1/3
ref $levels eq "ARRAY" and defined $levels->[0]
!ll&&!rl&&r
001
MC/DC0%0/2
ref $levels eq "ARRAY" and defined $levels->[0]
ref $levels eq "ARRAY" defined $levels->[0]
Truth table33%1/3
A and B
A= ref $levels eq "ARRAY"B= defined $levels->[0]
ABresult
0X0
100
111
105 ( "Log levels must be an array reference with one defined value" );
106  
107 1 return $Log_Levels = $levels;
108 }
109  
110 27 1;
111  
112 __END__
« Usul/Crypt.pm ↑ Summary Usul/Config/Programs.pm »