Makefile.PL

filter: Statementstmt 22.4% 20 / 89 Branchbran 3.4% 2 / 58 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 37.5% 3 / 8 Podpod n/a totaltotal 14.2% 25 / 175 SCAR 64.7
CC
31
Cov
14%
WriteMakefile1
306.0
pod_section
90.0
update_file
30.0
CRAP 645.7
↑ Summary blib/lib/Term/Output/List/Win32.pm »
1  
2 # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use ExtUtils::MakeMaker qw(WriteMakefile);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
7 # the contents of the Makefile that is written.
8  
9 # Normalize version strings like 6.30_02 to 6.3002,
10 # so that we can do numerical comparisons on it.
11 1 my $eumm_version = $ExtUtils::MakeMaker::VERSION;
12 1 $eumm_version =~ s/_//;
13  
14 1 my $module = 'Term::Output::List';
15 1 (my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
16 1 (my $distbase = $module) =~ s!::!-!g;
17 1 my $distlink = $distbase;
18  
19 1 my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
20  
21 1 my @TERM_MODULES;
22 1 ▶if( $^O eq 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 1 1
23 0 push @TERM_MODULES, 'Win32::Console' => 0;
24 }
25  
26 1 my %module = (
27 NAME => $module,
28 AUTHOR => q{Max Maischein <corion@cpan.org>},
29 VERSION_FROM => $main_file,
30 ABSTRACT_FROM => $main_file,
31 META_MERGE => {
32 "meta-spec" => { version => 2 },
33 resources => {
34 repository => {
35 web => "https://github.com/Corion/$distlink",
36 url => "git://github.com/Corion/$distlink.git",
37 type => 'git',
38 },
39 bugtracker => {
40 web => "https://github.com/Corion/$distbase/issues",
41 # mailto => 'meta-bugs@example.com',
42 },
43 license => "https://dev.perl.org/licenses/",
44 },
45 dynamic_config => 1, # We have dynamic prerequisites
46 x_static_install => 0, # We have dynamic prerequisites
47 },
48  
49 MIN_PERL_VERSION => '5.020', # I use signatures
50  
51 'LICENSE'=> 'perl',
52  
53 PL_FILES => {},
54 BUILD_REQUIRES => {
55 'ExtUtils::MakeMaker' => 0,
56 },
57  
58 PREREQ_PM => {
59 'Moo' => 2, # for some hashes-as-objects
60 'Module::Load' => 0,
61 'Term::Cap' => 0,
62 @TERM_MODULES,
63 },
64 TEST_REQUIRES => {
65 'Test::More' => 0,
66 'Test2::V0' => 0,
67 },
68  
69 dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
70 clean => { FILES => "$distbase-*" },
71  
72 test => { TESTS => join( ' ', @tests ) },
73 );
74  
75 # This is so that we can do
76 # require 'Makefile.PL'
77 # and then call get_module_info
78  
79 1 ▶sub get_module_info { %module }
Subroutine get_module_info: called CC=1 SCAR=0.0
80  
81 1 ▶if( ! caller ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 1 1
82 # I should maybe use something like Shipwright...
83 0 regen_README($main_file);
84 0 ▶ regen_EXAMPLES() if -d 'examples';
Branch: 1 branch
BranchTrueFalseTotal
if -d "examples" 0 0 0
85 0 WriteMakefile1(get_module_info);
86 };
87  
88 1 1;
89  
90 sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
91 0 ▶ my %params=@_;
Subroutine WriteMakefile1: not called CC=17 SCAR=57.2
92 0 my $eumm_version=$ExtUtils::MakeMaker::VERSION;
93 0 $eumm_version=eval $eumm_version;
94 0 ▶ die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"EXTRA_META"} 0 0 0
95 0 ▶ die "License not specified" if not exists $params{LICENSE};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"LICENSE"} 0 0 0
96 0 ▶ if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params{"BUILD_REQUIRES"} and $eumm_version < "6.5503") 0 0 0
Condition0%0/3
$params{"BUILD_REQUIRES"} and $eumm_version < "6.5503"
!ll&&!rl&&r
000
MC/DC0%0/2
$params{"BUILD_REQUIRES"} and $eumm_version < "6.5503"
$params{"BUILD_REQUIRES"} $eumm_version < "6.5503"
Truth table0%0/3
A and B
A= $params{"BUILD_REQUIRES"}B= $eumm_version < "6.5503"
ABresult
0X0
100
111
97 #EUMM 6.5502 has problems with BUILD_REQUIRES
98 0 ▶ $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
Branch: 1 branch
BranchTrueFalseTotal
$params{"PREREQ_PM"} or {} 0 0 0
99 0 delete $params{BUILD_REQUIRES};
100 }
101 0 ▶ if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params{"TEST_REQUIRES"} and $eumm_version < "6.64") 0 0 0
Condition0%0/3
$params{"TEST_REQUIRES"} and $eumm_version < "6.64"
!ll&&!rl&&r
000
MC/DC0%0/2
$params{"TEST_REQUIRES"} and $eumm_version < "6.64"
$params{"TEST_REQUIRES"} $eumm_version < "6.64"
Truth table0%0/3
A and B
A= $params{"TEST_REQUIRES"}B= $eumm_version < "6.64"
ABresult
0X0
100
111
102 0 ▶ $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
Branch: 1 branch
BranchTrueFalseTotal
$params{"PREREQ_PM"} or {} 0 0 0
103 0 delete $params{TEST_REQUIRES};
104 }
105 0 ▶ delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.52" 0 0 0
106 0 ▶ delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.48" 0 0 0
107 0 ▶ delete $params{META_MERGE} if $eumm_version < 6.46;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.46" 0 0 0
108 0 ▶ delete $params{META_ADD} if $eumm_version < 6.46;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.46" 0 0 0
109 0 ▶ delete $params{LICENSE} if $eumm_version < 6.31;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.31" 0 0 0
110 0 ▶ delete $params{AUTHOR} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
111 0 ▶ delete $params{ABSTRACT_FROM} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
112 0 ▶ delete $params{BINARY_LOCATION} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
113  
114 0 WriteMakefile(%params);
115 }
116  
117 sub regen_README {
118 # README is the short version that just tells people what this is
119 # and how to install it
120 0 ▶ eval {
Subroutine regen_README: not called CC=1 SCAR=6.9
121 # Get description
122 0 my $readme = join "\n",
123 pod_section($_[0], 'NAME', 'no heading' ),
124 pod_section($_[0], 'DESCRIPTION' ),
125 <<INSTALL,
126  
127 INSTALLATION
128  
129 This is a Perl module distribution. It should be installed with whichever
130 tool you use to manage your installation of Perl, e.g. any of
131  
132 cpanm .
133 cpan .
134 cpanp -i .
135  
136 Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
137 Should you wish to install this module manually, the procedure is
138  
139 perl Makefile.PL
140 make
141 make test
142 make install
143  
144 INSTALL
145 pod_section($_[0], 'REPOSITORY'),
146 pod_section($_[0], 'SUPPORT'),
147 pod_section($_[0], 'TALKS'),
148 pod_section($_[0], 'KNOWN ISSUES'),
149 pod_section($_[0], 'BUG TRACKER'),
150 pod_section($_[0], 'CONTRIBUTING'),
151 pod_section($_[0], 'SEE ALSO'),
152 pod_section($_[0], 'AUTHOR'),
153 pod_section($_[0], 'LICENSE' ),
154 pod_section($_[0], 'COPYRIGHT' ),
155 ;
156 0 update_file( 'README', $readme );
157 };
158 # README.mkdn is the documentation that will be shown as the main
159 # page of the repository on Github. Hence we recreate the POD here
160 # as Markdown
161 0 eval {
162 0 require Pod::Markdown;
163  
164 0 my $parser = Pod::Markdown->new();
165  
166 # Read POD from Module.pm and write to README
167 0 $parser->parse_from_file($_[0]);
168 0 my $readme_mkdn = <<STATUS . $parser->as_markdown;
169  
170 [![Windows](https://github.com/Corion/$distbase/workflows/windows/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Awindows)
171 [![MacOS](https://github.com/Corion/$distbase/workflows/macos/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Amacos)
172 [![Linux](https://github.com/Corion/$distbase/workflows/linux/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Alinux)
173  
174 STATUS
175 0 update_file( 'README.mkdn', $readme_mkdn );
176 };
177 }
178  
179 sub pod_section {
180 0 ▶ my( $filename, $section, $remove_heading ) = @_;
Subroutine pod_section: not called CC=9 SCAR=45.0
181 0 ▶ open my $fh, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $filename or die "Couldn't read '${filename}': $!" 0 0 0
182 or die "Couldn't read '$filename': $!";
183  
184 my @section =
185 0 grep { /^=head1\s+$section/.../^=/ } <$fh>;
186  
187 # Trim the section
188 0 ▶ if( @section ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@section) 0 0 0
189 0 ▶ pop @section if $section[-1] =~ /^=/;
Branch: 1 branch
BranchTrueFalseTotal
if $section[-1] =~ /^=/ 0 0 0
190 0 ▶ shift @section if $remove_heading;
Branch: 1 branch
BranchTrueFalseTotal
if $remove_heading 0 0 0
191  
192 pop @section
193 0 ▶ while @section and $section[-1] =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
@section and $section[-1] =~ /^\s*$/ and do { pop @section } 0 0 0
Condition0%0/3
@section and $section[-1] =~ /^\s*$/
!ll&&!rl&&r
000
MC/DC0%0/2
@section and $section[-1] =~ /^\s*$/
@section $section[-1] =~ /^\s*$/
Truth table0%0/3
A and B
A= @sectionB= $section[-1] =~ /^\s*$/
ABresult
0X0
100
111
194 shift @section
195 0 ▶ while @section and $section[0] =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
@section and $section[0] =~ /^\s*$/ and do { shift @section } 0 0 0
Condition0%0/3
@section and $section[0] =~ /^\s*$/
!ll&&!rl&&r
000
MC/DC0%0/2
@section and $section[0] =~ /^\s*$/
@section $section[0] =~ /^\s*$/
Truth table0%0/3
A and B
A= @sectionB= $section[0] =~ /^\s*$/
ABresult
0X0
100
111
196 };
197  
198 0 @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
199 0 return join "", @section;
200 }
201  
202 sub regen_EXAMPLES {
203 0 ▶ my $perl = $^X;
Subroutine regen_EXAMPLES: not called CC=3 SCAR=24.8
204 0 ▶ if ($perl =~/\s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perl =~ /\s/) 0 0 0
205 0 $perl = qq{"$perl"};
206 };
207 0 (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
208 0 my $examples = `$perl -w examples/gen_examples_pod.pl`;
209 0 ▶ if ($examples) {
Branch: 1 branch
BranchTrueFalseTotal
if ($examples) 0 0 0
210 0 warn "(Re)Creating $example_file\n";
211 0 $examples =~ s/\r\n/\n/g;
212 0 update_file( $example_file, $examples );
213 };
214 };
215  
216 sub update_file {
217 0 ▶ my( $filename, $new_content ) = @_;
Subroutine update_file: not called CC=5 SCAR=34.0
218 0 my $content;
219 0 ▶ if( -f $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $filename) 0 0 0
220 0 ▶ open my $fh, '<:raw:encoding(UTF-8)', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<:raw:encoding(UTF-8)", $filename or die "Couldn't read '${filename}': $!" 0 0 0
221 or die "Couldn't read '$filename': $!";
222 0 local $/;
223 0 $content = <$fh>;
224 };
225  
226 0 ▶ if( $content ne $new_content ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content ne $new_content) 0 0 0
227 0 ▶ if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '>:raw:encoding(UTF-8)', $filename) { } 0 0 0
228 0 print $fh $new_content;
229 } else {
230 0 warn "Couldn't (re)write '$filename': $!";
231 };
232 };
233 }
↑ Summary blib/lib/Term/Output/List/Win32.pm »