Zest/Author/TABULO/MungersForHas.pm

filter: Statementstmt 100% 26 / 26 Branchbran 78.5% 11 / 14 Conditioncond 63.3% 19 / 30 MC/DCmcdc 18.7% 3 / 16 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 4 totaltotal 68.3% 67 / 98 CC 20 SCAR 23.9
CC
20
Cov
80%
hm_enhance_documentation
17.6
hm_lazy_if_possible
6.8
hm_strip_nonstandard_opts
2.0
CRAP 11.0
« Dist/Zilla/PluginBundle/Author/TABULO.pm ↑ Summary Zest/Author/TABULO/Util/Dzil.pm »
1  
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Zest::Author::TABULO::MungersForHas;
6 2 our $VERSION = '1.000014';
7  
8 2 ▶use Exporter::Shiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
9 hm_tabulo
10 hm_lazy_if_possible
11 hm_enhance_documentation
12 hm_strip_nonstandard_opts
13 2 );
14  
15  
16 #region: #== HAS-MUNGERS ==
17  
18 ##== High level: Apply our own suite of mungers for MooseX::MungeHas
19 106 ▶sub hm_tabulo {
Subroutine hm_tabulo: called CC=1 SCAR=0.0
Pod undocumented
20  
21 ## no critic: Subroutines::ProhibitAmpersandSigils
22 106 &hm_lazy_if_possible;
23 106 &hm_enhance_documentation;
24 106 &hm_strip_nonstandard_opts;
25 }
26  
27 ##== Lower level: Individual mungers for MooseX::MungeHas
28  
29 106 ▶sub hm_lazy_if_possible {
Subroutine hm_lazy_if_possible: called CC=6 SCAR=19.2
Pod undocumented
30 106 ▶ unless ( exists $_{lazy} && defined $_{lazy} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $_{"lazy"} and defined $_{"lazy"}) 106 0 106
Condition33%1/3
exists $_{"lazy"} and defined $_{"lazy"}
!ll&&!rl&&r
10600
MC/DC0%0/2
exists $_{"lazy"} and defined $_{"lazy"}
exists $_{"lazy"} defined $_{"lazy"}
Truth table33%1/3
A and B
A= exists $_{"lazy"}B= defined $_{"lazy"}
ABresult
0X0
100
111
31 106 ▶ $_{lazy} //= 1 if exists $_{default} || exists $_{builder};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_{"default"} or exists $_{"builder"} 98 8 106
Condition80%4/5
exists $_{"default"} or exists $_{"builder"}
l!l&&r!l&&!r
9448
$_{"lazy"} //= 1
l!l
098
MC/DC100%2/2
exists $_{"default"} or exists $_{"builder"}
exists $_{"default"} exists $_{"builder"}
MC/DC0%0/1
$_{"lazy"} //= 1
$_{"lazy"}
Truth table100%3/3
A or B
A= exists $_{"default"}B= exists $_{"builder"}
ABresult
1X1
011
000
Truth table50%1/2
A
A= $_{"lazy"}
Aresult
11
00
32 }
33 }
34  
35 106 ▶sub hm_enhance_documentation {
Subroutine hm_enhance_documentation: called CC=14 SCAR=28.7
Pod undocumented
36  
37 #local %_ = ( name => $name, %opt ); # %_ will be available in CODE, filled with whatever we have for attribute META
38  
39 # Semi-dynamic documentation (with rudimentary templating)
40 58 ▶ $_{-document_default} = sub { "Default: '$_{default}'" }
Subroutine __ANON__: called CC=1 SCAR=0.0
41 106 ▶ if delete $_{-document_default} // 1 and exists $_{default} and defined $_{default} and !ref $_{default};
Branch: 1 branch
BranchTrueFalseTotal
if delete $_{"-document_default"} // 1 and exists $_{"default"} and defined $_{"default"} and not ref $_{"default"} 58 48 106
Condition72%8/11
delete $_{"-document_default"} // 1 and exists $_{"default"} and defined $_{"default"} and not ref $_{"default"}
!ll&&!rl&&r
123658
delete $_{"-document_default"} // 1 and exists $_{"default"} and defined $_{"default"}
!ll&&!rl&&r
12094
delete $_{"-document_default"} // 1 and exists $_{"default"}
!ll&&!rl&&r
01294
delete $_{"-document_default"} // 1
l!l
0106
MC/DC0%0/4
delete $_{"-document_default"} // 1 and exists $_{"default"} and defined $_{"default"} and not ref $_{"default"}
delete $_{"-document_default"} exists $_{"default"} defined $_{"default"} not ref $_{"default"}
Truth table0%0/5
A and B and C and not(D)
A= delete $_{"-document_default"}B= exists $_{"default"}C= defined $_{"default"}D= not ref $_{"default"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
42  
43 106 for my $key (qw(documentation -doc -document_default)) {
44 318 ▶ my $doc = delete $_{$key} // next;
Condition100%2/2
delete $_{$key} // (next)
l!l
164154
MC/DC100%1/1
delete $_{$key} // (next)
delete $_{$key}
Truth table100%2/2
A
A= delete $_{$key}
Aresult
11
00
45 164 ▶ $doc = $doc->() if ref($doc) =~ /CODE/;
Branch: 1 branch
BranchTrueFalseTotal
if ref($doc) =~ /CODE/ 58 106 164
46 164 ▶ $_{$key} = $doc if defined $doc;
Branch: 1 branch
BranchTrueFalseTotal
if defined $doc 164 0 164
47 }
48 106 ▶ my $doc = join( " ", delete $_{-doc} // (), delete $_{-document_default} // () );
Condition50%3/6
delete $_{"-doc"} // ()
l!l&&r!l&&!r
10600
delete $_{"-document_default"} // ()
l!l&&r!l&&!r
58480
MC/DC0%0/2
delete $_{"-doc"} // ()
delete $_{"-doc"} ()
MC/DC0%0/2
delete $_{"-document_default"} // ()
delete $_{"-document_default"} ()
Truth table33%1/3
A // B
A= delete $_{"-doc"}B= ()
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= delete $_{"-document_default"}B= ()
ABresult
1X1
011
000
49 106 ▶ $_{documentation} //= $doc if $doc;
Branch: 1 branch
BranchTrueFalseTotal
if $doc 106 0 106
Condition33%1/3
$_{"documentation"} //= $doc
l!l&&r!l&&!r
01060
MC/DC0%0/2
$_{"documentation"} //= $doc
$_{"documentation"} $doc
Truth table33%1/3
A //= B
A= $_{"documentation"}B= $doc
ABresult
1X1
011
000
50 }
51  
52 106 ▶sub hm_strip_nonstandard_opts {
Subroutine hm_strip_nonstandard_opts: called CC=2 SCAR=6.9
Pod undocumented
53 106 ▶ %_ = ( map { ( $_->key =~ m/^-/ ) ? () : (@$_) } List::Util::pairs(%_) );
Branch: 1 branch
BranchTrueFalseTotal
$_->key =~ /^-/ ? : 12 634 646
54 }
55  
56  
57 #endregion HAS-MUNGERS
58  
59 2 1;
60  
61 =pod
62  
63 =encoding UTF-8
64  
65 =for :stopwords Tabulo[n]
66  
67 =head1 NAME
68  
69 Zest::Author::TABULO::MungersForHas - Utility functions used by TABULO's authoring dist
70  
71 =head1 VERSION
72  
73 version 1.000014
74  
75 =for Pod::Coverage hm_enhance_documentation hm_lazy_if_possible hm_strip_nonstandard_opts hm_tabulo
76  
77 =head1 AUTHORS
78  
79 Tabulo[n] <dev@tabulo.net>
80  
81 =head1 LEGAL
82  
83 This software is copyright (c) 2023 by Tabulo[n].
84  
85 This is free software; you can redistribute it and/or modify it under
86 the same terms as the Perl 5 programming language system itself.
87  
88 =cut
89  
90 __END__
« Dist/Zilla/PluginBundle/Author/TABULO.pm ↑ Summary Zest/Author/TABULO/Util/Dzil.pm »