line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::perlimports::Config; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
1044
|
use Moo; |
|
4
|
|
|
|
|
8922
|
|
|
4
|
|
|
|
|
21
|
|
4
|
4
|
|
|
4
|
|
4415
|
use MooX::StrictConstructor; |
|
4
|
|
|
|
|
57814
|
|
|
4
|
|
|
|
|
18
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.000052'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
103199
|
use List::Util qw( uniq ); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
506
|
|
9
|
4
|
|
|
4
|
|
3846
|
use Path::Tiny qw( path ); |
|
4
|
|
|
|
|
62635
|
|
|
4
|
|
|
|
|
274
|
|
10
|
4
|
|
|
4
|
|
2619
|
use Types::Standard qw( ArrayRef Bool InstanceOf Str ); |
|
4
|
|
|
|
|
435221
|
|
|
4
|
|
|
|
|
44
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has cache => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
isa => Bool, |
15
|
|
|
|
|
|
|
lazy => 1, |
16
|
|
|
|
|
|
|
default => 0, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has _ignore_modules => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => ArrayRef, |
22
|
|
|
|
|
|
|
init_arg => 'ignore_modules', |
23
|
|
|
|
|
|
|
lazy => 1, |
24
|
|
|
|
|
|
|
default => sub { [] }, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has _ignore_modules_filename => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => Str, |
30
|
|
|
|
|
|
|
init_arg => 'ignore_modules_filename', |
31
|
|
|
|
|
|
|
predicate => '_has_ignore_modules_filename', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has _ignore_modules_pattern => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => ArrayRef [Str], |
37
|
|
|
|
|
|
|
init_arg => 'ignore_modules_pattern', |
38
|
|
|
|
|
|
|
lazy => 1, |
39
|
|
|
|
|
|
|
predicate => '_has_ignore_modules_pattern', |
40
|
|
|
|
|
|
|
coerce => sub { return ref $_[0] ? $_[0] : [ $_[0] ] }, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has _ignore_modules_pattern_filename => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
isa => Str, |
46
|
|
|
|
|
|
|
init_arg => 'ignore_modules_pattern_filename', |
47
|
|
|
|
|
|
|
predicate => '_has_ignore_modules_pattern_filename', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has ignore => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
isa => ArrayRef, |
53
|
|
|
|
|
|
|
lazy => 1, |
54
|
|
|
|
|
|
|
builder => '_build_ignore', |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has ignore_pattern => ( |
58
|
|
|
|
|
|
|
is => 'ro', |
59
|
|
|
|
|
|
|
isa => ArrayRef, |
60
|
|
|
|
|
|
|
lazy => 1, |
61
|
|
|
|
|
|
|
builder => '_build_ignore_pattern', |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has libs => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
isa => ArrayRef, |
67
|
|
|
|
|
|
|
lazy => 1, |
68
|
|
|
|
|
|
|
default => sub { [] }, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has log_filename => ( |
72
|
|
|
|
|
|
|
is => 'ro', |
73
|
|
|
|
|
|
|
isa => Str, |
74
|
|
|
|
|
|
|
lazy => 1, |
75
|
|
|
|
|
|
|
default => sub { q{} }, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has log_level => ( |
79
|
|
|
|
|
|
|
is => 'ro', |
80
|
|
|
|
|
|
|
isa => Str, |
81
|
|
|
|
|
|
|
lazy => 1, |
82
|
|
|
|
|
|
|
default => sub { 'error' }, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has _never_export_modules => ( |
86
|
|
|
|
|
|
|
is => 'ro', |
87
|
|
|
|
|
|
|
isa => ArrayRef, |
88
|
|
|
|
|
|
|
init_arg => 'never_export_modules', |
89
|
|
|
|
|
|
|
lazy => 1, |
90
|
|
|
|
|
|
|
default => sub { [] }, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
has _never_export_modules_filename => ( |
94
|
|
|
|
|
|
|
is => 'ro', |
95
|
|
|
|
|
|
|
isa => Str, |
96
|
|
|
|
|
|
|
init_arg => 'never_export_modules_filename', |
97
|
|
|
|
|
|
|
predicate => '_has_never_export_modules_filename', |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
has never_export => ( |
101
|
|
|
|
|
|
|
is => 'ro', |
102
|
|
|
|
|
|
|
isa => ArrayRef, |
103
|
|
|
|
|
|
|
lazy => 1, |
104
|
|
|
|
|
|
|
builder => '_build_never_export', |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has padding => ( |
108
|
|
|
|
|
|
|
is => 'ro', |
109
|
|
|
|
|
|
|
isa => Bool, |
110
|
|
|
|
|
|
|
lazy => 1, |
111
|
|
|
|
|
|
|
default => 1, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
has preserve_duplicates => ( |
115
|
|
|
|
|
|
|
is => 'ro', |
116
|
|
|
|
|
|
|
isa => Bool, |
117
|
|
|
|
|
|
|
lazy => 1, |
118
|
|
|
|
|
|
|
default => 1, |
119
|
|
|
|
|
|
|
); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
has preserve_unused => ( |
122
|
|
|
|
|
|
|
is => 'ro', |
123
|
|
|
|
|
|
|
isa => Bool, |
124
|
|
|
|
|
|
|
lazy => 1, |
125
|
|
|
|
|
|
|
default => 1, |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
has tidy_whitespace => ( |
129
|
|
|
|
|
|
|
is => 'ro', |
130
|
|
|
|
|
|
|
isa => Bool, |
131
|
|
|
|
|
|
|
lazy => 1, |
132
|
|
|
|
|
|
|
default => 1, |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
with 'App::perlimports::Role::Logger'; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub _build_ignore { |
138
|
2
|
|
|
2
|
|
13719
|
my $self = shift; |
139
|
2
|
|
|
|
|
40
|
return $self->_aggregate( |
140
|
|
|
|
|
|
|
$self->_ignore_modules, |
141
|
|
|
|
|
|
|
'_ignore_modules_filename' |
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub _build_ignore_pattern { |
146
|
2
|
|
|
2
|
|
998
|
my $self = shift; |
147
|
2
|
|
|
|
|
13
|
return $self->_aggregate( |
148
|
|
|
|
|
|
|
$self->_ignore_modules_pattern, |
149
|
|
|
|
|
|
|
'_ignore_modules_pattern_filename' |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _build_never_export { |
154
|
2
|
|
|
2
|
|
906
|
my $self = shift; |
155
|
2
|
|
|
|
|
39
|
return $self->_aggregate( |
156
|
|
|
|
|
|
|
$self->_never_export_modules, |
157
|
|
|
|
|
|
|
'_never_export_modules_filename' |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub _aggregate { |
162
|
6
|
|
|
6
|
|
107
|
my $self = shift; |
163
|
6
|
|
100
|
|
|
23
|
my $list = shift || []; |
164
|
6
|
|
|
|
|
26
|
my $accessor = shift; |
165
|
|
|
|
|
|
|
|
166
|
6
|
|
|
|
|
23
|
my $predicate = '_has' . $accessor; |
167
|
|
|
|
|
|
|
|
168
|
6
|
100
|
|
|
|
94
|
return $list if !$self->$predicate; |
169
|
|
|
|
|
|
|
|
170
|
3
|
|
|
|
|
13
|
my $filename = $self->$accessor; |
171
|
3
|
50
|
|
|
|
58
|
return $list if !$filename; # could be an empty string |
172
|
|
|
|
|
|
|
|
173
|
0
|
0
|
|
|
|
0
|
die "File $filename not found" unless -e $filename; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
0
|
return [ uniq( @{$list}, path($filename)->lines( { chomp => 1 } ) ) ]; |
|
0
|
|
|
|
|
0
|
|
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub create_config { |
179
|
2
|
|
|
2
|
1
|
33440
|
shift; # $class |
180
|
2
|
|
|
|
|
5
|
my $filename = shift; |
181
|
|
|
|
|
|
|
|
182
|
2
|
100
|
|
|
|
11
|
if ( -e $filename ) { |
183
|
1
|
|
|
|
|
29
|
die "$filename already exists"; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
1
|
|
|
|
|
60
|
my @toml = <DATA>; |
187
|
1
|
|
|
|
|
10
|
path($filename)->spew(@toml); |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# ABSTRACT: Generic configuration options for C<perlimports> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=pod |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=encoding UTF-8 |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 NAME |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
App::perlimports::Config - Generic configuration options for C<perlimports> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 VERSION |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
version 0.000052 |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 DESCRIPTION |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This module isn't really meant to provide a public interface. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 create_config( $filename ) |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This class method creates a L<perlimports> config file at the provided |
213
|
|
|
|
|
|
|
filename. Dies if the file already exists. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 AUTHOR |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Olaf Alders <olaf@wundercounter.com> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Olaf Alders. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
224
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
__DATA__ |
229
|
|
|
|
|
|
|
# Valid log levels are: |
230
|
|
|
|
|
|
|
# debug, info, notice, warning, error, critical, alert, emergency |
231
|
|
|
|
|
|
|
# critical, alert and emergency are not currently used. |
232
|
|
|
|
|
|
|
# |
233
|
|
|
|
|
|
|
# Please use boolean values in this config file. Negated options (--no-*) are |
234
|
|
|
|
|
|
|
# not permitted here. Explicitly set options to true or false. |
235
|
|
|
|
|
|
|
# |
236
|
|
|
|
|
|
|
# Some of these values deviate from the regular perlimports defaults. In |
237
|
|
|
|
|
|
|
# particular, you're encouraged to leave preserve_duplicates and |
238
|
|
|
|
|
|
|
# preserve_unused disabled. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
cache = false # setting this to true is currently discouraged |
241
|
|
|
|
|
|
|
ignore_modules = [] |
242
|
|
|
|
|
|
|
ignore_modules_filename = "" |
243
|
|
|
|
|
|
|
ignore_modules_pattern = "" # regex like "^(Foo|Foo::Bar)" |
244
|
|
|
|
|
|
|
ignore_modules_pattern_filename = "" |
245
|
|
|
|
|
|
|
libs = ["lib", "t/lib"] |
246
|
|
|
|
|
|
|
log_filename = "" |
247
|
|
|
|
|
|
|
log_level = "warn" |
248
|
|
|
|
|
|
|
never_export_modules = [] |
249
|
|
|
|
|
|
|
never_export_modules_filename = "" |
250
|
|
|
|
|
|
|
padding = true |
251
|
|
|
|
|
|
|
preserve_duplicates = false |
252
|
|
|
|
|
|
|
preserve_unused = false |
253
|
|
|
|
|
|
|
tidy_whitespace = true |