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   270249 use strict;
  1         3  
  1         51  
4 1     1   902 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         119915  
  1         1792  
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 = 'Archive::SevenZip';
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             },
36             license => "https://dev.perl.org/licenses/",
37             },
38             dynamic_config => 0, # we promise to keep META.* up-to-date
39             x_static_install => 1, # we are pure Perl and don't do anything fancy
40             },
41              
42             MIN_PERL_VERSION => '5.006', # I use // in some places
43              
44             'LICENSE'=> 'perl',
45              
46             PL_FILES => {},
47             BUILD_REQUIRES => {
48             'ExtUtils::MakeMaker' => 0,
49             },
50              
51             PREREQ_PM => {
52             'File::Spec' => 0, # some tests do, at least
53             'Exporter' => 5, # for 'import'
54             'File::Temp' => 0,
55             'File::Copy' => 0,
56             'IPC::Open3' => 0, # for talking to 7zip
57             'Path::Class' => 0,
58             'Encode' => 0,
59             'File::Basename' => 0,
60             'Time::Piece' => 0,
61             'Archive::Zip' => 0,
62             'Archive::Zip::Member' => 0,
63             },
64             TEST_REQUIRES => {
65             'Test::More' => '1.001002', # a random version to allow done_testing()
66             'Data::Dumper' => 0, # it's core, but still, why not be explicit
67             },
68              
69              
70             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
71             clean => { FILES => "$distbase-*" },
72              
73             test => { TESTS => join( ' ', @tests ) },
74             );
75              
76             # This is so that we can do
77             # require 'Makefile.PL'
78             # and then call get_module_info
79              
80 1     1   18 sub get_module_info { %module }
81              
82             if( ! caller ) {
83             # I should maybe use something like Shipwright...
84             regen_README($main_file);
85             regen_EXAMPLES() if -d 'examples';
86             WriteMakefile1(get_module_info);
87             };
88              
89             1;
90              
91             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
92 0     0     my %params=@_;
93 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
94 0           $eumm_version=eval $eumm_version;
95 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
96 0 0         die "License not specified" if not exists $params{LICENSE};
97 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
98             #EUMM 6.5502 has problems with BUILD_REQUIRES
99 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
100 0           delete $params{BUILD_REQUIRES};
101             }
102 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
103 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
104 0           delete $params{TEST_REQUIRES};
105             }
106 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
107 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
108 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
109 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
110 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
111 0 0         delete $params{AUTHOR} if $] < 5.005;
112 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
113 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
114              
115 0           WriteMakefile(%params);
116             }
117              
118             sub regen_README {
119             # README is the short version that just tells people what this is
120             # and how to install it
121 0     0     eval {
122             # Get description
123 0           my $readme = join "\n",
124             pod_section($_[0], 'NAME', 'no heading' ),
125             pod_section($_[0], 'DESCRIPTION' ),
126             <
127              
128             INSTALLATION
129              
130             This is a Perl module distribution. It should be installed with whichever
131             tool you use to manage your installation of Perl, e.g. any of
132              
133             cpanm .
134             cpan .
135             cpanp -i .
136              
137             Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
138             Should you wish to install this module manually, the procedure is
139              
140             perl Makefile.PL
141             make
142             make test
143             make install
144              
145             INSTALL
146             pod_section($_[0], 'REPOSITORY'),
147             pod_section($_[0], 'SUPPORT'),
148             pod_section($_[0], 'TALKS'),
149             pod_section($_[0], 'KNOWN ISSUES'),
150             pod_section($_[0], 'BUG TRACKER'),
151             pod_section($_[0], 'CONTRIBUTING'),
152             pod_section($_[0], 'SEE ALSO'),
153             pod_section($_[0], 'AUTHOR'),
154             pod_section($_[0], 'LICENSE' ),
155             pod_section($_[0], 'COPYRIGHT' ),
156             ;
157 0           update_file( 'README', $readme );
158             };
159             # README.mkdn is the documentation that will be shown as the main
160             # page of the repository on Github. Hence we recreate the POD here
161             # as Markdown
162 0           eval {
163 0           require Pod::Markdown;
164              
165 0           my $parser = Pod::Markdown->new();
166              
167             # Read POD from Module.pm and write to README
168 0           $parser->parse_from_file($_[0]);
169 0           my $readme_mkdn = <as_markdown;
170              
171             [![Travis Build Status](https://travis-ci.org/Corion/$distlink.svg?branch=master)](https://travis-ci.org/Corion/$distlink)
172             [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/$distlink?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/$distlink)
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             }