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   291460 use strict;
  1         2  
  1         51  
4 1     1   904 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         118156  
  1         2255  
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 = 'RecentInfo::Manager';
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 @windows_prereqs;
21             if( $^O =~ /cygwin|MSWin32/ ) {
22             @windows_prereqs = (
23             'Win32API::RecentFiles' => '0.01',
24             'Win32::Shortcut' => '0.01',
25             );
26             }
27              
28             my %module = (
29             NAME => $module,
30             AUTHOR => q{Max Maischein },
31             VERSION_FROM => $main_file,
32             ABSTRACT_FROM => $main_file,
33             META_MERGE => {
34             "meta-spec" => { version => 2 },
35             resources => {
36             repository => {
37             web => "https://github.com/Corion/$distlink",
38             url => "git://github.com/Corion/$distlink.git",
39             type => 'git',
40             },
41             bugtracker => {
42             web => "https://github.com/Corion/$distbase/issues",
43             # mailto => 'meta-bugs@example.com',
44             },
45             license => "https://dev.perl.org/licenses/",
46             },
47             dynamic_config => 1, # we have dynamic prerequisites
48             x_static_install => 1, # we are pure Perl and don't do anything fancy, we can be installed by copying files
49             },
50              
51             MIN_PERL_VERSION => '5.020', # I use signatures
52              
53             'LICENSE'=> 'artistic_2',
54              
55             PL_FILES => {},
56             EXE_FILES => [glob('scripts/*')],
57             BUILD_REQUIRES => {
58             'ExtUtils::MakeMaker' => 0,
59             },
60              
61             PREREQ_PM => {
62             'experimental' => '0.032',
63             'stable' => '0.032', # same as experimental.pm, but my tets infrastructure wants it explicitly
64             'Exporter' => 5, # for 'import'
65             'PerlX::Maybe' => 0,
66             'Carp' => 0,
67             'File::Basename' => 0,
68             'File::Spec' => 0,
69             'List::Util' => 0,
70             'MIME::Detect' => 0,
71             'Module::Load' => 0,
72             'Moo' => 2,
73             'XML::LibXML' => 0, # for XBEL parsing
74             'XML::LibXML::PrettyPrint' => 0, # for XBEL parsing
75             'IO::AtomicFile' => 0, # for XBEL writing
76             'Date::Format::ISO8601' => 0,
77             'URI::file' => 0,
78              
79             @windows_prereqs,
80             },
81             TEST_REQUIRES => {
82             'Test2::V0' => 0,
83             'Try::Tiny' => 0,
84             },
85              
86             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
87             clean => { FILES => "$distbase-*" },
88              
89             test => { TESTS => join( ' ', @tests ) },
90             );
91              
92             # This is so that we can do
93             # require 'Makefile.PL'
94             # and then call get_module_info
95              
96 1     1   17 sub get_module_info { %module }
97              
98             if( ! caller ) {
99             # I should maybe use something like Shipwright...
100             my $mm = WriteMakefile1(get_module_info);
101             my $version = $mm->parse_version($main_file);
102             regen_README($main_file, $version);
103             regen_EXAMPLES() if -d 'examples';
104             };
105              
106             1;
107              
108             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
109 0     0     my %params=@_;
110 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
111 0           $eumm_version=eval $eumm_version;
112 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
113 0 0         die "License not specified" if not exists $params{LICENSE};
114 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
115             #EUMM 6.5502 has problems with BUILD_REQUIRES
116 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
117 0           delete $params{BUILD_REQUIRES};
118             }
119 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
120 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
121 0           delete $params{TEST_REQUIRES};
122             }
123 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
124 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
125 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
126 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
127 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
128 0 0         delete $params{AUTHOR} if $] < 5.005;
129 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
130 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
131              
132 0           WriteMakefile(%params);
133             }
134              
135             sub regen_README {
136             # README is the short version that just tells people what this is
137             # and how to install it
138 0     0     my( $file, $version ) = @_;
139 0           eval {
140             # Get description
141 0           my $readme = join "\n",
142             pod_section($file, 'NAME', 'no heading' ),
143             pod_section($file, 'DESCRIPTION' ),
144             <
145             This document describes version $version.
146             VERSION
147             <
148              
149             INSTALLATION
150              
151             This is a Perl module distribution. It should be installed with whichever
152             tool you use to manage your installation of Perl, e.g. any of
153              
154             cpanm .
155             cpan .
156             cpanp -i .
157              
158             Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
159             Should you wish to install this module manually, the procedure is
160              
161             perl Makefile.PL
162             make
163             make test
164             make install
165              
166             INSTALL
167             pod_section($file, 'REPOSITORY'),
168             pod_section($file, 'SUPPORT'),
169             pod_section($file, 'TALKS'),
170             pod_section($file, 'KNOWN ISSUES'),
171             pod_section($file, 'BUG TRACKER'),
172             pod_section($file, 'CONTRIBUTING'),
173             pod_section($file, 'SEE ALSO'),
174             pod_section($file, 'AUTHOR'),
175             pod_section($file, 'LICENSE' ),
176             pod_section($file, 'COPYRIGHT' ),
177             ;
178 0           update_file( 'README', $readme );
179             };
180             # README.mkdn is the documentation that will be shown as the main
181             # page of the repository on Github. Hence we recreate the POD here
182             # as Markdown
183 0           eval {
184 0           require Pod::Markdown;
185              
186 0           my $parser = Pod::Markdown->new();
187              
188             # Read POD from Module.pm and write to README
189 0           $parser->parse_from_file($_[0]);
190 0           my $readme_mkdn = <as_markdown;
191              
192             [![Windows](https://github.com/Corion/$distbase/workflows/windows/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Awindows)
193             [![MacOS](https://github.com/Corion/$distbase/workflows/macos/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Amacos)
194             [![Linux](https://github.com/Corion/$distbase/workflows/linux/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Alinux)
195              
196             STATUS
197 0           update_file( 'README.mkdn', $readme_mkdn );
198             };
199             }
200              
201             sub pod_section {
202 0     0     my( $filename, $section, $remove_heading ) = @_;
203 0 0         open my $fh, '<', $filename
204             or die "Couldn't read '$filename': $!";
205              
206             my @section =
207 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
208              
209             # Trim the section
210 0 0         if( @section ) {
211 0 0         pop @section if $section[-1] =~ /^=/;
212 0 0         shift @section if $remove_heading;
213              
214             pop @section
215 0   0       while @section and $section[-1] =~ /^\s*$/;
216             shift @section
217 0   0       while @section and $section[0] =~ /^\s*$/;
218             };
219              
220 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
221 0           return join "", @section;
222             }
223              
224             sub regen_EXAMPLES {
225 0     0     my $perl = $^X;
226 0 0         if ($perl =~/\s/) {
227 0           $perl = qq{"$perl"};
228             };
229 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
230 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
231 0 0         if ($examples) {
232 0           warn "(Re)Creating $example_file\n";
233 0           $examples =~ s/\r\n/\n/g;
234 0           update_file( $example_file, $examples );
235             };
236             };
237              
238             sub update_file {
239 0     0     my( $filename, $new_content ) = @_;
240 0           my $content;
241 0 0         if( -f $filename ) {
242 0 0         open my $fh, '<:raw:encoding(UTF-8)', $filename
243             or die "Couldn't read '$filename': $!";
244 0           local $/;
245 0           $content = <$fh>;
246             };
247              
248 0 0         if( $content ne $new_content ) {
249 0 0         if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
250 0           print $fh $new_content;
251             } else {
252 0           warn "Couldn't (re)write '$filename': $!";
253             };
254             };
255             }