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