File Coverage

Makefile.PL
Criterion Covered Total %
statement 7 73 9.5
branch 0 48 0.0
condition 0 12 0.0
subroutine 3 8 37.5
pod n/a
total 10 141 7.0


line stmt bran cond sub pod time code
1             # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2              
3 1     1   289003 use strict;
  1         3  
  1         41  
4 1     1   731 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         109731  
  1         1273  
5             # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6             # the contents of the Makefile that is written.
7              
8             # Normalize version strings like 6.30_02 to 6.3002,
9             # so that we can do numerical comparisons on it.
10             my $eumm_version = $ExtUtils::MakeMaker::VERSION;
11             $eumm_version =~ s/_//;
12              
13             my $module = 'Mojo::UserAgent::Paranoid';
14             (my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
15             (my $distbase = $module) =~ s!::!-!g;
16             my $distlink = $distbase;
17              
18             my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
19              
20             my %module = (
21             NAME => $module,
22             AUTHOR => q{Max Maischein },
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/$distlink",
30             url => "git://github.com/Corion/$distlink.git",
31             type => 'git',
32             },
33             bugtracker => {
34             web => "https://github.com/Corion/$distbase/issues",
35             # mailto => 'meta-bugs@example.com',
36             },
37             license => "https://dev.perl.org/licenses/",
38             },
39             dynamic_config => 0, # we promise to keep META.* up-to-date
40             x_static_install => 1, # we are pure Perl and don't do anything fancy
41             },
42              
43             MIN_PERL_VERSION => '5.020', # I use signatures
44              
45             'LICENSE'=> 'artistic_2',
46              
47             PL_FILES => {},
48             BUILD_REQUIRES => { 'ExtUtils::MakeMaker' => 0 },
49              
50             PREREQ_PM => {
51             'experimental' => '0.036',
52             'IO::Socket::IP' => '0',
53             'IO::Socket::UNIX' => '0',
54             'Mojolicious' => '0',
55             'Net::DNS::Paranoid' => '0',
56             'Socket' => '0'
57             },
58             TEST_REQUIRES => {
59             'Data::Dumper' => '0',
60             'Test2::V0' => '0',
61             'Test::More' => '0'
62             },
63              
64             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
65             clean => { FILES => "$distbase-*" },
66              
67             test => { TESTS => join( ' ', @tests ) },
68             );
69              
70             # This is so that we can do
71             # require 'Makefile.PL'
72             # and then call get_module_info
73              
74 1     1   13 sub get_module_info { %module }
75              
76             if( ! caller ) {
77             # I should maybe use something like Shipwright...
78             my $mm = WriteMakefile1(get_module_info);
79             my $version = $mm->parse_version($main_file);
80             regen_README($main_file, $version);
81             regen_EXAMPLES() if -d 'examples';
82             };
83              
84             1;
85              
86             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
87 0     0     my %params=@_;
88 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
89 0           $eumm_version=eval $eumm_version;
90 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
91 0 0         die "License not specified" if not exists $params{LICENSE};
92 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
93             #EUMM 6.5502 has problems with BUILD_REQUIRES
94 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
95 0           delete $params{BUILD_REQUIRES};
96             }
97 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
98 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
99 0           delete $params{TEST_REQUIRES};
100             }
101 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
102 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
103 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
104 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
105 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
106 0 0         delete $params{AUTHOR} if $] < 5.005;
107 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
108 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
109              
110 0           WriteMakefile(%params);
111             }
112              
113             sub regen_README {
114             # README is the short version that just tells people what this is
115             # and how to install it
116 0     0     my( $file, $version ) = @_;
117 0           eval {
118             # Get description
119 0           my $readme = join "\n",
120             pod_section($file, 'NAME', 'no heading' ),
121             pod_section($file, 'DESCRIPTION' ),
122             <
123             This document describes version $version.
124             VERSION
125             <
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($file, 'REPOSITORY'),
146             pod_section($file, 'SUPPORT'),
147             pod_section($file, 'TALKS'),
148             pod_section($file, 'KNOWN ISSUES'),
149             pod_section($file, 'BUG TRACKER'),
150             pod_section($file, 'CONTRIBUTING'),
151             pod_section($file, 'SEE ALSO'),
152             pod_section($file, 'AUTHOR'),
153             pod_section($file, 'LICENSE' ),
154             pod_section($file, '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 = <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     0     my( $filename, $section, $remove_heading ) = @_;
181 0 0         open my $fh, '<', $filename
182             or die "Couldn't read '$filename': $!";
183              
184             my @section =
185 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
186              
187             # Trim the section
188 0 0         if( @section ) {
189 0 0         pop @section if $section[-1] =~ /^=/;
190 0 0         shift @section if $remove_heading;
191              
192             pop @section
193 0   0       while @section and $section[-1] =~ /^\s*$/;
194             shift @section
195 0   0       while @section and $section[0] =~ /^\s*$/;
196             };
197              
198 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
199 0           return join "", @section;
200             }
201              
202             sub regen_EXAMPLES {
203 0     0     my $perl = $^X;
204 0 0         if ($perl =~/\s/) {
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 0         if ($examples) {
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     0     my( $filename, $new_content ) = @_;
218 0           my $content;
219 0 0         if( -f $filename ) {
220 0 0         open my $fh, '<:raw:encoding(UTF-8)', $filename
221             or die "Couldn't read '$filename': $!";
222 0           local $/;
223 0           $content = <$fh>;
224             };
225              
226 0 0         if( $content ne $new_content ) {
227 0 0         if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
228 0           print $fh $new_content;
229             } else {
230 0           warn "Couldn't (re)write '$filename': $!";
231             };
232             };
233             }