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 'MooX::Role::DBIConnection' => 0,
63 'File::ShareDir' => 0, # for finding our SQL snippet
64 'POSIX' => 0,
65 'Time::Piece' => 0,
66 'Text::Table' => 0,
67  
68 # For Weather::WeatherGov
69 'URI' => 0,
70 'HTTP::Tiny' => 0,
71 'IO::Socket::SSL' => 1.42,
72 'Net::SSLeay' => 1.49,
73 'JSON' => 0,
74 },
75 'EXE_FILES' => [
76 glob( 'script/*.pl' ),
77 ],
78 TEST_REQUIRES => {
79 'Test::More' => 0,
80 'Data::Dumper' => 0,
81 },
82  
83 dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
84 clean => { FILES => "$distbase-*" },
85  
86 test => { TESTS => join( ' ', @tests ) },
87 );
88  
89 # This is so that we can do
90 # require 'Makefile.PL'
91 # and then call get_module_info
92  
93 1 ▶sub get_module_info { %module }
Subroutine get_module_info: called CC=1 SCAR=0.0
94  
95 1 ▶if( ! caller ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 1 1
96 # I should maybe use something like Shipwright...
97 0 install_share dist => 'sql';
98 0 regen_README($main_file);
99 0 regen_EXAMPLES();
100 0 WriteMakefile1(get_module_info);
101 };
102  
103 1 1;
104  
105 sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
106 0 ▶ my %params=@_;
Subroutine WriteMakefile1: not called CC=17 SCAR=57.2
107 0 my $eumm_version=$ExtUtils::MakeMaker::VERSION;
108 0 $eumm_version=eval $eumm_version;
109 0 ▶ die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"EXTRA_META"} 0 0 0
110 0 ▶ die "License not specified" if not exists $params{LICENSE};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"LICENSE"} 0 0 0
111 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
112 #EUMM 6.5502 has problems with BUILD_REQUIRES
113 0 ▶ $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
Branch: 1 branch
BranchTrueFalseTotal
$params{"PREREQ_PM"} or {} 0 0 0
114 0 delete $params{BUILD_REQUIRES};
115 }
116 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
117 0 ▶ $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
Branch: 1 branch
BranchTrueFalseTotal
$params{"PREREQ_PM"} or {} 0 0 0
118 0 delete $params{TEST_REQUIRES};
119 }
120 0 ▶ delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.52" 0 0 0
121 0 ▶ delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.48" 0 0 0
122 0 ▶ delete $params{META_MERGE} if $eumm_version < 6.46;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.46" 0 0 0
123 0 ▶ delete $params{META_ADD} if $eumm_version < 6.46;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.46" 0 0 0
124 0 ▶ delete $params{LICENSE} if $eumm_version < 6.31;
Branch: 1 branch
BranchTrueFalseTotal
if $eumm_version < "6.31" 0 0 0
125 0 ▶ delete $params{AUTHOR} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
126 0 ▶ delete $params{ABSTRACT_FROM} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
127 0 ▶ delete $params{BINARY_LOCATION} if $] < 5.005;
Branch: 1 branch
BranchTrueFalseTotal
if $] < "5.005" 0 0 0
128  
129 0 WriteMakefile(%params);
130 }
131  
132 sub regen_README {
133 # README is the short version that just tells people what this is
134 # and how to install it
135 0 ▶ eval {
Subroutine regen_README: not called CC=1 SCAR=6.9
136 # Get description
137 0 my $readme = join "\n",
138 pod_section($_[0], 'NAME', 'no heading' ),
139 pod_section($_[0], 'DESCRIPTION' ),
140 <<INSTALL,
141  
142 INSTALLATION
143  
144 This is a Perl module distribution. It should be installed with whichever
145 tool you use to manage your installation of Perl, e.g. any of
146  
147 cpanm .
148 cpan .
149 cpanp -i .
150  
151 Consult http://www.cpan.org/modules/INSTALL.html for further instruction.
152 Should you wish to install this module manually, the procedure is
153  
154 perl Makefile.PL
155 make
156 make test
157 make install
158  
159 INSTALL
160 pod_section($_[0], 'REPOSITORY'),
161 pod_section($_[0], 'SUPPORT'),
162 pod_section($_[0], 'TALKS'),
163 pod_section($_[0], 'KNOWN ISSUES'),
164 pod_section($_[0], 'BUG TRACKER'),
165 pod_section($_[0], 'CONTRIBUTING'),
166 pod_section($_[0], 'SEE ALSO'),
167 pod_section($_[0], 'AUTHOR'),
168 pod_section($_[0], 'LICENSE' ),
169 pod_section($_[0], 'COPYRIGHT' ),
170 ;
171 0 update_file( 'README', $readme );
172 };
173 # README.mkdn is the documentation that will be shown as the main
174 # page of the repository on Github. Hence we recreate the POD here
175 # as Markdown
176 0 eval {
177 0 require Pod::Markdown;
178  
179 0 my $parser = Pod::Markdown->new();
180  
181 # Read POD from Module.pm and write to README
182 0 $parser->parse_from_file($_[0]);
183 0 my $readme_mkdn = <<STATUS . $parser->as_markdown;
184 [//]: # "This file is generated from the documentation in $main_file."
185 [//]: # "Please edit that file instead."
186  
187 [![Travis Build Status](https://travis-ci.org/Corion/$distbase.svg?branch=master)](https://travis-ci.org/Corion/$distbase)
188 [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/$distbase?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/$distbase)
189  
190 STATUS
191 0 update_file( 'README.mkdn', $readme_mkdn );
192 };
193 }
194  
195 sub pod_section {
196 0 ▶ my( $filename, $section, $remove_heading ) = @_;
Subroutine pod_section: not called CC=7 SCAR=40.3
197 0 ▶ open my $fh, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $filename or die "Couldn't read '${filename}': $!" 0 0 0
198 or die "Couldn't read '$filename': $!";
199  
200 my @section =
201 0 grep { /^=head1\s+$section/.../^=/ } <$fh>;
202  
203 # Trim the section
204 0 ▶ if( @section ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@section) 0 0 0
205 0 ▶ pop @section if $section[-1] =~ /^=/;
Branch: 1 branch
BranchTrueFalseTotal
if $section[-1] =~ /^=/ 0 0 0
206 0 ▶ shift @section if $remove_heading;
Branch: 1 branch
BranchTrueFalseTotal
if $remove_heading 0 0 0
207 pop @section
208 0 ▶ while $section[-1] =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
$section[-1] =~ /^\s*$/ and do { pop @section } 0 0 0
209 shift @section
210 0 ▶ while $section[0] =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
$section[0] =~ /^\s*$/ and do { shift @section } 0 0 0
211 };
212  
213 0 @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
214 0 return join "", @section;
215 }
216  
217 sub regen_EXAMPLES {
218 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
219  
220 0 my $perl = $^X;
221 0 ▶ if ($perl =~/\s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perl =~ /\s/) 0 0 0
222 0 $perl = qq{"$perl"};
223 };
224 0 my $examples = `$perl -w examples/gen_examples_pod.pl`;
225 0 ▶ if ($examples) {
Branch: 1 branch
BranchTrueFalseTotal
if ($examples) 0 0 0
226 0 warn "(Re)Creating lib/WWW/Mechanize/Chrome/Examples.pm\n";
227 0 $examples =~ s/\r\n/\n/g;
228 0 update_file( 'lib/WWW/Mechanize/Chrome/Examples.pm', $examples );
229 };
230 };
231  
232 sub update_file {
233 0 ▶ my( $filename, $new_content ) = @_;
Subroutine update_file: not called CC=5 SCAR=34.0
234 0 my $content;
235 0 ▶ if( -f $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $filename) 0 0 0
236 0 ▶ open my $fh, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $filename or die "Couldn't read '${filename}': $!" 0 0 0
237 or die "Couldn't read '$filename': $!";
238 0 binmode $fh;
239 0 local $/;
240 0 $content = <$fh>;
241 };
242  
243 0 ▶ if( $content ne $new_content ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content ne $new_content) 0 0 0
244 0 ▶ if( open my $fh, '>', $filename ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '>', $filename) { } 0 0 0
245 0 binmode $fh;
246 0 print $fh $new_content;
247 } else {
248 0 warn "Couldn't (re)write '$filename': $!";
249 };
250 };
251 }
252  
253 package MY;
254 1 ▶use File::ShareDir::Install qw(postamble);
Subroutine BEGIN: called CC=1 SCAR=0.0
↑ Summary blib/lib/Weather/MOSMIX/Weathercodes.pm »