File Coverage

Makefile.PL
Criterion Covered Total %
statement 7 72 9.7
branch 0 48 0.0
condition 0 12 0.0
subroutine 3 8 37.5
pod n/a
total 10 140 7.1


line stmt bran cond sub pod time code
1             # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2              
3 1     1   416 use strict;
  1         3  
  1         33  
4 1     1   951 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         114115  
  1         1511  
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.010', # I use // in some places
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             'Filter::signatures' => '0.16',
57             'Moo' => '2',
58             'HTTP::Request' => '6.07',
59             'HTTP::Request::Common' => '6.07',
60             'HTTP::Request::Generator' => '0.09', # earlier versions don't handle IPv6 well
61             'URI' => 0,
62             'URI::Escape' => 0,
63             'List::Util' => '1.29', # for pairmap
64             'PerlX::Maybe' => 0,
65             'MIME::Base64' => 0,
66             'JSON' => 0,
67             'File::Basename' => 0, # core anyway
68             },
69             TEST_REQUIRES => {
70             'Test::More' => '0.88', # for done_testing support
71             'Data::Dumper' => 0,
72             'Capture::Tiny' => 0,
73             'Path::Tiny' => 0,
74             'HTTP::Tiny' => 0,
75             'WWW::Mechanize' => 0,
76             'LWP::UserAgent' => 0,
77             'IO::Socket::SSL' => 0, # for allowing -k to compile
78             #'HTTP::Cookies::Netscape' => 0, # this can't cope with the Netscape cookie files that curl writes :(
79             'HTTP::CookieJar' => 0, # this one doesn't have an adapter to save/load at all :(
80             'HTTP::CookieJar::LWP' => 0, # this one doesn't have an adapter to save/load at all :(
81             'Test::HTTP::LocalServer' => 0.67, # we want ->server_url()
82             },
83              
84             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
85             clean => { FILES => "$distbase-*" },
86              
87             test => { TESTS => join( ' ', @tests ) },
88             );
89              
90             # This is so that we can do
91             # require 'Makefile.PL'
92             # and then call get_module_info
93              
94 1     1   12 sub get_module_info { %module }
95              
96             if( ! caller ) {
97             # I should maybe use something like Shipwright...
98             regen_README($main_file);
99             regen_EXAMPLES() if -d 'examples';
100             WriteMakefile1(get_module_info);
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     eval {
136             # Get description
137 0           my $readme = join "\n",
138             pod_section($_[0], 'NAME', 'no heading' ),
139             pod_section($_[0], 'DESCRIPTION' ),
140             <
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 https://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 = <as_markdown;
184              
185             [![Travis Build Status](https://travis-ci.org/Corion/$distlink.svg?branch=master)](https://travis-ci.org/Corion/$distlink)
186             [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/$distlink?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/$distlink)
187              
188             STATUS
189 0           update_file( 'README.mkdn', $readme_mkdn );
190             };
191             }
192              
193             sub pod_section {
194 0     0     my( $filename, $section, $remove_heading ) = @_;
195 0 0         open my $fh, '<', $filename
196             or die "Couldn't read '$filename': $!";
197              
198             my @section =
199 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
200              
201             # Trim the section
202 0 0         if( @section ) {
203 0 0         pop @section if $section[-1] =~ /^=/;
204 0 0         shift @section if $remove_heading;
205              
206             pop @section
207 0   0       while @section and $section[-1] =~ /^\s*$/;
208             shift @section
209 0   0       while @section and $section[0] =~ /^\s*$/;
210             };
211              
212 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
213 0           return join "", @section;
214             }
215              
216             sub regen_EXAMPLES {
217 0     0     my $perl = $^X;
218 0 0         if ($perl =~/\s/) {
219 0           $perl = qq{"$perl"};
220             };
221 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
222 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
223 0 0         if ($examples) {
224 0           warn "(Re)Creating $example_file\n";
225 0           $examples =~ s/\r\n/\n/g;
226 0           update_file( $example_file, $examples );
227             };
228             };
229              
230             sub update_file {
231 0     0     my( $filename, $new_content ) = @_;
232 0           my $content;
233 0 0         if( -f $filename ) {
234 0 0         open my $fh, '<:raw:encoding(UTF-8)', $filename
235             or die "Couldn't read '$filename': $!";
236 0           local $/;
237 0           $content = <$fh>;
238             };
239              
240 0 0         if( $content ne $new_content ) {
241 0 0         if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
242 0           print $fh $new_content;
243             } else {
244 0           warn "Couldn't (re)write '$filename': $!";
245             };
246             };
247             }