blib/lib/ExtUtils/MakeMaker/Attributes.pm

filter: Statementstmt 87.5% 49 / 56 Branchbran 57.1% 8 / 14 Conditioncond 46.6% 7 / 15 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 87.5% 14 / 16 Podpod 100% 8 / 8 totaltotal 76.0% 89 / 117 CC 16 SCAR 19.7
CC
16
Cov
75%
eumm_version_supports_attribute
30.0
eumm_version_supported_attributes
5.0
_eumm_version_for_perl
4.7
CRAP 7.2
↑ Summary
1 package ExtUtils::MakeMaker::Attributes;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Module::CoreList;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '0.001';
11  
12 1 my @exports = qw(
13 known_eumm_attributes is_known_eumm_attribute
14 eumm_attribute_requires_version eumm_attribute_fallback
15 eumm_version_supported_attributes eumm_version_supports_attribute
16 perl_version_supported_attributes perl_version_supports_attribute
17 );
18 1 our @EXPORT_OK = @exports;
19 1 our %EXPORT_TAGS = (all => \@exports);
20  
21 1 my %attributes = (
22 ABSTRACT => {},
23 ABSTRACT_FROM => {},
24 AUTHOR => {},
25 BINARY_LOCATION => {},
26 BUILD_REQUIRES => {
27 requires => '6.55_03',
28 fallback => {method => 'merge_prereqs', merge_target => 'PREREQ_PM'},
29 },
30 C => {},
31 CCFLAGS => {},
32 CONFIG => {},
33 CONFIGURE => {},
34 CONFIGURE_REQUIRES => {requires => '6.52'},
35 DEFINE => {},
36 DESTDIR => {},
37 DIR => {},
38 DISTNAME => {},
39 DISTVNAME => {},
40 DLEXT => {},
41 DL_FUNCS => {},
42 DL_VARS => {},
43 EXCLUDE_EXT => {},
44 EXE_FILES => {},
45 FIRST_MAKEFILE => {},
46 FULLPERL => {},
47 FULLPERLRUN => {},
48 FULLPERLRUNINST => {},
49 FUNCLIST => {},
50 H => {},
51 IMPORTS => {},
52 INC => {},
53 INCLUDE_EXT => {},
54 INSTALLARCHLIB => {},
55 INSTALLBIN => {},
56 INSTALLDIRS => {},
57 INSTALLMAN1DIR => {},
58 INSTALLMAN3DIR => {},
59 INSTALLPRIVLIB => {},
60 INSTALLSCRIPT => {},
61 INSTALLSITEARCH => {},
62 INSTALLSITEBIN => {},
63 INSTALLSITELIB => {},
64 INSTALLSITEMAN1DIR => {},
65 INSTALLSITEMAN3DIR => {},
66 INSTALLSITESCRIPT => {requires => '6.30_02'},
67 INSTALLVENDORARCH => {},
68 INSTALLVENDORBIN => {},
69 INSTALLVENDORLIB => {},
70 INSTALLVENDORMAN1DIR => {},
71 INSTALLVENDORMAN3DIR => {},
72 INSTALLVENDORSCRIPT => {requires => '6.30_02'},
73 INST_ARCHLIB => {},
74 INST_BIN => {},
75 INST_LIB => {},
76 INST_MAN1DIR => {},
77 INST_MAN3DIR => {},
78 INST_SCRIPT => {},
79 LD => {},
80 LDDLFLAGS => {},
81 LDFROM => {},
82 LIB => {},
83 LIBPERL_A => {},
84 LIBS => {},
85 LICENSE => {requires => '6.31'},
86 LINKTYPE => {},
87 MAGICXS => {requires => '6.8305'},
88 MAKE => {requires => '6.30_01'},
89 MAKEAPERL => {},
90 MAKEFILE_OLD => {},
91 MAN1PODS => {},
92 MAN3PODS => {},
93 MAP_TARGET => {},
94 META_ADD => {requires => '6.46'},
95 META_MERGE => {requires => '6.46'},
96 MIN_PERL_VERSION => {requires => '6.48'},
97 MYEXTLIB => {},
98 NAME => {},
99 NEEDS_LINKING => {},
100 NOECHO => {},
101 NORECURS => {},
102 NO_META => {},
103 NO_MYMETA => {requires => '6.57_02'},
104 NO_PACKLIST => {requires => '6.7501'},
105 NO_PERLLOCAL => {requires => '6.7501'},
106 NO_VC => {},
107 OBJECT => {},
108 OPTIMIZE => {},
109 PERL => {},
110 PERL_CORE => {},
111 PERLMAINCC => {},
112 PERL_ARCHLIB => {},
113 PERL_LIB => {},
114 PERL_MALLOC_OK => {},
115 PERLPREFIX => {},
116 PERLRUN => {},
117 PERLRUNINST => {},
118 PERL_SRC => {},
119 PERM_DIR => {requires => '6.51_01'},
120 PERM_RW => {},
121 PERM_RWX => {},
122 PL_FILES => {},
123 PM => {},
124 PMLIBDIRS => {},
125 PM_FILTER => {},
126 POLLUTE => {},
127 PPM_INSTALL_EXEC => {},
128 PPM_INSTALL_SCRIPT => {},
129 PPM_UNINSTALL_EXEC => {requires => '6.8502'},
130 PPM_UNINSTALL_SCRIPT => {requires => '6.8502'},
131 PREFIX => {},
132 PREREQ_FATAL => {},
133 PREREQ_PM => {},
134 PREREQ_PRINT => {},
135 PRINT_PREREQ => {},
136 SITEPREFIX => {},
137 SIGN => {requires => '6.18'},
138 SKIP => {},
139 TEST_REQUIRES => {
140 requires => '6.64',
141 fallback => {method => 'merge_prereqs', merge_target => 'PREREQ_PM'},
142 },
143 TYPEMAPS => {},
144 VENDORPREFIX => {},
145 VERBINST => {},
146 VERSION => {},
147 VERSION_FROM => {},
148 VERSION_SYM => {},
149 XS => {},
150 XSBUILD => {requires => '7.12'},
151 XSMULTI => {requires => '7.12'},
152 XSOPT => {},
153 XSPROTOARG => {},
154 XS_VERSION => {},
155 clean => {},
156 depend => {},
157 dist => {},
158 dynamic_lib => {},
159 linkext => {},
160 macro => {},
161 postamble => {},
162 realclean => {},
163 test => {},
164 tool_autosplit => {},
165 );
166  
167 3 ▶sub known_eumm_attributes {
Subroutine known_eumm_attributes: called CC=1 SCAR=0.0
Pod documented
168 1 ▶ no locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
169 3 return sort keys %attributes;
170 }
171  
172 280 ▶sub is_known_eumm_attribute {
Subroutine is_known_eumm_attribute: called CC=2 SCAR=7.1
Pod documented
173 280 my ($attribute) = @_;
174 280 ▶ return !!(defined $attribute && exists $attributes{$attribute});
Condition66%2/3
defined $attribute && exists $attributes{$attribute}
!ll&&!rl&&r
01279
MC/DC50%1/2
defined $attribute && exists $attributes{$attribute}
defined $attribute exists $attributes{$attribute}
Truth table66%2/3
A && B
A= defined $attributeB= exists $attributes{$attribute}
ABresult
0X0
100
111
175 }
176  
177 276 ▶sub eumm_attribute_requires_version {
Subroutine eumm_attribute_requires_version: called CC=3 SCAR=11.1
Pod documented
178 276 my ($attribute) = @_;
179 276 ▶ croak "Unknown ExtUtils::MakeMaker attribute $attribute"
Branch: 1 branch
BranchTrueFalseTotal
unless is_known_eumm_attribute($attribute) 0 276 276
180 unless is_known_eumm_attribute($attribute);
181 276 ▶ return $attributes{$attribute}{requires} || 0;
Condition100%2/2
$attributes{$attribute}{'requires'} || 0
l!l
41235
MC/DC100%1/1
$attributes{$attribute}{'requires'} || 0
$attributes{$attribute}{'requires'}
Truth table100%2/2
A
A= $attributes{$attribute}{'requires'}
Aresult
11
00
182 }
183  
184 2 ▶sub eumm_attribute_fallback {
Subroutine eumm_attribute_fallback: called CC=3 SCAR=11.0
Pod documented
185 2 my ($attribute) = @_;
186 2 ▶ croak "Unknown ExtUtils::MakeMaker attribute $attribute"
Branch: 1 branch
BranchTrueFalseTotal
unless is_known_eumm_attribute($attribute) 0 2 2
187 unless is_known_eumm_attribute($attribute);
188 2 ▶ if (defined(my $fallback = $attributes{$attribute}{fallback})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $fallback = $attributes{$attribute}{"fallback"})) 1 1 2
189 1 return +{%$fallback};
190 }
191 1 return undef;
192 }
193  
194 0 ▶sub eumm_version_supports_attribute {
Subroutine eumm_version_supports_attribute: not called CC=5 SCAR=34.0
Pod documented
195 0 my ($attribute, $eumm_version) = @_;
196 0 ▶ return 0 unless is_known_eumm_attribute($attribute);
Branch: 1 branch
BranchTrueFalseTotal
unless is_known_eumm_attribute($attribute) 0 0 0
197 0 ▶ my $required_version = eumm_attribute_requires_version($attribute) || return 1;
Condition0%0/2
eumm_attribute_requires_version($attribute) || (return 1)
l!l
00
MC/DC0%0/1
eumm_attribute_requires_version($attribute) || (return 1)
eumm_attribute_requires_version($attribute)
Truth table0%0/2
A
A= eumm_attribute_requires_version($attribute)
Aresult
11
00
198 0 ▶ return version->parse($eumm_version || 0) >= version->parse($required_version) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
'version'->parse($eumm_version || 0) >= 'version'->parse($required_version) ? : 0 0 0
Condition0%0/2
$eumm_version || 0
l!l
00
MC/DC0%0/1
$eumm_version || 0
$eumm_version
Truth table0%0/2
A
A= $eumm_version
Aresult
11
00
199 }
200  
201 0 ▶sub perl_version_supports_attribute {
Subroutine perl_version_supports_attribute: not called CC=1 SCAR=6.9
Pod documented
202 0 my ($attribute, $perl_version) = @_;
203 0 return eumm_version_supports_attribute($attribute, _eumm_version_for_perl($perl_version));
204 }
205  
206 2 ▶sub eumm_version_supported_attributes {
Subroutine eumm_version_supported_attributes: called CC=5 SCAR=16.1
Pod documented
207 2 my ($eumm_version) = @_;
208 2 ▶ $eumm_version = version->parse($eumm_version || 0);
Condition100%2/2
$eumm_version || 0
l!l
11
MC/DC100%1/1
$eumm_version || 0
$eumm_version
Truth table100%2/2
A
A= $eumm_version
Aresult
11
00
209 2 my @supported;
210 2 foreach my $attribute (known_eumm_attributes()) {
211 274 ▶ if (my $required_version = eumm_attribute_requires_version($attribute)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $required_version = eumm_attribute_requires_version($attribute)) { } 40 234 274
212 40 ▶ push @supported, $attribute if $eumm_version >= version->parse($required_version);
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version >= "version"->parse($required_version) 11 29 40
213 } else {
214 234 push @supported, $attribute;
215 }
216 }
217 2 return @supported;
218 }
219  
220 1 ▶sub perl_version_supported_attributes {
Subroutine perl_version_supported_attributes: called CC=1 SCAR=0.0
Pod documented
221 1 return eumm_version_supported_attributes(_eumm_version_for_perl(@_));
222 }
223  
224 1 ▶sub _eumm_version_for_perl {
Subroutine _eumm_version_for_perl: called CC=3 SCAR=15.4
225 1 my ($perl_version) = @_;
226 1 ▶ my $module_versions = Module::CoreList::find_version($perl_version) || return 0;
Condition50%1/2
Module::CoreList::find_version($perl_version) || (return 0)
l!l
01
MC/DC0%0/1
Module::CoreList::find_version($perl_version) || (return 0)
Module::CoreList::find_version($perl_version)
Truth table50%1/2
A
A= Module::CoreList::find_version($perl_version)
Aresult
11
00
227 0 ▶ return $module_versions->{'ExtUtils::MakeMaker'} || 0;
Condition0%0/2
$module_versions->{'ExtUtils::MakeMaker'} || 0
l!l
00
MC/DC0%0/1
$module_versions->{'ExtUtils::MakeMaker'} || 0
$module_versions->{'ExtUtils::MakeMaker'}
Truth table0%0/2
A
A= $module_versions->{'ExtUtils::MakeMaker'}
Aresult
11
00
228 }
229  
230 1 1;
231  
232 =head1 NAME
233  
234 ExtUtils::MakeMaker::Attributes - Determine when ExtUtils::MakeMaker attributes
235 are available
236  
237 =head1 SYNOPSIS
238  
239 use ExtUtils::MakeMaker::Attributes ':all';
240
241 my @eumm_available = eumm_version_supported_attributes(ExtUtils::MakeMaker->VERSION);
242 my @core_available = perl_version_supported_attributes($]);
243
244 unless (perl_version_supports_attribute('v5.10.1', 'TEST_REQUIRES')) {
245 ...
246 }
247
248 my $fallback = eumm_attribute_fallback('TEST_REQUIRES');
249 my $required_eumm = eumm_attribute_requires_version('TEST_REQUIRES');
250 unless (eval { ExtUtils::MakeMaker->VERSION($required_eumm); 1 }) {
251 ...
252 }
253  
254 =head1 DESCRIPTION
255  
256 This module provides an API to determine what attributes are available to a
257 particular version of L<ExtUtils::MakeMaker>, and conversely, what version of
258 L<ExtUtils::MakeMaker> is required for a particular attribute. See
259 L<ExtUtils::MakeMaker/"Using Attributes and Parameters"> for more details on
260 the available attributes.
261  
262 =head1 FUNCTIONS
263  
264 All functions are exported on demand, and can be exported individually or via
265 the C<:all> tag.
266  
267 =head2 known_eumm_attributes
268  
269 my @attributes = known_eumm_attributes;
270  
271 Returns a list of attributes known to be accepted by the latest version of
272 L<ExtUtils::MakeMaker>.
273  
274 =head2 is_known_eumm_attribute
275  
276 my $boolean = is_known_eumm_attribute($attribute);
277  
278 Returns a boolean whether the attribute is known to be accepted by the latest
279 version of L<ExtUtils::MakeMaker>.
280  
281 =head2 eumm_attribute_requires_version
282  
283 my $version = eumm_attribute_requires_version($attribute);
284  
285 Returns the minimum version of L<ExtUtils::MakeMaker> that accepts the
286 attribute.
287  
288 =head2 eumm_attribute_fallback
289  
290 my $hashref = eumm_attribute_fallback($attribute);
291  
292 In cases where the active version of L<ExtUtils::MakeMaker> does not support an
293 attribute, the attribute should be deleted from the options passed to
294 C<WriteMakefile>. However, some attributes may still be useful in other ways,
295 as indicated by this function. If the attribute has an associated fallback
296 method, it returns a hashref containing a C<method> and possibly other related
297 keys. Otherwise, it returns C<undef>. Currently it may return these methods:
298  
299 =over 2
300  
301 =item merge_prereqs
302  
303 The key's contents (as a hashref of prerequisites) should be merged into the
304 C<merge_target> (returned in the fallback hashref), ideally using
305 L<CPAN::Meta::Requirements/"add_requirements">.
306  
307 =back
308  
309 =head2 eumm_version_supports_attribute
310  
311 my $boolean = eumm_version_supports_attribute($attribute, $eumm_version);
312  
313 Returns a boolean whether the L<ExtUtils::MakeMaker> supports the attribute at
314 the specified version.
315  
316 =head2 perl_version_supports_attribute
317  
318 my $boolean = perl_version_supports_attribute($attribute, $perl_version);
319  
320 Returns a boolean whether the version of L<ExtUtils::MakeMaker> shipped in the
321 specified version of Perl supports the attribute.
322  
323 =head2 eumm_version_supported_attributes
324  
325 my @attributes = eumm_version_supported_attributes($eumm_version);
326  
327 Returns a list of all attributes supported by the specified version of
328 L<ExtUtils::MakeMaker>.
329  
330 =head2 perl_version_supported_attributes
331  
332 my @attributes = perl_version_supported_attributes($perl_version);
333  
334 Returns a list of all attributes supported by the version of
335 L<ExtUtils::MakeMaker> shipped in the specified version of Perl.
336  
337 =head1 BUGS
338  
339 Report any issues on the public bugtracker.
340  
341 =head1 AUTHOR
342  
343 Dan Book <dbook@cpan.org>
344  
345 =head1 COPYRIGHT AND LICENSE
346  
347 This software is Copyright (c) 2017 by Dan Book.
348  
349 This is free software, licensed under:
350  
351 The Artistic License 2.0 (GPL Compatible)
352  
353 =head1 SEE ALSO
354  
355 L<ExtUtils::MakeMaker>
↑ Summary