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   376394 use strict;
  1         3  
  1         53  
4 1     1   962 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         125450  
  1         1274  
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 = 'Mojo::File::ChangeNotify';
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             # 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'=> 'artistic_2',
46              
47             PL_FILES => {},
48             BUILD_REQUIRES => { 'ExtUtils::MakeMaker' => 0 },
49              
50             PREREQ_PM => {
51             'experimental' => '0',
52             'feature' => '0',
53             'Exporter' => '5',
54             'File::ChangeNotify' => '0',
55             'Mojo::Base' => '0',
56             'Mojo::EventEmitter' => '0',
57             'Mojo::IOLoop::Subprocess' => '0',
58             'Scalar::Util' => '0'
59             },
60             TEST_REQUIRES => {
61             'experimental' => '0',
62             'File::Copy' => '0',
63             'File::Path' => '0',
64             'File::Spec' => '0',
65             'File::Temp' => '0',
66             'Mojo::Promise' => '0',
67             'Scalar::Util' => '0',
68             'Test2::V0' => '0',
69             'Test::More' => '0'
70             },
71              
72             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
73             clean => { FILES => "$distbase-*" },
74              
75             test => { TESTS => join( ' ', @tests ) },
76             );
77              
78             # This is so that we can do
79             # require 'Makefile.PL'
80             # and then call get_module_info
81              
82 1     1   12 sub get_module_info { %module }
83              
84             if( ! caller ) {
85             # I should maybe use something like Shipwright...
86             my $mm = WriteMakefile1(get_module_info);
87             my $version = $mm->parse_version($main_file);
88             regen_README($main_file, $version);
89             regen_EXAMPLES() if -d 'examples';
90             };
91              
92             1;
93              
94             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
95 0     0     my %params=@_;
96 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
97 0           $eumm_version=eval $eumm_version;
98 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
99 0 0         die "License not specified" if not exists $params{LICENSE};
100 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
101             #EUMM 6.5502 has problems with BUILD_REQUIRES
102 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
103 0           delete $params{BUILD_REQUIRES};
104             }
105 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
106 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
107 0           delete $params{TEST_REQUIRES};
108             }
109 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
110 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
111 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
112 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
113 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
114 0 0         delete $params{AUTHOR} if $] < 5.005;
115 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
116 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
117              
118 0           WriteMakefile(%params);
119             }
120              
121             sub regen_README {
122             # README is the short version that just tells people what this is
123             # and how to install it
124 0     0     my( $file, $version ) = @_;
125 0           eval {
126             # Get description
127 0           my $readme = join "\n",
128             pod_section($file, 'NAME', 'no heading' ),
129             pod_section($file, 'DESCRIPTION' ),
130             <
131             This document describes version $version.
132             VERSION
133             <
134              
135             INSTALLATION
136              
137             This is a Perl module distribution. It should be installed with whichever
138             tool you use to manage your installation of Perl, e.g. any of
139              
140             cpanm .
141             cpan .
142             cpanp -i .
143              
144             Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
145             Should you wish to install this module manually, the procedure is
146              
147             perl Makefile.PL
148             make
149             make test
150             make install
151              
152             INSTALL
153             pod_section($file, 'REPOSITORY'),
154             pod_section($file, 'SUPPORT'),
155             pod_section($file, 'TALKS'),
156             pod_section($file, 'KNOWN ISSUES'),
157             pod_section($file, 'BUG TRACKER'),
158             pod_section($file, 'CONTRIBUTING'),
159             pod_section($file, 'SEE ALSO'),
160             pod_section($file, 'AUTHOR'),
161             pod_section($file, 'LICENSE' ),
162             pod_section($file, 'COPYRIGHT' ),
163             ;
164 0           update_file( 'README', $readme );
165             };
166             # README.mkdn is the documentation that will be shown as the main
167             # page of the repository on Github. Hence we recreate the POD here
168             # as Markdown
169 0           eval {
170 0           require Pod::Markdown;
171              
172 0           my $parser = Pod::Markdown->new();
173              
174             # Read POD from Module.pm and write to README
175 0           $parser->parse_from_file($_[0]);
176 0           my $readme_mkdn = <as_markdown;
177              
178             [![Windows](https://github.com/Corion/$distbase/workflows/windows/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Awindows)
179             [![MacOS](https://github.com/Corion/$distbase/workflows/macos/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Amacos)
180             [![Linux](https://github.com/Corion/$distbase/workflows/linux/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Alinux)
181              
182             STATUS
183 0           update_file( 'README.mkdn', $readme_mkdn );
184             };
185             }
186              
187             sub pod_section {
188 0     0     my( $filename, $section, $remove_heading ) = @_;
189 0 0         open my $fh, '<', $filename
190             or die "Couldn't read '$filename': $!";
191              
192             my @section =
193 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
194              
195             # Trim the section
196 0 0         if( @section ) {
197 0 0         pop @section if $section[-1] =~ /^=/;
198 0 0         shift @section if $remove_heading;
199              
200             pop @section
201 0   0       while @section and $section[-1] =~ /^\s*$/;
202             shift @section
203 0   0       while @section and $section[0] =~ /^\s*$/;
204             };
205              
206 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
207 0           return join "", @section;
208             }
209              
210             sub regen_EXAMPLES {
211 0     0     my $perl = $^X;
212 0 0         if ($perl =~/\s/) {
213 0           $perl = qq{"$perl"};
214             };
215 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
216 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
217 0 0         if ($examples) {
218 0           warn "(Re)Creating $example_file\n";
219 0           $examples =~ s/\r\n/\n/g;
220 0           update_file( $example_file, $examples );
221             };
222             };
223              
224             sub update_file {
225 0     0     my( $filename, $new_content ) = @_;
226 0           my $content;
227 0 0         if( -f $filename ) {
228 0 0         open my $fh, '<:raw:encoding(UTF-8)', $filename
229             or die "Couldn't read '$filename': $!";
230 0           local $/;
231 0           $content = <$fh>;
232             };
233              
234 0 0         if( $content ne $new_content ) {
235 0 0         if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
236 0           print $fh $new_content;
237             } else {
238 0           warn "Couldn't (re)write '$filename': $!";
239             };
240             };
241             }