File Coverage

blib/lib/Dist/Mgr/FileData.pm
Criterion Covered Total %
statement 43 43 100.0
branch 6 8 75.0
condition 6 6 100.0
subroutine 15 16 93.7
pod n/a
total 70 73 95.8


line stmt bran cond sub pod time code
1             package Dist::Mgr::FileData;
2              
3 25     25   167 use warnings;
  25         44  
  25         795  
4 25     25   113 use strict;
  25         45  
  25         800  
5              
6             our $VERSION = '1.13';
7              
8 25     25   119 use Exporter qw(import);
  25         46  
  25         29392  
9             our @ISA = qw(Exporter);
10             our @EXPORT_OK = qw(
11             _changes_file
12              
13             _ci_github_file
14              
15             _config_file
16              
17             _git_ignore_file
18              
19             _module_section_ci_badges
20             _module_template_file
21              
22             _makefile_section_meta_merge
23             _makefile_section_bugtracker
24             _makefile_section_repo
25              
26             _manifest_skip_file
27             _manifest_t_file
28              
29             _unwanted_filesystem_entries
30             );
31             our %EXPORT_TAGS = (all => \@EXPORT_OK);
32              
33             sub _changes_file {
34 2     2   18 my ($module) = @_;
35              
36 2 50       11 die "_changes_file() needs module param" if ! defined $module;
37              
38 2         16 $module =~ s/::/-/g;
39              
40             return (
41 2         13 qq{Revision history for $module},
42             qq{},
43             qq{0.01 UNREL},
44             qq{ - Auto generated distribution with Dist::Mgr},
45             );
46             }
47              
48             sub _ci_github_file {
49 6     6   16 my ($os) = @_;
50              
51 6 100       15 if (! defined $os) {
52 2         11 $os = [qw(l w m)];
53             }
54              
55 6         36 my %os_matrix_map = (
56             l => qq{ubuntu-latest},
57             w => qq{windows-latest},
58             m => qq{macos-latest},
59             );
60              
61 6         30 my $os_matrix = "[ ";
62 6         15 $os_matrix .= join(', ', map { $os_matrix_map{$_} } @$os);
  12         33  
63 6         18 $os_matrix .= " ]";
64              
65             return (
66 6         60 qq{name: CI},
67             qq{on:},
68             qq{ push:},
69             qq{ branches: [ main ]},
70             qq{ pull_request:},
71             qq{ branches: [ main ]},
72             qq{ workflow_dispatch:},
73             qq{jobs:},
74             qq{ build:},
75             qq{ runs-on: \${{ matrix.os }}},
76             qq{ strategy:},
77             qq{ matrix:},
78             qq{ os: $os_matrix},
79             qq{ perl: [ '5.34', '5.32', '5.28', '5.24', '5.18', '5.14' ]},
80             qq{ include:},
81             qq{ - perl: '5.32'},
82             qq{ os: ubuntu-latest},
83             qq{ coverage: true},
84             qq{ name: Perl \${{ matrix.perl }} on \${{ matrix.os }}},
85             qq{ steps:},
86             qq{ - uses: actions/checkout\@v3},
87             qq{ - name: Set up perl},
88             qq{ uses: shogo82148/actions-setup-perl\@v1},
89             qq{ with:},
90             qq{ perl-version: \${{ matrix.perl }}},
91             qq{ - name: Perl version},
92             qq{ run: perl -V},
93             qq{ - name: Set up Windows},
94             qq{ if: matrix.os != 'windows-latest'},
95             qq{ run: cpanm ExtUtils::PL2Bat},
96             qq{ - name: Install prereqs},
97             qq{ run: |},
98             qq{ cpanm ExtUtils::MakeMaker},
99             qq{ cpanm --installdeps .},
100             qq{ - name: Run tests (no coverage)},
101             qq{ if: \${{ !matrix.coverage }}},
102             qq{ run: prove -lv t},
103             qq{ - name: Run tests (with coverage)},
104             qq{ if: \${{ matrix.coverage }}},
105             qq{ env:},
106             qq{ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}},
107             qq{ run: |},
108             qq{ cpanm -n Devel::Cover::Report::Coveralls},
109             qq{ cover -test -report Coveralls},
110             );
111             }
112              
113             sub _config_file {
114             return {
115 4     4   25 cpan_id => '',
116             cpan_pw => '',
117             };
118             }
119              
120             sub _git_ignore_file {
121             return (
122 2     2   25 q{Makefile},
123             q{*~},
124             q{*.bak},
125             q{*.swp},
126             q{*.bak},
127             q{.hg/},
128             q{.git/},
129             q{MYMETA.*},
130             q{*.tar.gz},
131             q{_build/},
132             q{blib/},
133             q{Build/},
134             q{META.json},
135             q{META.yml},
136             q{*.old},
137             q{*.orig},
138             q{pm_to_blib},
139             q{.metadata/},
140             q{.idea/},
141             q{*.debug},
142             q{*.iml},
143             q{*.bblog},
144             q{BB-Pass/},
145             q{BB-Fail/},
146             );
147             }
148              
149             sub _module_section_ci_badges {
150 3     3   10 my ($author, $repo) = @_;
151              
152             return (
153 3         54 qq{},
154             qq{=for html},
155             qq{},
156             qq{Coverage Status},
157             qq{},
158             );
159             }
160             sub _module_template_file {
161 6     6   26 my ($module, $author, $email) = @_;
162              
163 6 100 100     69 if (! defined $module || ! defined $author || ! defined $email) {
      100        
164 3         27 die "_module_template_file() requires 'module', 'author' and 'email' parameters";
165             }
166              
167 3         14 my ($email_user, $email_domain);
168              
169 3 50       45 if ($email =~ /(.*)\@(.*)/) {
170 3         13 $email_user = $1;
171 3         7 $email_domain = $2;
172             }
173              
174 3         81 my $year = (localtime)[5] + 1900;
175              
176             return (
177 3         96 qq{package $module;},
178             qq{},
179             qq{use strict;},
180             qq{use warnings;},
181             qq{},
182             qq{our \$VERSION = '0.01';},
183             qq{},
184             qq{sub __placeholder {}},
185             qq{},
186             qq{1;},
187             qq{__END__},
188             qq{},
189             qq{=head1 NAME},
190             qq{},
191             qq{$module - One line description},
192             qq{},
193             qq{=head1 SYNOPSIS},
194             qq{},
195             qq{=head1 DESCRIPTION},
196             qq{},
197             qq{=head1 METHODS},
198             qq{},
199             qq{=head2 name},
200             qq{},
201             qq{Description.},
202             qq{},
203             qq{I:},
204             qq{},
205             qq{ \$bar},
206             qq{},
207             qq{I: The name of the thing with the guy and the place.},
208             qq{},
209             qq{I: C<0> upon success.},
210             qq{},
211             qq{=head1 AUTHOR},
212             qq{},
213             qq{$author, C<< <$email_user at $email_domain> >>},
214             qq{},
215             qq{=head1 LICENSE AND COPYRIGHT},
216             qq{},
217             qq{Copyright $year $author.},
218             qq{},
219             qq{This program is free software; you can redistribute it and/or modify it},
220             qq{under the terms of the the Artistic License (2.0). You may obtain a},
221             qq{copy of the full license at:},
222             qq{},
223             qq{L},
224             );
225             }
226              
227             sub _makefile_section_meta_merge {
228             return (
229 4     4   39 " META_MERGE => {",
230             " 'meta-spec' => { version => 2 },",
231             " resources => {",
232             " },",
233             " },"
234             );
235             }
236             sub _makefile_section_bugtracker {
237 3     3   11 my ($author, $repo) = @_;
238              
239             return (
240 3         26 " bugtracker => {",
241             " web => 'https://github.com/$author/$repo/issues',",
242             " },"
243             );
244              
245             }
246             sub _makefile_section_repo {
247 3     3   22 my ($author, $repo) = @_;
248              
249             return (
250 3         34 " repository => {",
251             " type => 'git',",
252             " url => 'https://github.com/$author/$repo.git',",
253             " web => 'https://github.com/$author/$repo',",
254             " },"
255             );
256              
257             }
258              
259             sub _manifest_skip_file {
260             return (
261 2     2   34 q{~$},
262             q{^blib/},
263             q{^pm_to_blib/},
264             q{.old$},
265             q{.orig$},
266             q{.tar.gz$},
267             q{.bak$},
268             q{.swp$},
269             q{^test/},
270             q{.hg/},
271             q{.hgignore$},
272             q{^_build/},
273             q{^Build$},
274             q{^MYMETA\.yml$},
275             q{^MYMETA\.json$},
276             q{^README.bak$},
277             q{^Makefile$},
278             q{.metadata/},
279             q{.idea/},
280             q{pm_to_blib$},
281             q{.git/},
282             q{.debug$},
283             q{.gitignore$},
284             q{^\w+.pl$},
285             q{.ignore.txt$},
286             q{.travis.yml$},
287             q{.iml$},
288             q{examples/},
289             q{build/},
290             q{^\w+.list$},
291             q{.bblog$},
292             q{.base$},
293             q{BB-Pass/},
294             q{BB-Fail/},
295             q{cover_db/},
296             q{scrap\.pl},
297             q{^\.github/}
298             );
299             }
300             sub _manifest_t_file {
301             return (
302 2     2   23 q|use warnings;|,
303             q|use strict;|,
304             q||,
305             q|use Test::More;|,
306             q|use ExtUtils::Manifest;|,
307             q||,
308             q|if (! $ENV{RELEASE_TESTING}) {|,
309             q| plan skip_all => "Author tests not required for installation";|,
310             q|}|,
311             q||,
312             q|is_deeply [ ExtUtils::Manifest::manicheck() ], [], 'missing';|,
313             q|is_deeply [ ExtUtils::Manifest::filecheck() ], [], 'extra';|,
314             q||,
315             q|done_testing;|,
316             );
317             }
318              
319             sub _unwanted_filesystem_entries {
320 3     3   95 return qw(
321             xt/
322             ignore.txt
323             README
324             MANIFEST
325             );
326             }
327              
328       0     sub __placeholder {}
329              
330             1;
331             __END__