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   428936 use strict;
  1         3  
  1         39  
4 1     1   711 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         102099  
  1         2871  
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 = 'HTTP::Request::FromCurl';
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/$distbase",
30             url => "git://github.com/Corion/$distbase.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'=> 'perl',
46              
47             PL_FILES => {},
48             EXE_FILES => [glob 'script/*'],
49             BUILD_REQUIRES => {
50             'ExtUtils::MakeMaker' => 0,
51             },
52              
53             PREREQ_PM => {
54             'Carp' => 0,
55             'Getopt::Long' => '2.39', # for ->getoptionsfromarray
56             'Moo' => '2',
57             'HTTP::Request' => '6.07',
58             'HTTP::Request::Common' => '6.07',
59             'HTTP::Request::Generator' => '0.09', # earlier versions don't handle IPv6 well
60             'URI' => 0,
61             'URI::Escape' => 0,
62             'List::Util' => '1.29', # for pairmap
63             'PerlX::Maybe' => 0,
64             'MIME::Base64' => 0,
65             'JSON' => 0,
66             'File::Basename' => 0, # core anyway
67             },
68             TEST_REQUIRES => {
69             'Test2::V0' => '0',
70             'Data::Dumper' => 0,
71             'Capture::Tiny' => 0,
72             'Path::Tiny' => 0,
73             'HTTP::Tiny' => 0,
74             'WWW::Mechanize' => 0,
75             'LWP::UserAgent' => 0,
76             'IO::Socket::SSL' => 0, # for allowing -k to compile
77             #'HTTP::Cookies::Netscape' => 0, # this can't cope with the Netscape cookie files that curl writes :(
78             'HTTP::CookieJar' => 0, # this one doesn't have an adapter to save/load at all :(
79             'HTTP::CookieJar::LWP' => 0, # this one doesn't have an adapter to save/load at all :(
80             'Test::HTTP::LocalServer' => 0.67, # we want ->server_url()
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     1   20 sub get_module_info { %module }
94              
95             if( ! caller ) {
96             # I should maybe use something like Shipwright...
97             my $mm = WriteMakefile1(get_module_info);
98             my $version = $mm->parse_version($main_file);
99             regen_README($main_file, $version);
100             regen_EXAMPLES() if -d 'examples';
101             };
102              
103             1;
104              
105             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
106 0     0     my %params=@_;
107 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
108 0           $eumm_version=eval $eumm_version;
109 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
110 0 0         die "License not specified" if not exists $params{LICENSE};
111 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
112             #EUMM 6.5502 has problems with BUILD_REQUIRES
113 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
114 0           delete $params{BUILD_REQUIRES};
115             }
116 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
117 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
118 0           delete $params{TEST_REQUIRES};
119             }
120 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
121 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
122 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
123 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
124 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
125 0 0         delete $params{AUTHOR} if $] < 5.005;
126 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
127 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
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     0     my( $file, $version ) = @_;
136 0           eval {
137             # Get description
138 0           my $readme = join "\n",
139             pod_section($file, 'NAME', 'no heading' ),
140             pod_section($file, 'DESCRIPTION' ),
141             <
142             This document describes version $version.
143             VERSION
144             <
145              
146             INSTALLATION
147              
148             This is a Perl module distribution. It should be installed with whichever
149             tool you use to manage your installation of Perl, e.g. any of
150              
151             cpanm .
152             cpan .
153             cpanp -i .
154              
155             Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
156             Should you wish to install this module manually, the procedure is
157              
158             perl Makefile.PL
159             make
160             make test
161             make install
162              
163             INSTALL
164             pod_section($file, 'REPOSITORY'),
165             pod_section($file, 'SUPPORT'),
166             pod_section($file, 'TALKS'),
167             pod_section($file, 'KNOWN ISSUES'),
168             pod_section($file, 'BUG TRACKER'),
169             pod_section($file, 'CONTRIBUTING'),
170             pod_section($file, 'SEE ALSO'),
171             pod_section($file, 'AUTHOR'),
172             pod_section($file, 'LICENSE' ),
173             pod_section($file, 'COPYRIGHT' ),
174             ;
175 0           update_file( 'README', $readme );
176             };
177             # README.mkdn is the documentation that will be shown as the main
178             # page of the repository on Github. Hence we recreate the POD here
179             # as Markdown
180 0           eval {
181 0           require Pod::Markdown;
182              
183 0           my $parser = Pod::Markdown->new();
184              
185             # Read POD from Module.pm and write to README
186 0           $parser->parse_from_file($_[0]);
187 0           my $readme_mkdn = <as_markdown;
188              
189             [![Travis Build Status](https://travis-ci.org/Corion/$distlink.svg?branch=master)](https://travis-ci.org/Corion/$distlink)
190             [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/$distlink?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/$distlink)
191              
192             STATUS
193 0           update_file( 'README.mkdn', $readme_mkdn );
194             };
195             }
196              
197             sub pod_section {
198 0     0     my( $filename, $section, $remove_heading ) = @_;
199 0 0         open my $fh, '<', $filename
200             or die "Couldn't read '$filename': $!";
201              
202             my @section =
203 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
204              
205             # Trim the section
206 0 0         if( @section ) {
207 0 0         pop @section if $section[-1] =~ /^=/;
208 0 0         shift @section if $remove_heading;
209              
210             pop @section
211 0   0       while @section and $section[-1] =~ /^\s*$/;
212             shift @section
213 0   0       while @section and $section[0] =~ /^\s*$/;
214             };
215              
216 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
217 0           return join "", @section;
218             }
219              
220             sub regen_EXAMPLES {
221 0     0     my $perl = $^X;
222 0 0         if ($perl =~/\s/) {
223 0           $perl = qq{"$perl"};
224             };
225 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
226 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
227 0 0         if ($examples) {
228 0           warn "(Re)Creating $example_file\n";
229 0           $examples =~ s/\r\n/\n/g;
230 0           update_file( $example_file, $examples );
231             };
232             };
233              
234             sub update_file {
235 0     0     my( $filename, $new_content ) = @_;
236 0           my $content;
237 0 0         if( -f $filename ) {
238 0 0         open my $fh, '<:raw:encoding(UTF-8)', $filename
239             or die "Couldn't read '$filename': $!";
240 0           local $/;
241 0           $content = <$fh>;
242             };
243              
244 0 0         if( $content ne $new_content ) {
245 0 0         if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
246 0           print $fh $new_content;
247             } else {
248 0           warn "Couldn't (re)write '$filename': $!";
249             };
250             };
251             }