File Coverage

Makefile.PL
Criterion Covered Total %
statement 7 74 9.4
branch 0 48 0.0
condition 0 6 0.0
subroutine 3 8 37.5
pod n/a
total 10 136 7.3


line stmt bran cond sub pod time code
1             # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2              
3 1     1   439 use strict;
  1         2  
  1         32  
4 1     1   875 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         113611  
  1         2493  
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             },
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.006', # I use // in some places
39              
40             'LICENSE'=> 'perl',
41              
42             PL_FILES => {},
43             BUILD_REQUIRES => {
44             'ExtUtils::MakeMaker' => 0,
45             },
46              
47             PREREQ_PM => {
48             'File::Spec' => 0, # some tests do, at least
49             'Exporter' => 5, # for 'import'
50             'File::Temp' => 0,
51             'File::Copy' => 0,
52             'IPC::Open3' => 0, # for talking to 7zip
53             'Path::Class' => 0,
54             'Encode' => 0,
55             'File::Basename' => 0,
56             'Time::Piece' => 0,
57             'Archive::Zip' => 0,
58             'Archive::Zip::Member' => 0,
59             },
60             TEST_REQUIRES => {
61             'Test::More' => '1.001002', # a random version to allow done_testing()
62             'Data::Dumper' => 0, # it's core, but still, why not be explicit
63             },
64              
65              
66             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
67             clean => { FILES => "$distbase-*" },
68              
69             test => { TESTS => join( ' ', @tests ) },
70             );
71              
72             # This is so that we can do
73             # require 'Makefile.PL'
74             # and then call get_module_info
75              
76 1     1   12 sub get_module_info { %module }
77              
78             if( ! caller ) {
79             # I should maybe use something like Shipwright...
80             regen_README($main_file);
81             regen_EXAMPLES() if -d 'examples';
82             WriteMakefile1(get_module_info);
83             };
84              
85             1;
86              
87             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
88 0     0     my %params=@_;
89 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
90 0           $eumm_version=eval $eumm_version;
91 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
92 0 0         die "License not specified" if not exists $params{LICENSE};
93 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
94             #EUMM 6.5502 has problems with BUILD_REQUIRES
95 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
96 0           delete $params{BUILD_REQUIRES};
97             }
98 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
99 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
100 0           delete $params{TEST_REQUIRES};
101             }
102 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
103 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
104 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
105 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
106 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
107 0 0         delete $params{AUTHOR} if $] < 5.005;
108 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
109 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
110              
111 0           WriteMakefile(%params);
112             }
113              
114             sub regen_README {
115             # README is the short version that just tells people what this is
116             # and how to install it
117 0     0     eval {
118             # Get description
119 0           my $readme = join "\n",
120             pod_section($_[0], 'NAME', 'no heading' ),
121             pod_section($_[0], 'DESCRIPTION' ),
122             <
123              
124             INSTALLATION
125              
126             This is a Perl module distribution. It should be installed with whichever
127             tool you use to manage your installation of Perl, e.g. any of
128              
129             cpanm .
130             cpan .
131             cpanp -i .
132              
133             Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
134             Should you wish to install this module manually, the procedure is
135              
136             perl Makefile.PL
137             make
138             make test
139             make install
140              
141             INSTALL
142             pod_section($_[0], 'REPOSITORY'),
143             pod_section($_[0], 'SUPPORT'),
144             pod_section($_[0], 'TALKS'),
145             pod_section($_[0], 'KNOWN ISSUES'),
146             pod_section($_[0], 'BUG TRACKER'),
147             pod_section($_[0], 'CONTRIBUTING'),
148             pod_section($_[0], 'SEE ALSO'),
149             pod_section($_[0], 'AUTHOR'),
150             pod_section($_[0], 'LICENSE' ),
151             pod_section($_[0], 'COPYRIGHT' ),
152             ;
153 0           update_file( 'README', $readme );
154             };
155             # README.mkdn is the documentation that will be shown as the main
156             # page of the repository on Github. Hence we recreate the POD here
157             # as Markdown
158 0           eval {
159 0           require Pod::Markdown;
160              
161 0           my $parser = Pod::Markdown->new();
162              
163             # Read POD from Module.pm and write to README
164 0           $parser->parse_from_file($_[0]);
165 0           my $readme_mkdn = <as_markdown;
166              
167             [![Travis Build Status](https://travis-ci.org/Corion/$distlink.svg?branch=master)](https://travis-ci.org/Corion/$distlink)
168             [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/$distlink?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/$distlink)
169              
170             STATUS
171 0           update_file( 'README.mkdn', $readme_mkdn );
172             };
173             }
174              
175             sub pod_section {
176 0     0     my( $filename, $section, $remove_heading ) = @_;
177 0 0         open my $fh, '<', $filename
178             or die "Couldn't read '$filename': $!";
179              
180             my @section =
181 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
182              
183             # Trim the section
184 0 0         if( @section ) {
185 0 0         pop @section if $section[-1] =~ /^=/;
186 0 0         shift @section if $remove_heading;
187              
188             pop @section
189 0           while $section[-1] =~ /^\s*$/;
190             shift @section
191 0           while $section[0] =~ /^\s*$/;
192             };
193              
194 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
195 0           return join "", @section;
196             }
197              
198             sub regen_EXAMPLES {
199 0     0     my $perl = $^X;
200 0 0         if ($perl =~/\s/) {
201 0           $perl = qq{"$perl"};
202             };
203 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
204 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
205 0 0         if ($examples) {
206 0           warn "(Re)Creating $example_file\n";
207 0           $examples =~ s/\r\n/\n/g;
208 0           update_file( $example_file, $examples );
209             };
210             };
211              
212             sub update_file {
213 0     0     my( $filename, $new_content ) = @_;
214 0           my $content;
215 0 0         if( -f $filename ) {
216 0 0         open my $fh, '<', $filename
217             or die "Couldn't read '$filename': $!";
218 0           binmode $fh;
219 0           local $/;
220 0           $content = <$fh>;
221             };
222              
223 0 0         if( $content ne $new_content ) {
224 0 0         if( open my $fh, '>', $filename ) {
225 0           binmode $fh;
226 0           print $fh $new_content;
227             } else {
228 0           warn "Couldn't (re)write '$filename': $!";
229             };
230             };
231             }