File Coverage

blib/lib/Dist/Zilla/PluginBundle/PERLSRVDE.pm
Criterion Covered Total %
statement 83 116 71.5
branch 0 24 0.0
condition 0 5 0.0
subroutine 28 30 93.3
pod 0 1 0.0
total 111 176 63.0


line stmt bran cond sub pod time code
1              
2             use v5.24;
3 1     1   637  
  1         3  
4             # ABSTRACT: The plugin bundle we use at Perl-Services.de
5              
6             use strict;
7 1     1   5 use warnings;
  1         1  
  1         16  
8 1     1   4  
  1         1  
  1         31  
9             our $VERSION = '1.0.1'; # VERSION
10              
11             use namespace::autoclean;
12 1     1   1235  
  1         23819  
  1         5  
13             use Dist::Zilla 6.0;
14 1     1   901  
  1         1521985  
  1         47  
15             use Dist::Zilla::PluginBundle::Git;
16 1     1   485 use Dist::Zilla::PluginBundle::Basic;
  1         510937  
  1         32  
17 1     1   459 use Dist::Zilla::PluginBundle::Filter ();
  1         53197  
  1         26  
18 1     1   424  
  1         11176  
  1         35  
19             use Dist::Zilla::Plugin::ContributorsFile;
20 1     1   435 use Dist::Zilla::Plugin::CheckChangesHasContent;
  1         196719  
  1         63  
21 1     1   428 use Dist::Zilla::Plugin::NextRelease;
  1         57399  
  1         29  
22 1     1   441 use Dist::Zilla::Plugin::SyncCPANfile;
  1         74064  
  1         33  
23 1     1   427 use Dist::Zilla::Plugin::OurPkgVersion;
  1         34076  
  1         35  
24 1     1   420 use Dist::Zilla::Plugin::PodWeaver;
  1         258250  
  1         32  
25 1     1   412 use Dist::Zilla::Plugin::Git::Contributors;
  1         1008947  
  1         43  
26 1     1   608 use Dist::Zilla::Plugin::PodSyntaxTests;
  1         136917  
  1         45  
27 1     1   569 use Dist::Zilla::Plugin::PodCoverageTests;
  1         58099  
  1         42  
28 1     1   602 use Dist::Zilla::Plugin::Test::NoTabs;
  1         28936  
  1         42  
29 1     1   651 use Dist::Zilla::Plugin::Test::NoBOM;
  1         77068  
  1         45  
30 1     1   604 use Dist::Zilla::Plugin::Test::Perl::Critic;
  1         96259  
  1         44  
31 1     1   636 use Dist::Zilla::Plugin::ExecDir;
  1         46663  
  1         39  
32 1     1   575 use Dist::Zilla::Plugin::MetaJSON;
  1         51939  
  1         44  
33 1     1   663 use Dist::Zilla::Plugin::MetaProvides::Package;
  1         40819  
  1         42  
34 1     1   615 use Dist::Zilla::Plugin::ReadmeAnyFromPod;
  1         326804  
  1         59  
35 1     1   593 use Dist::Zilla::Plugin::ReadmeAddDevInfo;
  1         99318  
  1         44  
36 1     1   589 use Dist::Zilla::Plugin::GitHubREADME::Badge;
  1         48488  
  1         47  
37 1     1   603 use Dist::Zilla::Plugin::MetaResources;
  1         49625  
  1         47  
38 1     1   620  
  1         29649  
  1         34  
39             use Moose;
40 1     1   7  
  1         2  
  1         6  
41             with qw(
42             Dist::Zilla::Role::PluginBundle::Easy
43             Dist::Zilla::Role::PluginBundle::Config::Slicer
44             Dist::Zilla::Role::PluginBundle::PluginRemover
45             );
46              
47             has 'is_cpan' => (
48             is => 'ro',
49             isa => 'Bool',
50             lazy => 1,
51             default => sub {
52             my $pl = $_[0]->payload;
53             exists $pl->{is_cpan} ? $pl->{is_cpan} : 0;
54             },
55             );
56              
57             has 'repository_type' => (
58             is => 'ro',
59             isa => 'Str',
60             lazy => 1,
61             default => sub {
62             my $pl = $_[0]->payload;
63             exists $pl->{repository_type} ? $pl->{repository_type} : 'github';
64             },
65             );
66              
67             has 'repository_path' => (
68             is => 'ro',
69             isa => 'Str',
70             lazy => 1,
71             default => sub {
72             my $pl = $_[0]->payload;
73             exists $pl->{repository_path} ? $pl->{repository_path} : '';
74             },
75             );
76              
77             has 'internal_type' => (
78             is => 'ro',
79             isa => 'Str',
80             lazy => 1,
81             default => sub {
82             my $pl = $_[0]->payload;
83             exists $pl->{internal_type} ? $pl->{internal_type} : 'git';
84             },
85             );
86              
87             has 'internal_url' => (
88             is => 'ro',
89             isa => 'Str',
90             lazy => 1,
91             default => sub {
92             my $pl = $_[0]->payload;
93             exists $pl->{internal_url} ? $pl->{internal_url} : '';
94             },
95             );
96              
97             has 'internal_web' => (
98             is => 'ro',
99             isa => 'Str',
100             lazy => 1,
101             default => sub {
102             my $pl = $_[0]->payload;
103             exists $pl->{internal_web} ? $pl->{internal_web} : '';
104             },
105             );
106              
107             has 'bugtracker' => (
108             is => 'ro',
109             isa => 'Str',
110             lazy => 1,
111             default => sub {
112             my $pl = $_[0]->payload;
113             exists $pl->{bugtracker} ? $pl->{bugtracker} : '';
114             },
115             );
116              
117             has 'fake_release' => (
118             is => 'ro',
119             isa => 'Bool',
120             lazy => 1,
121             default => sub {
122             my $pl = $_[0]->payload;
123             if ( $pl->{is_cpan} ) {
124             $pl->{fake_release} = 0;
125             }
126             exists $pl->{fake_release} ? $pl->{fake_release} : 1;
127             },
128             );
129              
130             my ($self) = @_;
131              
132 0     0 0   my @remove_from_basic;
133             if ( $self->fake_release ) {
134 0           push @remove_from_basic, 'UploadToCPAN';
135 0 0         }
136 0            
137             $self->add_plugins(
138             [
139             'ContributorsFile' => {
140             filename => 'CONTRIBUTORS',
141 0           },
142             ],
143             'CheckChangesHasContent',
144             [
145             'NextRelease' => {
146             format => '%-9v%T %{yyyy-MM-dd HH:mm:ss VVVV}d',
147             },
148             ],
149             qw/
150             SyncCPANfile
151             OurPkgVersion
152             PodWeaver
153             /,
154             [
155             'Git::Contributors' => {
156             include_authors => 1,
157             },
158             ],
159             qw/
160             PodSyntaxTests
161             PodCoverageTests
162              
163             Test::NoTabs
164             Test::NoBOM
165             Test::Perl::Critic
166              
167             MetaJSON
168             MetaProvides::Package
169              
170             ExecDir
171             /,
172             );
173              
174             $self->add_bundle(
175             '@Filter' => {
176 0           '-bundle' => '@Basic',
177             '-remove' => [ 'Readme', @remove_from_basic ],
178             },
179             );
180              
181             $self->_meta_resources;
182             $self->add_bundle('@Git');
183 0            
184 0           if ( $self->is_cpan ) {
185             $self->add_plugins(
186 0 0         [
187 0           'ReadmeAnyFromPod' => 'GfmInRoot' => {
188             phase => 'build',
189             },
190             ],
191             [
192             'ReadmeAnyFromPod' => 'TextInBuild' => {
193             phase => 'build',
194             },
195             ],
196             [
197             'ReadmeAddDevInfo' => {
198             phase => 'build',
199             before => '# AUTHOR',
200             add_contribution_file => 1,
201             },
202             ],
203             [
204             'GitHubREADME::Badge' => {
205             badges => [ qw/cpants issues cpancover license/ ],
206             phase => 'build',
207             place => 'top',
208             },
209             ],
210             );
211             }
212             }
213              
214             my ($self) = @_;
215              
216             my %meta_resources;
217 0     0      
218             $meta_resources{'bugtracker.web'} = $self->bugtracker if $self->bugtracker;
219 0            
220             my $type = $self->repository_type;
221 0 0          
222             return if !$type && !%meta_resources;
223 0            
224             my $name = $self->repository_path;
225 0 0 0        
226             if ( $type eq 'github' ) {
227 0           $meta_resources{'homepage'} =
228             $meta_resources{'repository.web'} =
229 0 0         sprintf "https://github.com/%s",
    0          
    0          
230             $name
231 0           ;
232             $meta_resources{'repository.url'} =
233             sprintf "git://github.com/%s.git",
234             $name
235 0           ;
236             $meta_resources{'repository.type'} = 'git';
237              
238             if ( !$self->bugtracker ) {
239 0           $meta_resources{'bugtracker.web'} =
240             sprintf "https://github.com/%s/issues",
241 0 0         $name
242 0           ;
243             }
244             }
245             elsif ( $type eq 'gitlab' ) {
246             $meta_resources{'homepage'} =
247             $meta_resources{'repository.web'} =
248             sprintf "https://gitlab.com/%s",
249             $name
250 0           ;
251             $meta_resources{'repository.url'} =
252             sprintf "git://gitlab.com/%s.git",
253             $name
254 0           ;
255             $meta_resources{'repository.type'} = 'git';
256              
257             if ( !$self->bugtracker ) {
258 0           $meta_resources{'bugtracker.web'} =
259             sprintf "https://gitlab.com/%s/-/issues",
260 0 0         $name
261 0           ;
262             }
263             }
264             elsif ( $type eq 'internal' ) {
265             $meta_resources{'homepage'} =
266             $meta_resources{'repository.web'} =
267             $self->internal_web if $self->internal_web;
268             $meta_resources{'repository.url'} =
269 0 0         $self->internal_url if $self->internal_url;
270             $meta_resources{'repository.type'} =
271 0 0         $self->internal_type || 'git';
272             }
273 0   0        
274             return if !%meta_resources;
275              
276             $self->add_plugins(
277 0 0         [ 'MetaResources' => \%meta_resources ],
278             );
279 0            
280             return 1;
281             }
282              
283 0           __PACKAGE__->meta->make_immutable;
284              
285             1;
286              
287              
288             =pod
289              
290             =encoding UTF-8
291              
292             =head1 NAME
293              
294             Dist::Zilla::PluginBundle::PERLSRVDE - The plugin bundle we use at Perl-Services.de
295              
296             =head1 VERSION
297              
298             version 1.0.1
299              
300             =head1 SYNOPSIS
301              
302             ; in dist.ini
303             [@PERLSRVDE]
304              
305             Using L</Options>:
306              
307             ; in dist.ini
308             [@PERLSRVDE]
309             ; we are using an internal git repository
310             repository_type = internal
311             internal_type = git
312             internal_url = git://git.internal.example/test.git
313             internal_web = https://git.internal.example/test
314             ; but the bugtracker is an other tool
315             bugtracker = https://our.bugtracker.example
316             ; and it's a CPAN module, so we want to include more
317             ; dist::zilla plugins
318             is_cpan = 1
319             ; but we do not want to upload it ;-)
320             fake_release = 1
321              
322             =head1 DESCRIPTION
323              
324             This is a L<Dist::Zilla> PluginBundle. It lists the plugins we use at L<Perl-Services.de|https://perl-services.de>.
325             It is roughly equivalent to the following dist.ini:
326              
327             [ContributorsFile]
328             filename = CONTRIBUTORS
329            
330             [CheckChangesHasContent]
331            
332             [NextRelease]
333             format=%-9v%T %{yyyy-MM-dd HH:mm:ss VVVV}d
334            
335             [SyncCPANfile]
336             [PkgVersion]
337             [PodWeaver]
338            
339             [@Filter]
340             -bundle = @Basic
341             -remove = Readme
342             -remove = UploadToCPAN
343            
344             [Git::Contributors]
345             include_authors = 1
346            
347             [PodSyntaxTests]
348             [PodCoverageTests]
349             [Test::NoTabs]
350             [Test::NoBOM]
351             [Test::Perl::Critic]
352            
353             [MetaProvides::Package]
354             [MetaJSON]
355            
356             [ExecDir]
357            
358             [@Git]
359            
360             [PerlTidy]
361             perltidyrc = .perltidyrc
362              
363             =for Pod::Coverage configure
364              
365             =head1 OPTIONS
366              
367             These options can be used:
368              
369             =over 4
370              
371             =item * is_cpan
372              
373             =item * repository_type
374              
375             =item * repository_path
376              
377             =item * internal_type
378              
379             =item * internal_url
380              
381             =item * bugtracker
382              
383             =item * fake_release
384              
385             =back
386              
387             =head1 AUTHOR
388              
389             Renee Baecker <reneeb@cpan.org>
390              
391             =head1 COPYRIGHT AND LICENSE
392              
393             This software is Copyright (c) 2022 by Renee Baecker.
394              
395             This is free software, licensed under:
396              
397             The Artistic License 2.0 (GPL Compatible)
398              
399             =cut