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