| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
3
|
|
|
3
|
|
48530
|
use 5.006; #6 = pragmas, our, 5 = qr, 4 = __PACAKGE__,for my |
|
|
3
|
|
|
|
|
9
|
|
|
2
|
3
|
|
|
3
|
|
12
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
60
|
|
|
3
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
209
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Package::Strictures; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.000001'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Facilitate toggling validation code at users request, without extra performance penalties. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
|
12
|
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
1121
|
use Package::Strictures::Registry; |
|
|
3
|
|
|
|
|
21
|
|
|
|
3
|
|
|
|
|
74
|
|
|
14
|
3
|
|
|
3
|
|
14
|
use Carp (); |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
1514
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub import { |
|
71
|
2
|
|
|
2
|
|
24
|
my ( $self, %params ) = @_; |
|
72
|
2
|
50
|
|
|
|
15
|
if ( not %params ) { |
|
73
|
0
|
|
|
|
|
0
|
Carp::carp( __PACKAGE__ . ' called with no parameters, skipping magic' ); |
|
74
|
0
|
|
|
|
|
0
|
return; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
2
|
50
|
66
|
|
|
11
|
if ( ( not exists $params{-for} ) && ( not exists $params{-from} ) ) { |
|
77
|
0
|
|
|
|
|
0
|
Carp::croak( 'no -for or -from parameter to ' . __PACKAGE__ ); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
2
|
100
|
|
|
|
8
|
if ( exists $params{-for} ) { |
|
80
|
1
|
|
|
|
|
4
|
$self->_setup_for( $params{-for} ); |
|
81
|
1
|
|
|
|
|
41
|
return; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
1
|
50
|
|
|
|
3
|
if ( exists $params{-from} ) { |
|
84
|
1
|
|
|
|
|
3
|
$self->_setup_from( $params{-from} ); |
|
85
|
1
|
|
|
|
|
121
|
return; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
|
|
|
|
0
|
Carp::croak('Ugh!?'); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _setup_for { |
|
91
|
2
|
|
|
2
|
|
4
|
my ( $self, $params ) = @_; |
|
92
|
2
|
|
|
|
|
6
|
my $reftype = ref $params; |
|
93
|
2
|
50
|
|
|
|
8
|
if ( $reftype ne 'HASH' ) { |
|
94
|
0
|
|
|
|
|
0
|
Carp::croak("-for presently only takes HASH, got `$reftype`"); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
2
|
|
|
|
|
3
|
for my $package ( keys %{$params} ) { |
|
|
2
|
|
|
|
|
10
|
|
|
97
|
2
|
|
|
|
|
7
|
$self->_setup_for_package( $params->{$package}, $package ); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
2
|
|
|
|
|
3
|
return; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _setup_from { |
|
103
|
1
|
|
|
1
|
|
3
|
my ( $self, $from ) = @_; |
|
104
|
1
|
|
|
|
|
1
|
my $reftype = ref $from; |
|
105
|
1
|
50
|
|
|
|
3
|
if ($reftype) { |
|
106
|
0
|
|
|
|
|
0
|
Carp::croak("-from can only take a scalar, not a ref, got `$reftype`"); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
## no critic (RegularExpressions::RequireDotMatchAnything RegularExpressions::RequireLineBoundaryMatching) |
|
109
|
1
|
50
|
|
|
|
5
|
if ( $from =~ /[.]ini$/x ) { |
|
110
|
1
|
|
|
|
|
2
|
$self->_setup_from_ini($from); |
|
111
|
1
|
|
|
|
|
2
|
return; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
0
|
|
|
|
|
0
|
Carp::croak('Only know how to load setup from .ini files at present'); |
|
114
|
0
|
|
|
|
|
0
|
return; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _setup_from_ini { |
|
118
|
1
|
|
|
1
|
|
1
|
my ( $self, $from ) = @_; |
|
119
|
1
|
|
|
|
|
419
|
require Config::INI::Reader; |
|
120
|
1
|
|
|
|
|
36369
|
my ($conf) = Config::INI::Reader->read_file($from); |
|
121
|
1
|
50
|
|
|
|
394
|
if ( exists $conf->{'_'} ) { |
|
122
|
0
|
|
|
|
|
0
|
Carp::carp("Strictures not addressed at a package found in `$from`"); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
1
|
|
|
|
|
6
|
$self->_setup_for($conf); |
|
125
|
1
|
|
|
|
|
3
|
return; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _setup_for_package { |
|
129
|
2
|
|
|
2
|
|
6
|
my ( undef, $params, $package ) = @_; |
|
130
|
2
|
|
|
|
|
3
|
my $reftype = ref $params; |
|
131
|
2
|
50
|
|
|
|
6
|
if ( $reftype ne 'HASH' ) { |
|
132
|
0
|
|
|
|
|
0
|
my $mesg = q[]; |
|
133
|
0
|
|
|
|
|
0
|
$mesg .= q[-for => { Some::Name => X } presently only takes HASH,]; |
|
134
|
0
|
|
|
|
|
0
|
$mesg .= q[got `%s` on package `%s` ]; |
|
135
|
0
|
|
|
|
|
0
|
Carp::croak( sprintf $mesg, $reftype, $package ); |
|
136
|
|
|
|
|
|
|
} |
|
137
|
2
|
|
|
|
|
2
|
for my $value ( keys %{$params} ) { |
|
|
2
|
|
|
|
|
6
|
|
|
138
|
2
|
|
|
|
|
11
|
Package::Strictures::Registry->set_value( $package, $value, $params->{$value} ); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
2
|
|
|
|
|
4
|
return; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |