File Coverage

blib/lib/Dist/Zilla/PluginBundle/PERLSRVDE.pm
Criterion Covered Total %
statement 83 128 64.8
branch 0 32 0.0
condition 0 8 0.0
subroutine 28 30 93.3
pod 0 1 0.0
total 111 199 55.7


line stmt bran cond sub pod time code
1             package Dist::Zilla::PluginBundle::PERLSRVDE;
2              
3 1     1   812 use v5.24;
  1         4  
4              
5             # ABSTRACT: The plugin bundle we use at Perl-Services.de
6              
7 1     1   5 use strict;
  1         3  
  1         19  
8 1     1   5 use warnings;
  1         2  
  1         38  
9              
10             our $VERSION = '1.1.0'; # VERSION
11              
12 1     1   463 use namespace::autoclean;
  1         18244  
  1         3  
13              
14 1     1   692 use Dist::Zilla 6.0;
  1         1764686  
  1         60  
15              
16 1     1   659 use Dist::Zilla::PluginBundle::Git;
  1         630968  
  1         45  
17 1     1   612 use Dist::Zilla::PluginBundle::Basic;
  1         65515  
  1         36  
18 1     1   572 use Dist::Zilla::PluginBundle::Filter ();
  1         13834  
  1         31  
19              
20 1     1   493 use Dist::Zilla::Plugin::ContributorsFile;
  1         244342  
  1         43  
21 1     1   492 use Dist::Zilla::Plugin::CheckChangesHasContent;
  1         68640  
  1         49  
22 1     1   602 use Dist::Zilla::Plugin::NextRelease;
  1         92639  
  1         49  
23 1     1   573 use Dist::Zilla::Plugin::SyncCPANfile;
  1         42818  
  1         44  
24 1     1   512 use Dist::Zilla::Plugin::OurPkgVersion;
  1         307428  
  1         44  
25 1     1   562 use Dist::Zilla::Plugin::PodWeaver;
  1         1108562  
  1         45  
26 1     1   641 use Dist::Zilla::Plugin::Git::Contributors;
  1         158040  
  1         49  
27 1     1   700 use Dist::Zilla::Plugin::PodSyntaxTests;
  1         65583  
  1         56  
28 1     1   643 use Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable;
  1         65619  
  1         45  
29 1     1   592 use Dist::Zilla::Plugin::Test::NoTabs;
  1         85676  
  1         46  
30 1     1   654 use Dist::Zilla::Plugin::Test::NoBOM;
  1         109727  
  1         52  
31 1     1   688 use Dist::Zilla::Plugin::Test::Perl::Critic;
  1         72626  
  1         55  
32 1     1   772 use Dist::Zilla::Plugin::ExecDir;
  1         58828  
  1         49  
33 1     1   651 use Dist::Zilla::Plugin::MetaJSON;
  1         45701  
  1         38  
34 1     1   530 use Dist::Zilla::Plugin::MetaProvides::Package;
  1         367963  
  1         56  
35 1     1   685 use Dist::Zilla::Plugin::ReadmeAnyFromPod;
  1         110931  
  1         48  
36 1     1   634 use Dist::Zilla::Plugin::ReadmeAddDevInfo;
  1         54845  
  1         53  
37 1     1   654 use Dist::Zilla::Plugin::GitHubREADME::Badge;
  1         56096  
  1         56  
38 1     1   669 use Dist::Zilla::Plugin::MetaResources;
  1         34996  
  1         39  
39              
40 1     1   9 use Moose;
  1         4  
  1         9  
41              
42             with qw(
43             Dist::Zilla::Role::PluginBundle::Easy
44             Dist::Zilla::Role::PluginBundle::Config::Slicer
45             Dist::Zilla::Role::PluginBundle::PluginRemover
46             );
47              
48             has 'is_cpan' => (
49             is => 'ro',
50             isa => 'Bool',
51             lazy => 1,
52             default => sub {
53             my $pl = $_[0]->payload;
54             exists $pl->{is_cpan} ? $pl->{is_cpan} : 0;
55             },
56             );
57              
58             has 'repository_type' => (
59             is => 'ro',
60             isa => 'Str',
61             lazy => 1,
62             default => sub {
63             my $pl = $_[0]->payload;
64             exists $pl->{repository_type} ? $pl->{repository_type} : 'github';
65             },
66             );
67              
68             has 'repository_path' => (
69             is => 'ro',
70             isa => 'Str',
71             lazy => 1,
72             default => sub {
73             my $pl = $_[0]->payload;
74             exists $pl->{repository_path} ? $pl->{repository_path} : '';
75             },
76             );
77              
78             has 'internal_type' => (
79             is => 'ro',
80             isa => 'Str',
81             lazy => 1,
82             default => sub {
83             my $pl = $_[0]->payload;
84             exists $pl->{internal_type} ? $pl->{internal_type} : 'git';
85             },
86             );
87              
88             has 'internal_url' => (
89             is => 'ro',
90             isa => 'Str',
91             lazy => 1,
92             default => sub {
93             my $pl = $_[0]->payload;
94             exists $pl->{internal_url} ? $pl->{internal_url} : '';
95             },
96             );
97              
98             has 'internal_web' => (
99             is => 'ro',
100             isa => 'Str',
101             lazy => 1,
102             default => sub {
103             my $pl = $_[0]->payload;
104             exists $pl->{internal_web} ? $pl->{internal_web} : '';
105             },
106             );
107              
108             has 'bugtracker' => (
109             is => 'ro',
110             isa => 'Str',
111             lazy => 1,
112             default => sub {
113             my $pl = $_[0]->payload;
114             exists $pl->{bugtracker} ? $pl->{bugtracker} : '';
115             },
116             );
117              
118             has 'pod_class' => (
119             is => 'ro',
120             isa => 'Str',
121             default => sub {
122             my $pl = $_[0]->payload;
123             exists $pl->{pod_class} ? $pl->{pod_class} : 'Pod::Coverage::TrustPod';
124             },
125             );
126              
127             has 'pod_skip' => (
128             is => 'ro',
129             isa => 'ArrayRef',
130             default => sub {
131             my $pl = $_[0]->payload;
132             exists $pl->{pod_skip} ?
133             ref $pl->{pod_skip} ? $pl->{pod_skip} : [ $pl->{pod_skip} ]
134             : [];
135             },
136             );
137              
138             has 'pod_trustme' => (
139             is => 'ro',
140             isa => 'ArrayRef',
141             default => sub {
142             my $pl = $_[0]->payload;
143             exists $pl->{pod_trustme} ?
144             ref $pl->{pod_trustme} ? $pl->{pod_trustme} : [ $pl->{pod_trustme} ]
145             : [];
146             },
147             );
148              
149             has 'pod_also_private' => (
150             is => 'ro',
151             isa => 'ArrayRef',
152             default => sub {
153             my $pl = $_[0]->payload;
154             exists $pl->{pod_also_private} ?
155             ref $pl->{pod_also_private} ? $pl->{pod_also_private} : [ $pl->{pod_also_private} ]
156             : [];
157             },
158             );
159              
160             has 'fake_release' => (
161             is => 'ro',
162             isa => 'Bool',
163             lazy => 1,
164             default => sub {
165             my $pl = $_[0]->payload;
166             if ( $pl->{is_cpan} ) {
167             $pl->{fake_release} = 0;
168             }
169             exists $pl->{fake_release} ? $pl->{fake_release} : 1;
170             },
171             );
172              
173             has exclude_from_basic => (
174             is => 'ro',
175             isa => 'ArrayRef[Str]',
176             lazy => 1,
177             default => sub {
178             my $pl = $_[0]->payload;
179             $pl->{exclude_from_basic};
180             },
181             );
182              
183             sub mvp_multivalue_args {
184             return qw( pod_skip pod_trustme pod_also_private exclude_from_basic );
185             }
186              
187             sub configure {
188 0     0 0   my ($self) = @_;
189              
190 0           my %remove_from_basic;
191 0 0         if ( $self->fake_release ) {
192 0           $remove_from_basic{UploadToCPAN}++;
193             }
194              
195 0 0         for my $exclude ( @{ $self->exclude_from_basic || [] } ) {
  0            
196 0           $remove_from_basic{$exclude}++;
197             }
198              
199 0           my %pod_coverage_opts;
200 0           for my $opt_name ( qw/class skip trustme also_private/ ) {
201 0           my $method = $self->can('pod_' . $opt_name);
202 0 0         next if !$method;
203              
204 0           my $value = $self->$method();
205 0 0         next if !$value;
206 0 0 0       next if ref $value && !@{ $value };
  0            
207              
208 0           $pod_coverage_opts{$opt_name} = $value;
209             }
210              
211             $self->add_plugins(
212             [
213 0           'ContributorsFile' => {
214             filename => 'CONTRIBUTORS',
215             },
216             ],
217             'CheckChangesHasContent',
218             [
219             'NextRelease' => {
220             format => '%-9v%T %{yyyy-MM-dd HH:mm:ss VVVV}d',
221             },
222             ],
223             qw/
224             SyncCPANfile
225             OurPkgVersion
226             PodWeaver
227             /,
228             [
229             'Git::Contributors' => {
230             include_authors => 1,
231             },
232             ],
233             [
234             'Test::Pod::Coverage::Configurable' => \%pod_coverage_opts,
235             ],
236             qw/
237             PodSyntaxTests
238              
239             Test::NoTabs
240             Test::NoBOM
241             Test::Perl::Critic
242              
243             MetaJSON
244             MetaProvides::Package
245              
246             ExecDir
247             /,
248             );
249              
250 0           $self->add_bundle(
251             '@Filter' => {
252             '-bundle' => '@Basic',
253             '-remove' => [ 'Readme', 'PodCoverageTest', sort keys %remove_from_basic ],
254             },
255             );
256              
257 0           $self->_meta_resources;
258 0           $self->add_bundle('@Git');
259              
260 0 0         if ( $self->is_cpan ) {
261 0           $self->add_plugins(
262             [
263             'ReadmeAnyFromPod' => 'GfmInRoot' => {
264             phase => 'build',
265             },
266             ],
267             [
268             'ReadmeAnyFromPod' => 'TextInBuild' => {
269             phase => 'build',
270             },
271             ],
272             [
273             'ReadmeAddDevInfo' => {
274             phase => 'build',
275             before => '# AUTHOR',
276             add_contribution_file => 1,
277             },
278             ],
279             [
280             'GitHubREADME::Badge' => {
281             badges => [ qw/cpants issues cpancover license/ ],
282             phase => 'build',
283             place => 'top',
284             },
285             ],
286             );
287             }
288             }
289              
290             sub _meta_resources {
291 0     0     my ($self) = @_;
292              
293 0           my %meta_resources;
294              
295 0 0         $meta_resources{'bugtracker.web'} = $self->bugtracker if $self->bugtracker;
296              
297 0           my $type = $self->repository_type;
298              
299 0 0 0       return if !$type && !%meta_resources;
300              
301 0           my $name = $self->repository_path;
302              
303 0 0         if ( $type eq 'github' ) {
    0          
    0          
304             $meta_resources{'homepage'} =
305 0           $meta_resources{'repository.web'} =
306             sprintf "https://github.com/%s",
307             $name
308             ;
309 0           $meta_resources{'repository.url'} =
310             sprintf "git://github.com/%s.git",
311             $name
312             ;
313 0           $meta_resources{'repository.type'} = 'git';
314              
315 0 0         if ( !$self->bugtracker ) {
316 0           $meta_resources{'bugtracker.web'} =
317             sprintf "https://github.com/%s/issues",
318             $name
319             ;
320             }
321             }
322             elsif ( $type eq 'gitlab' ) {
323             $meta_resources{'homepage'} =
324 0           $meta_resources{'repository.web'} =
325             sprintf "https://gitlab.com/%s",
326             $name
327             ;
328 0           $meta_resources{'repository.url'} =
329             sprintf "git://gitlab.com/%s.git",
330             $name
331             ;
332 0           $meta_resources{'repository.type'} = 'git';
333              
334 0 0         if ( !$self->bugtracker ) {
335 0           $meta_resources{'bugtracker.web'} =
336             sprintf "https://gitlab.com/%s/-/issues",
337             $name
338             ;
339             }
340             }
341             elsif ( $type eq 'internal' ) {
342             $meta_resources{'homepage'} =
343 0 0         $meta_resources{'repository.web'} =
344             $self->internal_web if $self->internal_web;
345 0 0         $meta_resources{'repository.url'} =
346             $self->internal_url if $self->internal_url;
347 0   0       $meta_resources{'repository.type'} =
348             $self->internal_type || 'git';
349             }
350              
351 0 0         return if !%meta_resources;
352              
353 0           $self->add_plugins(
354             [ 'MetaResources' => \%meta_resources ],
355             );
356              
357 0           return 1;
358             }
359              
360             __PACKAGE__->meta->make_immutable;
361              
362             1;
363              
364             __END__
365              
366             =pod
367              
368             =encoding UTF-8
369              
370             =head1 NAME
371              
372             Dist::Zilla::PluginBundle::PERLSRVDE - The plugin bundle we use at Perl-Services.de
373              
374             =head1 VERSION
375              
376             version 1.1.0
377              
378             =head1 SYNOPSIS
379              
380             ; in dist.ini
381             [@PERLSRVDE]
382              
383             Using L</Options>:
384              
385             ; in dist.ini
386             [@PERLSRVDE]
387             ; we are using an internal git repository
388             repository_type = internal
389             internal_type = git
390             internal_url = git://git.internal.example/test.git
391             internal_web = https://git.internal.example/test
392             ; but the bugtracker is an other tool
393             bugtracker = https://our.bugtracker.example
394             ; and it's a CPAN module, so we want to include more
395             ; dist::zilla plugins
396             is_cpan = 1
397             ; but we do not want to upload it ;-)
398             fake_release = 1
399              
400             =head1 DESCRIPTION
401              
402             This is a L<Dist::Zilla> PluginBundle. It lists the plugins we use at L<Perl-Services.de|https://perl-services.de>.
403             It is roughly equivalent to the following dist.ini:
404              
405             [ContributorsFile]
406             filename = CONTRIBUTORS
407            
408             [CheckChangesHasContent]
409            
410             [NextRelease]
411             format=%-9v%T %{yyyy-MM-dd HH:mm:ss VVVV}d
412            
413             [SyncCPANfile]
414             [PkgVersion]
415             [PodWeaver]
416            
417             [@Filter]
418             -bundle = @Basic
419             -remove = Readme
420             -remove = UploadToCPAN
421            
422             [Git::Contributors]
423             include_authors = 1
424            
425             [PodSyntaxTests]
426             [Test::Pod::Coverage::Configurable]
427             [Test::NoTabs]
428             [Test::NoBOM]
429             [Test::Perl::Critic]
430            
431             [MetaProvides::Package]
432             [MetaJSON]
433            
434             [ExecDir]
435            
436             [@Git]
437            
438             [PerlTidy]
439             perltidyrc = .perltidyrc
440              
441             =for Pod::Coverage configure
442              
443             =head1 OPTIONS
444              
445             These options can be used:
446              
447             =over 4
448              
449             =item * is_cpan
450              
451             =item * repository_type
452              
453             This is used to generate the links to the repository and bugtracker (if bugtracker isn't set).
454              
455             Valid values:
456              
457             =over 4
458              
459             =item * github
460              
461             If you host your project on github.com
462              
463             =item * gitlab
464              
465             If you host your project on gitlab.com
466              
467             =item * internal
468              
469             If you host your project somewhere else.
470              
471             =back
472              
473             =item * repository_path
474              
475             The path of the repository. For this project it is I<perlservices/Dist-Zilla-PERLSRVDE>. The path is used
476             to generate the links to the repository and bugtracker.
477              
478             =item * internal_type
479              
480             =item * internal_url
481              
482             =item * bugtracker
483              
484             =item * fake_release
485              
486             =item * exclude_from_basic
487              
488             List plugins that should be removed from the L<Dist::Zilla::PluginBundle::Basic|@Basic> plugin bundle.
489              
490             =back
491              
492             These options are used to configure L<Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable>:
493              
494             =over 4
495              
496             =item * pod_class
497              
498             (see L<Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable/class>)
499              
500             =item * pod_skip
501              
502             (see L<Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable/skip>)
503              
504             =item * pod_trustme
505              
506             (see L<Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable/trustme>)
507              
508             =item * pod_also_private
509              
510             (see L<Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable/also_private>)
511              
512             =back
513              
514             =head1 AUTHOR
515              
516             Renee Baecker <reneeb@cpan.org>
517              
518             =head1 COPYRIGHT AND LICENSE
519              
520             This software is Copyright (c) 2022 by Renee Baecker.
521              
522             This is free software, licensed under:
523              
524             The Artistic License 2.0 (GPL Compatible)
525              
526             =cut