blib/lib/Dist/Zilla/PluginBundle/AVAR.pm

filter: Statementstmt 47.2% 51 / 108 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 42 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 72.7% 16 / 22 Podpod 0.0% 0 / 1 totaltotal 30.0% 67 / 223 CC 35 SCAR 66.7
CC
35
Cov
28%
bundle_config
1260.0
__ANON__
2.0
__ANON__
2.0
CRAP 788.0
↑ Summary
1 package Dist::Zilla::PluginBundle::AVAR;
2 1 our $AUTHORITY = 'cpan:AVAR';
3 1 $Dist::Zilla::PluginBundle::AVAR::VERSION = '0.35';
4 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 with 'Dist::Zilla::Role::PluginBundle';
8  
9 1 ▶use Dist::Zilla::PluginBundle::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Dist::Zilla::PluginBundle::Git 1.102810;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Dist::Zilla::Plugin::MetaNoIndex;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Dist::Zilla::Plugin::ReadmeFromPod;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Dist::Zilla::Plugin::MakeMaker::Awesome;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Dist::Zilla::Plugin::Test::Compile;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Dist::Zilla::Plugin::Authority;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Dist::Zilla::Plugin::InstallRelease;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Git::Wrapper ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Dist::Zilla::Chrome::Term ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Dist::Zilla::Dist::Builder ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Dist::Zilla::App ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 0 ▶sub bundle_config {
Subroutine bundle_config: not called CC=35 SCAR=71.4
Pod undocumented
24 0 my ($self, $section) = @_;
25  
26 0 my $args = $section->{payload};
27  
28 0 my $zilla = $self->_get_zilla;
29  
30 0 ▶ my $dist = $args->{dist} // $zilla->name || die "You must supply a dist =, it's equivalent to what you supply as name =";
Condition0%0/5
($args->{'dist'} // $zilla->name) || die(q[You must supply a dist =, it's equivalent to what you supply as name =])
l!l
00
$args->{"dist"} // $zilla->name
l!l&&r!l&&!r
000
MC/DC0%0/2
($args->{'dist'} // $zilla->name) || die(q[You must supply a dist =, it's equivalent to what you supply as name =])
$args->{"dist"} $zilla->name
Truth table0%0/3
A // B
A= $args->{"dist"}B= $zilla->name
ABresult
1X1
011
000
31  
32 0 my $ldist = lc $dist;
33  
34 0 my $git = Git::Wrapper->new('.');
35  
36 0 ▶ my $github_user = $args->{github_user} // try { ($git->config('github.user'))[0] } || $ENV{GITHUB_USER} || 'avar';
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/8
($args->{'github_user'} // &try(sub { ($git->config('github.user'))[0]; } )) || $ENV{'GITHUB_USER'} || 'avar'
l!l
00
$args->{"github_user"} // &try(sub { ($git->config("github.user"))[0]; } ) or $ENV{"GITHUB_USER"}
l!l&&r!l&&!r
000
$args->{"github_user"} // &try(sub { ($git->config("github.user"))[0]; } )
l!l&&r!l&&!r
000
MC/DC0%0/3
($args->{'github_user'} // &try(sub { ($git->config('github.user'))[0]; } )) || $ENV{'GITHUB_USER'} || 'avar'
$args->{"github_user"} &try(sub { ($git->config("github.user"))[0]; } ) $ENV{"GITHUB_USER"}
Truth table0%0/4
A // B or C
A= $args->{"github_user"}B= &try(sub { ($git->config("github.user"))[0]; } )C= $ENV{"GITHUB_USER"}
ABCresult
1XX1
01X1
0011
0000
37  
38 0 ▶ my $cpan_id = try { $zilla->stash_named('%PAUSE')->username };
Subroutine __ANON__: not called CC=1 SCAR=6.9
39  
40 0 ▶ my $authority = $args->{authority} // ($cpan_id ? "cpan:$cpan_id" : 'cpan:AVAR');
Branch: 1 branch
BranchTrueFalseTotal
$cpan_id ? : 0 0 0
Condition0%0/2
$args->{"authority"} // ($cpan_id ? "cpan:$cpan_id" : "cpan:AVAR")
l!l
00
MC/DC0%0/1
$args->{"authority"} // ($cpan_id ? "cpan:$cpan_id" : "cpan:AVAR")
$args->{"authority"}
Truth table0%0/2
A
A= $args->{"authority"}
Aresult
11
00
41 0 ▶ my $no_Authority = $args->{no_Authority} // 1;
Condition0%0/2
$args->{"no_Authority"} // 1
l!l
00
MC/DC0%0/1
$args->{"no_Authority"} // 1
$args->{"no_Authority"}
Truth table0%0/2
A
A= $args->{"no_Authority"}
Aresult
11
00
42 0 ▶ my $no_a_pre = $args->{no_AutoPrereq} // 0;
Condition0%0/2
$args->{"no_AutoPrereq"} // 0
l!l
00
MC/DC0%0/1
$args->{"no_AutoPrereq"} // 0
$args->{"no_AutoPrereq"}
Truth table0%0/2
A
A= $args->{"no_AutoPrereq"}
Aresult
11
00
43 0 ▶ my $use_mm = $args->{use_MakeMaker} // 1;
Condition0%0/2
$args->{"use_MakeMaker"} // 1
l!l
00
MC/DC0%0/1
$args->{"use_MakeMaker"} // 1
$args->{"use_MakeMaker"}
Truth table0%0/2
A
A= $args->{"use_MakeMaker"}
Aresult
11
00
44 0 ▶ my $use_ct = $args->{use_CompileTests} // $args->{use_TestCompile} // 1;
Condition0%0/5
($args->{"use_CompileTests"} // $args->{"use_TestCompile"}) // 1
l!l
00
$args->{"use_CompileTests"} // $args->{"use_TestCompile"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($args->{"use_CompileTests"} // $args->{"use_TestCompile"}) // 1
$args->{"use_CompileTests"} $args->{"use_TestCompile"}
Truth table0%0/3
A // B
A= $args->{"use_CompileTests"}B= $args->{"use_TestCompile"}
ABresult
1X1
011
000
45 0 ▶ my $bugtracker = $args->{bugtracker} // 'rt';
Condition0%0/2
$args->{"bugtracker"} // "rt"
l!l
00
MC/DC0%0/1
$args->{"bugtracker"} // "rt"
$args->{"bugtracker"}
Truth table0%0/2
A
A= $args->{"bugtracker"}
Aresult
11
00
46 0 my $homepage = $args->{homepage};
47 0 ▶ warn "AVAR: Upgrade to new format" if $args->{repository};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"repository"} 0 0 0
48 0 my $repository_url = $args->{repository_url};
49 0 my $repository_web = $args->{repository_web};
50 my $nextrelease_format = $args->{nextrelease_format} // '%-2v %{yyyy-MM-dd HH:mm:ss}d',
51 0 ▶ my $tag_message = $args->{git_tag_message};
Condition0%0/2
$args->{"nextrelease_format"} // "%-2v %{yyyy-MM-dd HH:mm:ss}d"
l!l
00
MC/DC0%0/1
$args->{"nextrelease_format"} // "%-2v %{yyyy-MM-dd HH:mm:ss}d"
$args->{"nextrelease_format"}
Truth table0%0/2
A
A= $args->{"nextrelease_format"}
Aresult
11
00
52 0 my $version_regexp = $args->{git_version_regexp};
53  
54 0 my $install_command = $args->{install_command};
55  
56 0 my ($tracker, $tracker_mailto);
57 0 my $page;
58 0 my ($repo_url, $repo_web);
59  
60 0 ▶ if ($bugtracker eq 'github') {
Branch: 2 branches
BranchTrueFalseTotal
if ($bugtracker eq 'github') { } 0 0 0
elsif ($bugtracker eq 'rt') { } 0 0 0
61 0 $tracker = "http://github.com/$github_user/$ldist/issues";
62 } elsif ($bugtracker eq 'rt') {
63 0 $tracker = "https://rt.cpan.org/Public/Dist/Display.html?Name=$dist";
64 0 $tracker_mailto = sprintf 'bug-%s@rt.cpan.org', $dist;
65 } else {
66 0 $tracker = $bugtracker;
67 }
68  
69  
70 0 ▶ unless ($repository_url) {
Branch: 1 branch
BranchTrueFalseTotal
if ($repository_url) { } 0 0 0
71 0 $repo_web = "http://github.com/$github_user/$ldist";
72 0 $repo_url = "git://github.com/$github_user/$ldist.git";
73 } else {
74 0 $repo_web = $repository_web;
75 0 $repo_url = $repository_url;
76 }
77  
78 0 ▶ unless (defined $homepage) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $homepage) { } 0 0 0
79 0 $page = "http://metacpan.org/release/$dist";
80 } else {
81 0 $page = $homepage;
82 }
83  
84 my @plugins = Dist::Zilla::PluginBundle::Filter->bundle_config({
85 0 name => $section->{name} . '/@Classic',
86 payload => {
87 bundle => '@Classic',
88 remove => [
89 # Don't add a =head1 VERSION
90 'PodVersion',
91 # This will inevitably whine about completely reasonable stuff
92 'PodCoverageTests',
93 # Use my MakeMaker
94 'MakeMaker',
95 # Use the use_begin argument to PkgVersion
96 'PkgVersion',
97 ],
98 },
99 });
100  
101 0 my $prefix = 'Dist::Zilla::Plugin::';
102 0 ▶ my @extra = map {[ "$section->{name}/$_->[0]" => "$prefix$_->[0]" => $_->[1] ]}
Branch: 2 branches
BranchTrueFalseTotal
$version_regexp ? : 0 0 0
$no_a_pre ? : 0 0 0
103 (
104 [
105 'PkgVersion' => {
106 use_begin => 1,
107 },
108 ],
109 [
110 'Git::NextVersion' => {
111 first_version => '0.01',
112 ($version_regexp
113 ? (version_regexp => $version_regexp)
114 : (version_regexp => '^(\d.*)$')),
115 }
116 ],
117 ($no_a_pre
118 ? ()
119 : ([ AutoPrereqs => { } ])),
120 [ MetaJSON => { } ],
121 [
122 MetaNoIndex => {
123 # Ignore these if they're there
124 0 ▶ directory => [ map { -d $_ ? $_ : () } qw( inc t xt utils example examples ) ],
Branch: 5 branches
BranchTrueFalseTotal
-d $_ ? : 0 0 0
$no_Authority ? : 0 0 0
$install_command ? : 0 0 0
$use_mm ? : 0 0 0
$use_ct ? : 0 0 0
125 }
126 ],
127 # Produce README from lib/
128 [ ReadmeFromPod => {} ],
129 [
130 MetaResources => {
131 homepage => $page,
132 'bugtracker.web' => $tracker,
133 'bugtracker.mailto' => $tracker_mailto,
134 'repository.type' => 'git',
135 'repository.url' => $repo_url,
136 'repository.web' => $repo_web,
137 license => 'http://dev.perl.org/licenses/',
138 }
139  
140 ],
141 ($no_Authority
142 ? ()
143 : (
144 [
145 Authority => {
146 authority => $authority,
147 do_metadata => 1,
148 }
149 ]
150 )
151 ),
152 # Bump the Changlog
153 [
154 NextRelease => {
155 format => $nextrelease_format,
156 }
157 ],
158 # install a copy for ourselves when releasing
159 ($install_command ? ([
160 InstallRelease => {
161 install_command => $install_command,
162 }
163 ]) : ()),
164  
165 # Maybe use MakeMaker, maybe not
166 ($use_mm
167 ? ([ MakeMaker => { } ])
168 : ()),
169  
170 # Maybe CompileTests
171 ($use_ct
172 ? ([ 'Test::Compile' => { } ])
173 : ()),
174 );
175 0 push @plugins, @extra;
176  
177 0 ▶ push @plugins, Dist::Zilla::PluginBundle::Git->bundle_config({
Branch: 1 branch
BranchTrueFalseTotal
$tag_message ? : 0 0 0
178 name => "$section->{name}/\@Git",
179 payload => {
180 tag_format => '%v',
181 ($tag_message
182 ? (tag_message => $tag_message)
183 : ()),
184 },
185 });
186  
187 # remove empty entries, Config::MVP crashes on them
188  
189 0 foreach my $p (@plugins) {
190 0 my ($name, $package, $payload) = @$p;
191  
192 0 ▶ while (my ($k, $v) = each %$payload) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$payload) 0 0 0
193 0 ▶ if (!$v || (ref $v eq 'ARRAY' && !@$v) || (ref $v eq 'HASH' && !%$v)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $v or ref $v eq "ARRAY" and not @$v or ref $v eq "HASH" and not %$v) 0 0 0
Condition0%0/12
not $v or ref $v eq "ARRAY" and not @$v or ref $v eq "HASH" and not %$v
l!l&&r!l&&!r
000
not $v or ref $v eq "ARRAY" and not @$v
l!l&&r!l&&!r
000
ref $v eq "ARRAY" and not @$v
!ll&&!rl&&r
000
ref $v eq "HASH" and not %$v
!ll&&!rl&&r
000
MC/DC0%0/5
not $v or ref $v eq "ARRAY" and not @$v or ref $v eq "HASH" and not %$v
not $v ref $v eq "ARRAY" not @$v ref $v eq "HASH" not %$v
Truth table0%0/8
not(A) or B and not(C) or D and not(E)
A= not $vB= ref $v eq "ARRAY"C= not @$vD= ref $v eq "HASH"E= not %$v
ABCDEresult
1XXXX1
011XX1
00X111
010111
00X0X0
00X100
0100X0
010100
194 0 delete $payload->{$k};
195 }
196 }
197 }
198  
199 0 return @plugins;
200 }
201  
202 0 ▶sub _get_zilla {
Subroutine _get_zilla: not called CC=1 SCAR=2.2
203 1 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
204 # avoid recursive loop
205 0 ▶ local *Dist::Zilla::PluginBundle::AVAR::bundle_config = sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
206  
207 0 my $chrome = Dist::Zilla::Chrome::Term->new;
208  
209 # this sucks
210 0 ▶ local *Dist::Zilla::App::chrome = sub { $chrome };
Subroutine __ANON__: not called CC=1 SCAR=6.9
211  
212 0 return Dist::Zilla::Dist::Builder->from_config({
213 dist_root => '.',
214 chrome => $chrome,
215 _global_stashes => Dist::Zilla::App->new->_build_global_stashes,
216 });
217 }
218  
219 1 __PACKAGE__->meta->make_immutable;
220  
221 =head1 NAME
222  
223 Dist::Zilla::PluginBundle::AVAR - Use L<Dist::Zilla> like AVAR does
224  
225 =head1 DESCRIPTION
226  
227 This is the plugin bundle that AVAR uses. Use it as:
228  
229 [@AVAR]
230 ;; same as `name' earlier in the dist.ini (optional, detected from $dzil->name)
231 dist = MyDist
232 ;; If you're not avar (will be read from "git config github.user" or $ENV{GITHUB_USER} by default)
233 github_user = imposter
234 ;; Bugtracker github or rt, default is rt
235 bugtracker = rt
236 ;; custom homepage/repository, defaults to metacpan page and github repository lc($dist->name)
237 homepage = http://example.com
238 repository = http://git.example.com/repo.git
239 ;; use various stuff or not
240 no_AutoPrereq = 1 ; evil for this module
241 use_MakeMaker = 0 ; If using e.g. MakeMaker::Awesome instead
242 use_TestCompile = 0 ; I have my own compile tests here..
243 ;; cpan:YOUR_CPAN_ID is the default authority, read from "dzil setup" entry for PAUSE
244 ; authority = cpan:AVAR
245 no_Authority = 0 ; If want to use the authority module (previously the default)
246 ;; if you want to install your dist after release (set $ENV{PERL_CPANM_OPTS} if you need --sudo or --mirror etc.)
247 ;; default is OFF
248 install_command = cpanm .
249  
250 It's equivalent to:
251  
252 [@Filter]
253 bundle = @Classic
254 remove = PodVersion
255 remove = PodCoverageTests
256
257 [Git::NextVersion]
258 [AutoPrereqs]
259 [MetaJSON]
260  
261 [MetaNoIndex]
262 ;; Only added if these directories exist
263 directory = inc
264 directory = t
265 directory = xt
266 directory = utils
267 directory = example
268 directory = examples
269
270 [ReadmeFromPod]
271  
272 [MetaResources]
273 ;; $github_user is 'avar' by default, $lc_dist is lc($dist)
274 homepage = http://search.cpan.org/dist/$dist/
275 bugtracker.mailto = bug-$dist@rt.cpan.org
276 bugtracker.web = https://rt.cpan.org/Public/Dist/Display.html?Name=$dist
277 repository.web = http://github.com/$github_user/$lc_dist
278 repository.url = git://github.com/$github_user/$lc_dist.git
279 repository.type = git
280 license = http://dev.perl.org/licenses/
281  
282 [Authority]
283 authority = cpan:AVAR
284 do_metadata = 1
285
286 [NextRelease]
287 format = %-2v %{yyyy-MM-dd HH:mm:ss}d
288
289 [@Git]
290 tag_format = %v
291 version_regexp = '^(\d.*)$'
292 first_version = '0.01'
293  
294 [InstallRelease]
295 install_command = cpanm .
296  
297 If you'd like a minting profile (to create new modules with all the
298 boilerplate) for this PluginBundle, check out:
299 L<Dist::Zilla::MintingProfile::Author::Caelum>.
300  
301 =head1 SEE ALSO
302  
303 =over 4
304  
305 =item * L<Dist::Zilla>
306  
307 =item * L<Dist::Zilla::PluginBundle::Git>
308  
309 =item * L<Dist::Zilla::MintingProfile::Author::Caelum>
310  
311 =back
312  
313 =head1 AUTHOR
314  
315 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
316  
317 =head1 LICENSE AND COPYRIGHT
318  
319 Copyright 2023 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org>
320  
321 This program is free software, you can redistribute it and/or modify
322 it under the same terms as Perl itself.
323
324 =cut
↑ Summary