File Coverage

Makefile.PL
Criterion Covered Total %
statement 13 80 16.2
branch 1 50 2.0
condition 0 12 0.0
subroutine 5 10 50.0
pod n/a
total 19 152 12.5


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