Makefile.PL

filter: Statementstmt 24.4% 23 / 94 Branchbran 1.7% 1 / 56 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 5 / 10 Podpod n/a totaltotal 17.0% 29 / 170 CC 30 SCAR 50.1
CC
30
Cov
15%
WriteMakefile1
306.0
pod_section
56.0
update_file
30.0
CRAP 149.5
↑ Summary blib/lib/Weather/MOSMIX/Weathercodes.pm »
1 # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use ExtUtils::MakeMaker qw(WriteMakefile);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::ShareDir::Install;
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 = 'Weather::MOSMIX';
15 1 (my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
16 1 (my $distbase = $module) =~ s!::!-!g;
17  
18 1 my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
19  
20 1 my %module = (
21 NAME => $module,
22 AUTHOR => q{Max Maischein <corion@cpan.org>},
23 VERSION_FROM => $main_file,
24 ABSTRACT_FROM => $main_file,
25 META_MERGE => {
26 "meta-spec" => { version => 2 },
27 resources => {
28 repository => {
29 web => "https://github.com/Corion/$distbase",
30 url => "git://github.com/Corion/$distbase.git",
31 type => 'git',
32 }
33 },
34 dynamic_config => 0, # we promise to keep META.* up-to-date
35 x_static_install => 1, # we are pure Perl and don't do anything fancy
36 },
37  
38 MIN_PERL_VERSION => '5.022', # We want certain Unicode emoji that aren't recognized earlier
39  
40 'LICENSE'=> 'perl',
41  
42 PL_FILES => {},
43 CONFIGURE_REQUIRES => {
44 'ExtUtils::MakeMaker' => '5.52_01',
45 'File::ShareDir::Install' => 0,
46 },
47  
48 PREREQ_PM => {
49 'Moo' => 2,
50 'Filter::signatures' => '0.09',
51  
52 # For reading the MOSMIX KML file
53 'PerlIO::gzip' => 0.2,
54 'Archive::Zip' => 0,
55 'XML::Twig' => 0,
56  
57 # Later, we might want to spin this out
58 # For writing the stuff to a database
59 'DBI' => 0,
60 'DBIx::RunSQL' => 0,
61 'DBD::SQLite' => 1.56,
62 'File::ShareDir' => 0, # for finding our SQL snippet
63 'POSIX' => 0,
64 'Time::Piece' => 0,
65 'Text::Table' => 0,
66  
67 # For Weather::WeatherGov
68 'URI' => 0,
69 'HTTP::Tiny' => 0,
70 'IO::Socket::SSL' => 1.42,
71 'Net::SSLeay' => 1.49,
72 'JSON' => 0,
73 },
74 'EXE_FILES' => [
75 glob( 'script/*.pl' ),
76 ],
77 TEST_REQUIRES => {
78 'Test::More' => 0,
79 'Data::Dumper' => 0,
80 },
81  
82 dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
83 clean => { FILES => "$distbase-*" },
84  
85 test => { TESTS => join( ' ', @tests ) },
86 );
87  
88 # This is so that we can do
89 # require 'Makefile.PL'
90 # and then call get_module_info
91  
92 1 ▶sub get_module_info { %module }
Subroutine get_module_info: called CC=1 SCAR=0.0
93  
94 1 ▶if( ! caller ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 1 1
95 # I should maybe use something like Shipwright...
96 0 install_share dist => 'sql';
97 0 regen_README($main_file);
98 0 regen_EXAMPLES();
99 0 WriteMakefile1(get_module_info);
100 };
101  
102 1 1;
103  
104 sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
105 0 ▶ my %params=@_;
Subroutine WriteMakefile1: not called CC=17 SCAR=57.2
106 0 my $eumm_version=$ExtUtils::MakeMaker::VERSION;
107 0 $eumm_version=eval $eumm_version;
108 0 ▶ die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"EXTRA_META"} 0 0 0
109 0 ▶ die "License not specified" if not exists $params{LICENSE};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"LICENSE"} 0 0 0
110 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
111 #EUMM 6.5502 has problems with BUILD_REQUIRES
112 0 ▶ $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
Branch: 1 branch
BranchTrueFalseTotal
$params{"PREREQ_PM"} or {} 0 0 0
113 0 delete $params{BUILD_REQUIRES};
114 }
115 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
116 0 ▶ $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
Branch: 1 branch
BranchTrueFalseTotal
$params{"PREREQ_PM"} or {} 0 0 0
117 0 delete $params{TEST_REQUIRES};
118 }
119 0 ▶ delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.52" 0 0 0
120 0 ▶ delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.48" 0 0 0
121 0 ▶ delete $params{META_MERGE} if $eumm_version < 6.46;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.46" 0 0 0
122 0 ▶ delete $params{META_ADD} if $eumm_version < 6.46;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.46" 0 0 0
123 0 ▶ delete $params{LICENSE} if $eumm_version < 6.31;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.31" 0 0 0
124 0 ▶ delete $params{AUTHOR} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
125 0 ▶ delete $params{ABSTRACT_FROM} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
126 0 ▶ delete $params{BINARY_LOCATION} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
127  
128 0 WriteMakefile(%params);
129 }
130  
131 sub regen_README {
132 # README is the short version that just tells people what this is
133 # and how to install it
134 0 ▶ eval {
Subroutine regen_README: not called CC=1 SCAR=6.9
135 # Get description
136 0 my $readme = join "\n",
137 pod_section($_[0], 'NAME', 'no heading' ),
138 pod_section($_[0], 'DESCRIPTION' ),
139 <<INSTALL,
140  
141 INSTALLATION
142  
143 This is a Perl module distribution. It should be installed with whichever
144 tool you use to manage your installation of Perl, e.g. any of
145  
146 cpanm .
147 cpan .
148 cpanp -i .
149  
150 Consult http://www.cpan.org/modules/INSTALL.html for further instruction.
151 Should you wish to install this module manually, the procedure is
152  
153 perl Makefile.PL
154 make
155 make test
156 make install
157  
158 INSTALL
159 pod_section($_[0], 'REPOSITORY'),
160 pod_section($_[0], 'SUPPORT'),
161 pod_section($_[0], 'TALKS'),
162 pod_section($_[0], 'KNOWN ISSUES'),
163 pod_section($_[0], 'BUG TRACKER'),
164 pod_section($_[0], 'CONTRIBUTING'),
165 pod_section($_[0], 'SEE ALSO'),
166 pod_section($_[0], 'AUTHOR'),
167 pod_section($_[0], 'LICENSE' ),
168 pod_section($_[0], 'COPYRIGHT' ),
169 ;
170 0 update_file( 'README', $readme );
171 };
172 # README.mkdn is the documentation that will be shown as the main
173 # page of the repository on Github. Hence we recreate the POD here
174 # as Markdown
175 0 eval {
176 0 require Pod::Markdown;
177  
178 0 my $parser = Pod::Markdown->new();
179  
180 # Read POD from Module.pm and write to README
181 0 $parser->parse_from_file($_[0]);
182 0 my $readme_mkdn = <<STATUS . $parser->as_markdown;
183 [//]: # "This file is generated from the documentation in $main_file."
184 [//]: # "Please edit that file instead."
185  
186 [![Travis Build Status](https://travis-ci.org/Corion/$distbase.svg?branch=master)](https://travis-ci.org/Corion/$distbase)
187 [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/$distbase?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/$distbase)
188  
189 STATUS
190 0 update_file( 'README.mkdn', $readme_mkdn );
191 };
192 }
193  
194 sub pod_section {
195 0 ▶ my( $filename, $section, $remove_heading ) = @_;
Subroutine pod_section: not called CC=7 SCAR=40.3
196 0 ▶ open my $fh, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $filename or die "Couldn't read '${filename}': $!" 0 0 0
197 or die "Couldn't read '$filename': $!";
198  
199 my @section =
200 0 grep { /^=head1\s+$section/.../^=/ } <$fh>;
201  
202 # Trim the section
203 0 ▶ if( @section ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@section) 0 0 0
204 0 ▶ pop @section if $section[-1] =~ /^=/;
Branch: 1 branch
BranchTrueFalseTotal
if $section[-1] =~ /^=/ 0 0 0
205 0 ▶ shift @section if $remove_heading;
Branch: 1 branch
BranchTrueFalseTotal
if $remove_heading 0 0 0
206 pop @section
207 0 ▶ while $section[-1] =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
$section[-1] =~ /^\s*$/ and do { pop @section } 0 0 0
208 shift @section
209 0 ▶ while $section[0] =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
$section[0] =~ /^\s*$/ and do { shift @section } 0 0 0
210 };
211  
212 0 @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
213 0 return join "", @section;
214 }
215  
216 sub regen_EXAMPLES {
217 0 ▶ return unless -e "examples/gen_examples_pod.pl";
Subroutine regen_EXAMPLES: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
unless -e "examples/gen_examples_pod.pl" 0 0 0
218  
219 0 my $perl = $^X;
220 0 ▶ if ($perl =~/\s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perl =~ /\s/) 0 0 0
221 0 $perl = qq{"$perl"};
222 };
223 0 my $examples = `$perl -w examples/gen_examples_pod.pl`;
224 0 ▶ if ($examples) {
Branch: 1 branch
BranchTrueFalseTotal
if ($examples) 0 0 0
225 0 warn "(Re)Creating lib/WWW/Mechanize/Chrome/Examples.pm\n";
226 0 $examples =~ s/\r\n/\n/g;
227 0 update_file( 'lib/WWW/Mechanize/Chrome/Examples.pm', $examples );
228 };
229 };
230  
231 sub update_file {
232 0 ▶ my( $filename, $new_content ) = @_;
Subroutine update_file: not called CC=5 SCAR=34.0
233 0 my $content;
234 0 ▶ if( -f $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $filename) 0 0 0
235 0 ▶ open my $fh, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $filename or die "Couldn't read '${filename}': $!" 0 0 0
236 or die "Couldn't read '$filename': $!";
237 0 binmode $fh;
238 0 local $/;
239 0 $content = <$fh>;
240 };
241  
242 0 ▶ if( $content ne $new_content ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content ne $new_content) 0 0 0
243 0 ▶ if( open my $fh, '>', $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '>', $filename) { } 0 0 0
244 0 binmode $fh;
245 0 print $fh $new_content;
246 } else {
247 0 warn "Couldn't (re)write '$filename': $!";
248 };
249 };
250 }
251  
252 package MY;
253 1 ▶use File::ShareDir::Install qw(postamble);
Subroutine BEGIN: called CC=1 SCAR=0.0
↑ Summary blib/lib/Weather/MOSMIX/Weathercodes.pm »