File Coverage

Makefile.PL
Criterion Covered Total %
statement 7 72 9.7
branch 0 48 0.0
condition 0 12 0.0
subroutine 3 8 37.5
pod n/a
total 10 140 7.1


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