GX/Meta/Util.pm

filter: Statementstmt 89.9% 777 / 864 Branchbran 81.9% 485 / 592 Conditioncond 38.6% 58 / 150 MC/DCmcdc 28.1% 20 / 71 Subroutinesub 100% 100 / 100 Podpod 100% 14 / 14 totaltotal 81.1% 1454 / 1791 CC 713 SCAR 30.1
CC
713
Cov
82%
__ANON__
85.8
__ANON__
59.4
__ANON__
59.4
CRAP 20.2
« GX/Route/Dynamic.pm ↑ Summary GX/Component.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/Meta/Util.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::Meta::Util;
7  
8 384 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 384 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 367 ▶use GX::Meta::Constants qw( REGEX_IDENTIFIER REGEX_MODULE_NAME REGEX_PACKAGE_NAME );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 376 ▶use GX::Meta::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 369 ▶use File::Find ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 378 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 367 ▶use File::Spec::Unix ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 # ----------------------------------------------------------------------------------------------------------------------
20 # Constants
21 # ----------------------------------------------------------------------------------------------------------------------
22  
23 370 ▶use constant UNIX_PATHS => ( $File::Spec::ISA[0] eq 'File::Spec::Unix' ) ? 1 : 0;
Subroutine BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
$File::Spec::ISA[0] eq 'File::Spec::Unix' ? : 371 0 371
24  
25  
26 # ----------------------------------------------------------------------------------------------------------------------
27 # Public functions
28 # ----------------------------------------------------------------------------------------------------------------------
29  
30 6555 ▶sub eval_code {
Subroutine eval_code: called CC=5 SCAR=16.5
Pod documented
31  
32 6625 my $code = shift;
33 6562 my $variables = shift;
34  
35 6637 ▶ if ( ref $code eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $code eq "ARRAY") 6544 82 6626
36 6629 $code = join( "\n", @$code );
37 }
38  
39 6562 my @EVAL_VARS;
40  
41 6637 ▶ if ( defined $variables ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $variables) 6620 1 6621
42  
43 6624 my @code;
44  
45 6571 my $i = 0;
46  
47 6646 ▶ while ( my ( $name, $value ) = each %$variables ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$variables) 3560 6619 10179
48 3637 push @code, 'my ' . $name . ' = $EVAL_VARS[' . $i++ . '];';
49 3573 push @EVAL_VARS, $value;
50 }
51  
52 6646 $code = join( "\n", @code, $code );
53  
54 }
55  
56 0 ▶ my $result = eval $code;
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=13 SCAR=26.7
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=13 SCAR=26.7
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=30 SCAR=36.4
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=5 SCAR=16.5
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=5 SCAR=16.5
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=57 SCAR=44.5
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=20 SCAR=31.6
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=7 SCAR=20.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=5 SCAR=16.5
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=13 SCAR=26.7
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=7 SCAR=20.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=7 SCAR=20.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=3 SCAR=11.2
Subroutine __ANON__: called CC=3 SCAR=11.2
Branch: 256 branches
BranchTrueFalseTotal
unless (exists $_[0]{"code"}) 133 670 803
unless (exists $self->{"arguments"}) 247 440 687
if (exists $args->{"arguments"}) 87 555 642
eval { do { local $_ = $args->{"arguments"}; ref $constraint ? &$constraint($constraint, $args->{"arguments"}) : $self->$constraint($args->{"arguments"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"arguments\"") 105 135 240
ref $constraint ? : 30 86 116
unless (exists $self->{"code"}) 187 62 249
if (exists $args->{'code'}) { } 123 85 208
eval { do { local $_ = $args->{"code"}; ref $constraint ? &$constraint($constraint, $args->{"code"}) : $self->$constraint($args->{"code"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"code\"") 186 13 199
ref $constraint ? : 127 76 203
unless (exists $_[0]{"controller"}) 272 998 1270
unless (exists $_[0]{"method"}) 170 844 1014
unless (exists $_[0]{"code"}) 217 419 636
unless (exists $_[0]{"dispatch_code"}) 1531 2539 4070
unless (exists $_[0]{"id"}) 1594 285 1879
unless (exists $self->{"arguments"}) 185 1620 1805
if (exists $args->{"arguments"}) 139 232 371
eval { do { local $_ = $args->{"arguments"}; ref $constraint ? &$constraint($constraint, $args->{"arguments"}) : $self->$constraint($args->{"arguments"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"arguments\"") 61 106 167
ref $constraint ? : 160 95 255
unless (exists $self->{"controller"}) 103 199 302
if (exists $args->{'controller'}) { } 164 36 200
ref $processor ? : 188 102 290
eval { do { local $_ = $value; ref $constraint ? &$constraint($constraint, $value) : $self->$constraint($value) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"controller\"") 155 145 300
ref $constraint ? : 286 93 379
eval { do { local $_ = $value; ref $constraint ? &$constraint($constraint, $value) : $self->$constraint($value) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"controller\"") 157 202 359
ref $constraint ? : 167 80 247
if ref $self->{"controller"} 137 107 244
unless (exists $self->{"method"}) 176 75 251
if (exists $args->{'method'}) { } 128 120 248
eval { do { local $_ = $args->{"method"}; ref $constraint ? &$constraint($constraint, $args->{"method"}) : $self->$constraint($args->{"method"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"method\"") 237 84 321
ref $constraint ? : 122 190 312
eval { do { local $_ = $args->{"method"}; ref $constraint ? &$constraint($constraint, $args->{"method"}) : $self->$constraint($args->{"method"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"method\"") 240 75 315
ref $constraint ? : 123 192 315
unless (exists $self->{"code"}) 237 76 313
if (exists $args->{'code'}) { } 80 232 312
eval { do { local $_ = $args->{"code"}; ref $constraint ? &$constraint($constraint, $args->{"code"}) : $self->$constraint($args->{"code"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"code\"") 201 75 276
ref $constraint ? : 84 198 282
unless (exists $self->{"dispatch_code"}) 240 79 319
if (exists $args->{'dispatch_code'}) { } 104 133 237
eval { do { local $_ = $args->{"dispatch_code"}; ref $constraint ? &$constraint($constraint, $args->{"dispatch_code"}) : $self->$constraint($args->{"dispatch_code"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"dispatch_code\"") 198 0 198
ref $constraint ? : 81 117 198
unless (exists $self->{"id"}) 223 1 224
if (exists $args->{'id'}) { } 7 220 227
eval { do { local $_ = $args->{"id"}; ref $constraint ? &$constraint($constraint, $args->{"id"}) : $self->$constraint($args->{"id"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"id\"") 87 4 91
ref $constraint ? : 10 81 91
unless (exists $_[0]{"name"}) 65 129 194
unless (exists $self->{"name"}) 31 30 61
if (exists $args->{'name'}) { } 51 10 61
eval { do { local $_ = $args->{"name"}; ref $constraint ? &$constraint($constraint, $args->{"name"}) : $self->$constraint($args->{"name"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"name\"") 38 51 89
ref $constraint ? : 45 15 60
unless (exists $self->{"callbacks"}) 25 28 53
if (exists $args->{'callbacks'}) { } 23 0 23
eval { do { local $_ = $args->{"callbacks"}; ref $constraint ? &$constraint($constraint, $args->{"callbacks"}) : $self->$constraint($args->{"callbacks"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"callbacks\"") 28 4 32
ref $constraint ? : 9 9 18
unless (exists $_[0]{"invocant"}) 18 113 131
unless (exists $_[0]{"method"}) 7 98 105
unless (exists $_[0]{"code"}) 17 19 36
unless (exists $self->{"arguments"}) 17 12 29
if (exists $args->{"arguments"}) 14 144 158
eval { do { local $_ = $args->{"arguments"}; ref $constraint ? &$constraint($constraint, $args->{"arguments"}) : $self->$constraint($args->{"arguments"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"arguments\"") 74 67 141
ref $constraint ? : 98 11 109
unless (exists $self->{"invocant"}) 96 5 101
if (exists $args->{'invocant'}) { } 93 3 96
eval { do { local $_ = $args->{"invocant"}; ref $constraint ? &$constraint($constraint, $args->{"invocant"}) : $self->$constraint($args->{"invocant"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"invocant\"") 31 65 96
ref $constraint ? : 95 1 96
if ref $self->{"invocant"} 29 66 95
unless (exists $self->{"method"}) 382 57 439
if (exists $args->{'method'}) { } 30 393 423
eval { do { local $_ = $args->{"method"}; ref $constraint ? &$constraint($constraint, $args->{"method"}) : $self->$constraint($args->{"method"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"method\"") 32 23 55
ref $constraint ? : 81 21 102
eval { do { local $_ = $args->{"method"}; ref $constraint ? &$constraint($constraint, $args->{"method"}) : $self->$constraint($args->{"method"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"method\"") 377 114 491
ref $constraint ? : 16 419 435
unless (exists $self->{"code"}) 14 25 39
if (exists $args->{'code'}) { } 18 24 42
eval { do { local $_ = $args->{"code"}; ref $constraint ? &$constraint($constraint, $args->{"code"}) : $self->$constraint($args->{"code"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"code\"") 19 24 43
ref $constraint ? : 14 28 42
unless (exists $self->{"handlers"}) 13 45 58
if (exists $args->{'handlers'}) { } 3 28 31
eval { do { local $_ = $args->{"handlers"}; ref $constraint ? &$constraint($constraint, $args->{"handlers"}) : $self->$constraint($args->{"handlers"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"handlers\"") 22 54 76
ref $constraint ? : 111 89 200
unless (exists $invocant->{"data"}) 32 72 104
if (@_ > 1) { } 15 69 84
unless (exists $_[0]{"encoding"}) 15 12 27
unless (exists $self->{"data"}) 80 91 171
if (exists $args->{"data"}) 10 84 94
eval { do { local $_ = $args->{"data"}; ref $constraint ? &$constraint($constraint, $args->{"data"}) : $self->$constraint($args->{"data"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"data\"") 210 22 232
ref $constraint ? : 199 17 216
unless (exists $self->{"encoding"}) 195 6 201
if (exists $args->{"encoding"}) 201 5 206
if (@_ > 1) { } 191 6 197
unless (exists $_[0]{"action"}) 191 0 191
if (@_ > 1) { } 191 0 191
unless (exists $_[0]{"format"}) 5 190 195
if (@_ > 1) { } 1 4 5
unless (exists $_[0]{"parameters"}) 1 0 1
unless (exists $self->{"action"}) 1 0 1
if (exists $args->{"action"}) 5 0 5
unless (exists $self->{"format"}) 191 4 195
if (exists $args->{"format"}) 8 187 195
unless (exists $self->{"parameters"}) 4 4 8
if (exists $args->{"parameters"}) 4 0 4
unless (exists $_[0]{"action"}) 291 34 325
unless (exists $invocant->{"constraints"}) 101 124 225
unless (exists $invocant->{"defaults"}) 191 0 191
unless (exists $_[0]{"host"}) 0 191 191
unless (exists $_[0]{"host_regex"}) 75 75 150
unless (exists $invocant->{"host_variables"}) 100 118 218
unless (exists $_[0]{"is_reversible"}) 191 43 234
unless (exists $invocant->{"methods"}) 0 191 191
unless (exists $_[0]{"methods_regex"}) 0 0 0
unless (exists $_[0]{"path"}) 75 75 150
unless (exists $_[0]{"path_regex"}) 191 75 266
unless (exists $invocant->{"path_variables"}) 0 191 191
unless (exists $_[0]{"reverse_host"}) 0 0 0
unless (exists $invocant->{"reverse_host_variables"}) 0 0 0
unless (exists $_[0]{"reverse_path"}) 191 0 191
unless (exists $invocant->{"reverse_path_variables"}) 5 186 191
unless (exists $_[0]{"reverse_scheme"}) 5 0 5
unless (exists $invocant->{"schemes"}) 5 0 5
unless (exists $_[0]{"schemes_regex"}) 5 0 5
unless (exists $self->{"action"}) 105 13 118
if (exists $args->{'action'}) { } 5 13 18
eval { do { local $_ = $args->{"action"}; ref $constraint ? &$constraint($constraint, $args->{"action"}) : $self->$constraint($args->{"action"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"action\"") 191 0 191
ref $constraint ? : 0 191 191
eval { do { local $_ = $args->{"action"}; ref $constraint ? &$constraint($constraint, $args->{"action"}) : $self->$constraint($args->{"action"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"action\"") 75 75 150
ref $constraint ? : 100 75 175
unless (exists $self->{"constraints"}) 191 100 291
if (exists $args->{'constraints'}) { } 186 105 291
eval { do { local $_ = $args->{"constraints"}; ref $constraint ? &$constraint($constraint, $args->{"constraints"}) : $self->$constraint($args->{"constraints"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"constraints\"") 191 100 291
ref $constraint ? : 100 191 291
eval { do { local $_ = $args->{"constraints"}; ref $constraint ? &$constraint($constraint, $args->{"constraints"}) : $self->$constraint($args->{"constraints"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"constraints\"") 0 100 100
ref $constraint ? : 100 0 100
unless (exists $self->{"defaults"}) 191 100 291
if (exists $args->{'defaults'}) { } 100 191 291
eval { do { local $_ = $args->{"defaults"}; ref $constraint ? &$constraint($constraint, $args->{"defaults"}) : $self->$constraint($args->{"defaults"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"defaults\"") 0 100 100
ref $constraint ? : 100 0 100
unless (exists $self->{"host"}) 191 100 291
if (exists $args->{'host'}) { } 102 189 291
unless (exists $self->{"host_regex"}) 191 100 291
if (exists $args->{"host_regex"}) 100 191 291
eval { do { local $_ = $args->{"host_regex"}; ref $constraint ? &$constraint($constraint, $args->{"host_regex"}) : $self->$constraint($args->{"host_regex"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"host_regex\"") 0 100 100
ref $constraint ? : 100 0 100
unless (exists $self->{"host_variables"}) 191 100 291
if (exists $args->{"host_variables"}) 100 191 291
eval { do { local $_ = $args->{"host_variables"}; ref $constraint ? &$constraint($constraint, $args->{"host_variables"}) : $self->$constraint($args->{"host_variables"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"host_variables\"") 191 100 291
ref $constraint ? : 100 191 291
unless (exists $self->{"is_reversible"}) 0 100 100
if (exists $args->{'is_reversible'}) { } 100 0 100
defined $args->{'is_reversible'} ? : 191 100 291
$args->{'is_reversible'} ? : 102 189 291
unless (exists $self->{"methods"}) 191 100 291
if (exists $args->{'methods'}) { } 108 183 291
eval { do { local $_ = $args->{"methods"}; ref $constraint ? &$constraint($constraint, $args->{"methods"}) : $self->$constraint($args->{"methods"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"methods\"") 8 100 108
ref $constraint ? : 108 0 108
eval { do { local $_ = $args->{"methods"}; ref $constraint ? &$constraint($constraint, $args->{"methods"}) : $self->$constraint($args->{"methods"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"methods\"") 8 100 108
ref $constraint ? : 108 0 108
ref $processor ? : 8 100 108
unless (exists $self->{"methods_regex"}) 291 0 291
if (exists $args->{"methods_regex"}) 0 291 291
eval { do { local $_ = $args->{"methods_regex"}; ref $constraint ? &$constraint($constraint, $args->{"methods_regex"}) : $self->$constraint($args->{"methods_regex"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"methods_regex\"") 100 0 100
ref $constraint ? : 0 100 100
unless (exists $self->{"path"}) 108 98 206
if (exists $args->{'path'}) { } 6 154 160
unless (exists $self->{"path_regex"}) 114 34 148
if (exists $args->{"path_regex"}) 11 159 170
eval { do { local $_ = $args->{"path_regex"}; ref $constraint ? &$constraint($constraint, $args->{"path_regex"}) : $self->$constraint($args->{"path_regex"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"path_regex\"") 102 63 165
ref $constraint ? : 10 140 150
unless (exists $self->{"path_variables"}) 84 17 101
if (exists $args->{"path_variables"}) 72 3 75
eval { do { local $_ = $args->{"path_variables"}; ref $constraint ? &$constraint($constraint, $args->{"path_variables"}) : $self->$constraint($args->{"path_variables"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"path_variables\"") 69 3 72
ref $constraint ? : 71 2 73
unless (exists $self->{"reverse_host"}) 67 2 69
if (exists $args->{"reverse_host"}) 69 0 69
unless (exists $self->{"reverse_host_variables"}) 67 2 69
if (exists $args->{"reverse_host_variables"}) 21 48 69
eval { do { local $_ = $args->{"reverse_host_variables"}; ref $constraint ? &$constraint($constraint, $args->{"reverse_host_variables"}) : $self->$constraint($args->{"reverse_host_variables"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"reverse_host_variables\"") 19 2 21
ref $constraint ? : 21 0 21
unless (exists $self->{"reverse_path"}) 67 2 69
if (exists $args->{"reverse_path"}) 0 67 67
unless (exists $self->{"reverse_path_variables"}) 0 0 0
if (exists $args->{"reverse_path_variables"}) 0 0 0
eval { do { local $_ = $args->{"reverse_path_variables"}; ref $constraint ? &$constraint($constraint, $args->{"reverse_path_variables"}) : $self->$constraint($args->{"reverse_path_variables"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"reverse_path_variables\"") 67 0 67
ref $constraint ? : 13 54 67
unless (exists $self->{"reverse_scheme"}) 13 0 13
if (exists $args->{"reverse_scheme"}) 13 0 13
unless (exists $self->{"schemes"}) 13 0 13
if (exists $args->{'schemes'}) { } 67 0 67
eval { do { local $_ = $args->{"schemes"}; ref $constraint ? &$constraint($constraint, $args->{"schemes"}) : $self->$constraint($args->{"schemes"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"schemes\"") 67 0 67
ref $constraint ? : 67 0 67
eval { do { local $_ = $args->{"schemes"}; ref $constraint ? &$constraint($constraint, $args->{"schemes"}) : $self->$constraint($args->{"schemes"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"schemes\"") 67 0 67
ref $constraint ? : 67 0 67
ref $processor ? : 67 0 67
unless (exists $self->{"schemes_regex"}) 67 0 67
if (exists $args->{"schemes_regex"}) 13 54 67
eval { do { local $_ = $args->{"schemes_regex"}; ref $constraint ? &$constraint($constraint, $args->{"schemes_regex"}) : $self->$constraint($args->{"schemes_regex"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"schemes_regex\"") 13 0 13
ref $constraint ? : 13 0 13
unless (exists $_[0]{"action"}) 13 0 13
unless (exists $_[0]{"host"}) 20 17 37
unless (exists $_[0]{"is_reversible"}) 2 41 43
unless (exists $_[0]{"method"}) 11 41 52
unless (exists $_[0]{"path"}) 14 36 50
unless (exists $_[0]{"scheme"}) 17 19 36
unless (exists $self->{"action"}) 14 40 54
if (exists $args->{'action'}) { } 14 24 38
eval { do { local $_ = $args->{"action"}; ref $constraint ? &$constraint($constraint, $args->{"action"}) : $self->$constraint($args->{"action"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"action\"") 20 19 39
ref $constraint ? : 10 35 45
eval { do { local $_ = $args->{"action"}; ref $constraint ? &$constraint($constraint, $args->{"action"}) : $self->$constraint($args->{"action"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"action\"") 16 21 37
ref $constraint ? : 5 18 23
unless (exists $self->{"host"}) 8 10 18
if (exists $args->{'host'}) { } 5 10 15
eval { do { local $_ = $args->{"host"}; ref $constraint ? &$constraint($constraint, $args->{"host"}) : $self->$constraint($args->{"host"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"host\"") 1 4 5
ref $constraint ? : 12 56 68
unless (exists $self->{"is_reversible"}) 14 44 58
if (exists $args->{'is_reversible'}) { } 7 10 17
defined $args->{'is_reversible'} ? : 0 0 0
$args->{'is_reversible'} ? : 20 44 64
unless (exists $self->{"method"}) 8 23 31
if (exists $args->{'method'}) { } 9 18 27
eval { do { local $_ = $value; ref $constraint ? &$constraint($constraint, $value) : $self->$constraint($value) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"method\"") 10 15 25
ref $constraint ? : 10 23 33
ref $processor ? : 10 8 18
unless (exists $self->{"path"}) 0 0 0
if (exists $args->{'path'}) { } 7 0 7
eval { do { local $_ = $args->{"path"}; ref $constraint ? &$constraint($constraint, $args->{"path"}) : $self->$constraint($args->{"path"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"path\"") 28 9 37
ref $constraint ? : 3 23 26
eval { do { local $_ = $args->{"path"}; ref $constraint ? &$constraint($constraint, $args->{"path"}) : $self->$constraint($args->{"path"}) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"path\"") 2 1 3
ref $constraint ? : 2 2 4
unless (exists $self->{"scheme"}) 20 0 20
if (exists $args->{'scheme'}) { } 0 20 20
eval { do { local $_ = $value; ref $constraint ? &$constraint($constraint, $value) : $self->$constraint($value) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"scheme\"") 0 0 0
ref $constraint ? : 0 0 0
ref $processor ? : 20 0 20
if ref $CLASS_DATA->{"application"} 0 20 20
unless (exists $CLASS_DATA->{"application"}) 20 0 20
unless (exists $CLASS_DATA->{"component_state"}) 0 20 20
unless (exists $CLASS_DATA->{"config"}) 0 0 0
unless (exists $CLASS_DATA->{"handlers"}) 0 0 0
unless (exists $invocant->{"actions"}) 0 20 20
unless (exists $invocant->{"actions"}) 0 0 0
unless (exists $invocant->{"actions"}) 20 0 20
unless (exists $invocant->{"actions"}) 0 20 20
if (() = each %data) 0 0 0
unless (exists $_[0]{"base_path"}) 0 0 0
eval { do { local $_ = $_[1]; ref $constraint ? &$constraint($constraint, $_[1]) : $_[0]->$constraint($_[1]) } } or "GX::Meta::Exception"->complain($@ || "Invalid value for attribute \"base_path\"") 20 0 20
ref $constraint ? : 0 20 20
unless (exists $_[0]{"default_format"}) 0 0 0
unless (exists $invocant->{"filter_hooks"}) 0 0 0
unless (exists $invocant->{"filter_hooks"}) 20 0 20
unless (exists $invocant->{"filter_hooks"}) 0 20 20
if (() = each %data) 0 0 0
unless (exists $_[0]{"name"}) 0 0 0
unless (exists $invocant->{"post_dispatch_filter_hooks"}) 20 0 20
unless (exists $invocant->{"pre_dispatch_filter_hooks"}) 0 20 20
unless (exists $invocant->{"renderers"}) 0 0 0
unless (exists $invocant->{"renderers"}) 0 0 0
unless (exists $invocant->{"renderers"}) 0 7 7
if (() = each %data) 3 4 7
Condition36%46/126
$@ || 'Invalid value for attribute "arguments"'
l!l
12280
$@ || 'Invalid value for attribute "code"'
l!l
09
$@ || 'Invalid value for attribute "arguments"'
l!l
0220
$@ || 'Invalid value for attribute "controller"'
l!l
040
$@ || 'Invalid value for attribute "controller"'
l!l
00
$@ || 'Invalid value for attribute "method"'
l!l
000
$@ || 'Invalid value for attribute "method"'
l!l
000
$@ || 'Invalid value for attribute "code"'
l!l
000
$@ || 'Invalid value for attribute "dispatch_code"'
l!l
00
$@ || 'Invalid value for attribute "id"'
l!l
00
$@ || 'Invalid value for attribute "name"'
l!l
210
$@ || 'Invalid value for attribute "callbacks"'
l!l
100615
$@ || 'Invalid value for attribute "arguments"'
l!l
00
$@ || 'Invalid value for attribute "invocant"'
l!l
200
$@ || 'Invalid value for attribute "method"'
l!l
000
$@ || 'Invalid value for attribute "method"'
l!l
101
$@ || 'Invalid value for attribute "code"'
l!l
11
$@ || 'Invalid value for attribute "handlers"'
l!l
112
$@ || 'Invalid value for attribute "data"'
l!l
00
$@ || 'Invalid value for attribute "action"'
l!l
223
$@ || 'Invalid value for attribute "action"'
l!l
02
$@ || 'Invalid value for attribute "constraints"'
l!l
00
$@ || 'Invalid value for attribute "constraints"'
l!l
13
$@ || 'Invalid value for attribute "defaults"'
l!l
03
$@ || 'Invalid value for attribute "host_regex"'
l!l
00
$@ || 'Invalid value for attribute "host_variables"'
l!l
00
$@ || 'Invalid value for attribute "methods"'
l!l
00
$@ || 'Invalid value for attribute "methods"'
l!l
00
$@ || 'Invalid value for attribute "methods_regex"'
l!l
41371
$@ || 'Invalid value for attribute "path_regex"'
l!l
03
$@ || 'Invalid value for attribute "path_variables"'
l!l
00
$@ || 'Invalid value for attribute "reverse_host_variables"'
l!l
00
$@ || 'Invalid value for attribute "reverse_path_variables"'
l!l
00
$@ || 'Invalid value for attribute "schemes"'
l!l
00
$@ || 'Invalid value for attribute "schemes"'
l!l
00
$@ || 'Invalid value for attribute "schemes_regex"'
l!l
12120
$@ || 'Invalid value for attribute "action"'
l!l
660
$@ || 'Invalid value for attribute "action"'
l!l
450
$@ || 'Invalid value for attribute "host"'
l!l
120
$@ || 'Invalid value for attribute "method"'
l!l
320
$@ || 'Invalid value for attribute "path"'
l!l
1190
$@ || 'Invalid value for attribute "path"'
l!l
39390
$@ || 'Invalid value for attribute "scheme"'
l!l
30360
ref $_[0] || $_[0]
l!l&&r!l&&!r
060
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
ref $invocant || $invocant
l!l&&r!l&&!r
000
ref $invocant || $invocant
l!l&&r!l&&!r
000
MC/DC100%1/1
$@ || 'Invalid value for attribute "arguments"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "code"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "arguments"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "controller"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "controller"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "method"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "method"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "code"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "dispatch_code"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "id"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "name"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "callbacks"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "arguments"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "invocant"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "method"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "method"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "code"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "handlers"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "data"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "action"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "action"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "constraints"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "constraints"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "defaults"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "host_regex"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "host_variables"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "methods"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "methods"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "methods_regex"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "path_regex"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "path_variables"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "reverse_host_variables"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "reverse_path_variables"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "schemes"'
$@
MC/DC0%0/1
$@ || 'Invalid value for attribute "schemes"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "schemes_regex"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "action"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "action"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "host"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "method"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "path"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "path"'
$@
MC/DC100%1/1
$@ || 'Invalid value for attribute "scheme"'
$@
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
MC/DC0%0/2
ref $invocant || $invocant
ref $invocant $invocant
MC/DC0%0/2
ref $invocant || $invocant
ref $invocant $invocant
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table50%1/2
A
A= $@
Aresult
11
00
Truth table50%1/2
A
A= $@
Aresult
11
00
Truth table50%1/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table50%1/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table50%1/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table50%1/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table50%1/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table100%2/2
A
A= $@
Aresult
11
00
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= ref $invocantB= $invocant
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= ref $invocantB= $invocant
ABresult
1X1
011
000
57  
58 6574 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 75 6555 6630
59 176 die $@ . "\nCode:\n$code\n";
60 }
61  
62 6700 return $result;
63  
64 }
65  
66 199 ▶sub file_to_module_name {
Subroutine file_to_module_name: called CC=3 SCAR=11.0
Pod documented
67  
68 200 my $file = shift;
69  
70 258 ▶ if ( ! defined $file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 512 1830 2342
71 146 complain "Missing argument";
72 }
73  
74 659 my @path = File::Spec->splitpath( File::Spec->canonpath( $file ) );
75  
76 595 $path[2] =~ s/\.pm$//;
77  
78 470 my $module = join(
79 '::',
80 File::Spec->splitdir( File::Spec->canonpath( $path[1] ) ),
81 $path[2]
82 );
83  
84 491 ▶ if ( $module !~ REGEX_MODULE_NAME ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/) 380 193 573
85 139 complain "Invalid argument (\"$file\" is not a valid module filename)";
86 }
87  
88 108 return $module;
89  
90 }
91  
92 414 ▶sub find_module_file {
Subroutine find_module_file: called CC=6 SCAR=17.9
Pod documented
93  
94 46 my $module = shift;
95  
96 203 my $key = eval { module_inc_key( $module ) };
97  
98 343 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 130 375 505
99 436 complain $@;
100 }
101  
102 102 for ( @INC ) {
103  
104 354 ▶ next if ! defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 12 126 138
105 122 ▶ next if ref $_;
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ 104 22 126
106  
107 93 my $path = "$_/$key";
108  
109 97 ▶ next unless -f $path;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $path 353 110 463
110  
111 5 return $path if UNIX_PATHS;
112  
113 0 my ( $volume, $directory, $filename ) = File::Spec::Unix->splitpath( $path );
114 4 $directory = File::Spec->catdir( File::Spec->splitdir( $directory ) );
115  
116 99 return File::Spec->catpath( $volume, $directory, $filename );
117  
118 }
119  
120 62 return undef;
121  
122 }
123  
124 95 ▶sub find_modules {
Subroutine find_modules: called CC=3 SCAR=11.0
Pod documented
125  
126 157 my $search_path = shift;
127 138 my $base_path = shift;
128  
129 145 ▶ return unless -d $search_path;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $search_path 179 336 515
130  
131 178 ▶ if ( ! defined $base_path ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $base_path) 8 179 187
132 212 $base_path = $search_path;
133 }
134  
135 135 my @files;
136  
137 File::Find::find(
138 {
139 120 ▶ 'wanted' => sub { push @files, $_ if /\.pm$/ },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if /\.pm$/ 80 7 87
140 175 'no_chdir' => 1
141 },
142 $search_path
143 );
144  
145 118 my @module_files = grep { defined } map {
146 73 local $@;
147 80 eval { file_to_module_name( File::Spec->abs2rel( $_, $base_path ) ) };
148 } @files;
149  
150 53 return @module_files;
151  
152 }
153  
154 4059 ▶sub load_module {
Subroutine load_module: called CC=7 SCAR=19.5
Pod documented
155  
156 4117 my $module = shift;
157  
158 4088 ▶ if ( ! defined( $module ) || $module !~ REGEX_MODULE_NAME ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/) 76 4177 4253
Condition100%3/3
defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
!ll&&!rl&&r
24124009
MC/DC0%0/2
defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
defined $module $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
Truth table33%1/3
A and B
A= defined $moduleB= $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
ABresult
0X0
100
111
159 50 complain "Invalid module name";
160 }
161  
162 4100 my ( $died, $error );
163  
164 {
165  
166 4044 local $@;
167  
168 4031 ▶ eval "require $module; 1;" or do {
Branch: 1 branch
BranchTrueFalseTotal
eval "require $module; 1;" or do { $died = 1; $error = $@ } 4076 122 4198
169 17 $died = 1;
170 31 $error = $@;
171 };
172  
173 }
174  
175 4031 ▶ if ( $died ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($died) 57 4087 4144
176  
177 26 ▶ if ( defined wantarray ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) 68 99 167
178 24 my $module_file = join( '/', split( '::', $module ) ) . '.pm';
179 25 ▶ return 0 if $error =~ /^Can't locate $module_file in \@INC /;
Branch: 1 branch
BranchTrueFalseTotal
if $error =~ /^Can't locate $module_file in \@INC / 60 48 108
180 }
181  
182 11 complain $error;
183  
184 }
185  
186 4033 return 1;
187  
188 }
189  
190 85 ▶sub module_inc_file {
Subroutine module_inc_file: called CC=3 SCAR=11.0
Pod documented
191  
192 28 my $module = shift;
193  
194 11 my $value = eval { module_inc_value( $module ) };
195  
196 23 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 28 27 55
197 11 complain $@;
198 }
199  
200 24 ▶ return ref( $value ) ? undef : $value;
Branch: 1 branch
BranchTrueFalseTotal
ref $value ? : 21 8 29
201  
202 }
203  
204 83 ▶sub module_inc_key {
Subroutine module_inc_key: called CC=3 SCAR=11.3
Pod documented
205  
206 36 my $module = shift;
207  
208 31 ▶ if ( ! defined( $module ) || $module !~ REGEX_MODULE_NAME ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/) 13 29 42
Condition33%1/3
defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
!ll&&!rl&&r
0015
MC/DC0%0/2
defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
defined $module $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
Truth table33%1/3
A and B
A= defined $moduleB= $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
ABresult
0X0
100
111
209 27 complain "Invalid module name";
210 }
211  
212 36 return join( '/', split( /::/, $module ) ) . '.pm'
213  
214 }
215  
216 85 ▶sub module_inc_value {
Subroutine module_inc_value: called CC=3 SCAR=11.0
Pod documented
217  
218 13 my $module = shift;
219  
220 26 my $key = eval { module_inc_key( $module ) };
221  
222 13 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 28 8 36
223 21 complain $@;
224 }
225  
226 32 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 12 24 36
227 16 $INC{$key} = $_[0];
228 }
229  
230 24 return $INC{$key};
231  
232 }
233  
234 43 ▶sub module_is_installed {
Subroutine module_is_installed: called CC=6 SCAR=17.9
Pod documented
235  
236 22 my $module = shift;
237  
238 10 my $key = eval { module_inc_key( $module ) };
239  
240 11 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 22 6 28
241 10 complain $@;
242 }
243  
244 11 for ( @INC ) {
245 27 ▶ next if ! defined( $_ ) || ref( $_ );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $_ or ref $_ 19 21 40
Condition100%3/3
not defined $_ or ref $_
l!l&&r!l&&!r
141918
MC/DC100%2/2
not defined $_ or ref $_
not defined $_ ref $_
Truth table100%3/3
not(A) or B
A= not defined $_B= ref $_
ABresult
1X1
011
000
246 111 ▶ return 1 if -f "$_/$key";
Branch: 1 branch
BranchTrueFalseTotal
if -f "$_/$key" 29 17 46
247 }
248  
249 53 return 0;
250  
251 }
252  
253 43 ▶sub module_is_loaded {
Subroutine module_is_loaded: called CC=3 SCAR=11.0
Pod documented
254  
255 61 my $module = shift;
256  
257 33 my $key = eval { module_inc_key( $module ) };
258  
259 21 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 9 21 30
260 56 complain $@;
261 }
262  
263 49 ▶ return exists( $INC{$key} ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $INC{$key} ? : 23 1 24
264  
265 }
266  
267 126 ▶sub module_to_file_name {
Subroutine module_to_file_name: called CC=3 SCAR=12.0
Pod documented
268  
269 38 my $module = shift;
270  
271 36 ▶ if ( ! defined( $module ) || $module !~ REGEX_MODULE_NAME ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/) 9 13 22
Condition0%0/3
defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
defined $module $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
Truth table0%0/3
A and B
A= defined $moduleB= $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
ABresult
0X0
100
111
272 25 complain "Invalid module name";
273 }
274  
275 34 return File::Spec->catfile( split( /::/, $module ) ) . '.pm';
276  
277 }
278  
279 12659 ▶sub subpackage_names {
Subroutine subpackage_names: called CC=4 SCAR=14.1
Pod documented
280  
281 12674 my $package = shift;
282  
283 12657 ▶ if ( ! defined( $package ) || $package !~ REGEX_PACKAGE_NAME ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $package and $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/) 28 12640 12668
Condition33%1/3
defined $package and $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
!ll&&!rl&&r
0012640
MC/DC0%0/2
defined $package and $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
defined $package $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
Truth table33%1/3
A and B
A= defined $packageB= $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
ABresult
0X0
100
111
284 31 complain "Invalid package name";
285 }
286  
287 370 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
288  
289 12671 ▶ return grep { substr( $_, -2, 2, '' ) eq '::' && $_ =~ REGEX_IDENTIFIER } keys %{"${package}::"};
Condition66%2/3
substr($_, -2, 2, '') eq '::' && $_ =~ /^[a-zA-Z_]\w*$/
!ll&&!rl&&r
260876012640
MC/DC50%1/2
substr($_, -2, 2, '') eq '::' && $_ =~ /^[a-zA-Z_]\w*$/
substr($_, -2, 2, '') eq '::' $_ =~ /^[a-zA-Z_]\w*$/
Truth table66%2/3
A && B
A= substr($_, -2, 2, '') eq '::'B= $_ =~ /^[a-zA-Z_]\w*$/
ABresult
0X0
100
111
290  
291 }
292  
293 39 ▶sub unload_module {
Subroutine unload_module: called CC=3 SCAR=11.6
Pod documented
294  
295 39 my $module = shift;
296  
297 53 ▶ if ( ! defined( $module ) || $module !~ REGEX_MODULE_NAME ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/) 9 19 28
Condition0%0/3
defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $module and $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
defined $module $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
Truth table0%0/3
A and B
A= defined $moduleB= $module =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
ABresult
0X0
100
111
298 163 complain "Invalid module name";
299 }
300  
301 162 wipe_package( $module );
302  
303 52 delete $INC{ module_inc_key( $module ) };
304  
305 97 return;
306  
307 }
308  
309 25 ▶sub wipe_package {
Subroutine wipe_package: called CC=10 SCAR=23.0
Pod documented
310  
311 83 my $package = shift;
312  
313 42 ▶ if ( ! defined( $package ) || $package !~ REGEX_PACKAGE_NAME ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $package and $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/) 22 2 24
Condition66%2/3
defined $package and $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
!ll&&!rl&&r
012
MC/DC0%0/2
defined $package and $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
defined $package $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
Truth table33%1/3
A and B
A= defined $packageB= $package =~ /^[a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*$/
ABresult
0X0
100
111
314 23 complain "Invalid package name";
315 }
316  
317 # NOTE: Symbol::delete_package() DOES NOT work!
318  
319 389 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
320  
321 27 my $symbol_table = \%{"${package}::"};
322  
323 15 for my $symbol_name ( keys %$symbol_table ) {
324  
325 # Skip sub-packages
326 73 ▶ next if substr( $symbol_name, -2 ) eq '::';
Branch: 1 branch
BranchTrueFalseTotal
if substr($symbol_name, -2) eq "::" 10 37 47
327  
328 68 my $full_name = "${package}::${symbol_name}";
329  
330 55 ▶ if ( *{$full_name}{'SCALAR'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (*{$full_name;}{"SCALAR"}) 38 1 39
331 46 my $scalar;
332 46 *{$full_name} = \$scalar;
333 32 undef $$full_name;
334 }
335  
336 40 ▶ if ( *{$full_name}{'ARRAY'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (*{$full_name;}{"ARRAY"}) 15 25 40
337 21 *{$full_name} = [];
338 22 undef @$full_name;
339 }
340  
341 54 ▶ if ( *{$full_name}{'HASH'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (*{$full_name;}{"HASH"}) 73 88 161
342 18 *{$full_name} = {};
343 121 undef %$full_name;
344 }
345  
346 71 ▶ if ( *{$full_name}{'CODE'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (*{$full_name;}{"CODE"}) 37 86 123
347  
348 368 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
349  
350 24 ▶ if ( defined( my $prototype = prototype $full_name ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $prototype = prototype $full_name)) { } 54 4 58
351  
352 107 ▶ local $SIG{__WARN__} = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
353 248 ▶ return if $_[0] =~ /^Constant subroutine [\w:]+ redefined at/;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /^Constant subroutine [\w:]+ redefined at/ 18 32 50
354 180 return CORE::warn( @_ );
355 107 };
356  
357 56 *{$full_name} = eval "sub ($prototype) {}";
358  
359 }
360 else {
361 26 ▶ *{$full_name} = sub {};
Subroutine __ANON__: called CC=1 SCAR=0.0
362 }
363  
364 22 undef &$full_name;
365  
366 }
367  
368 186 delete $symbol_table->{$symbol_name};
369  
370 }
371  
372 32 return;
373  
374 }
375  
376  
377 432 1;
378  
379 __END__
« GX/Route/Dynamic.pm ↑ Summary GX/Component.pm »