Pod/Weaver/PluginBundle/Author/ETHER.pm

filter: Statementstmt 100% 70 / 70 Branchbran 100% 26 / 26 Conditioncond 78.5% 11 / 14 MC/DCmcdc 66.6% 6 / 9 Subroutinesub 100% 17 / 17 Podpod 0.0% 0 / 2 totaltotal 94.2% 130 / 138 CC 19 SCAR 18.9
CC
19
Cov
97%
_expand_config
14.0
_prefix
3.1
configure
3.0
CRAP 6.6
« Dist/Zilla/PluginBundle/Author/ETHER.pm ↑ Summary auto/share/dist/Dist-Zilla-PluginBundle-Author-ETHER/profiles/default/Module.pm »
1 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Pod::Weaver::PluginBundle::Author::ETHER;
4 # vim: set ts=8 sts=2 sw=2 tw=100 et :
5 # ABSTRACT: A plugin bundle for pod woven by ETHER
6  
7 23 our $VERSION = '0.174';
8  
9 23 ▶use if "$]" >= 5.022, experimental => 're_strict';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 23 ▶no if "$]" >= 5.031009, feature => 'indirect';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 23 ▶no if "$]" >= 5.033001, feature => 'multidimensional';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 23 ▶no if "$]" >= 5.033006, feature => 'bareword_filehandles';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 23 ▶no if "$]" >= 5.041009, feature => 'smartmatch';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 23 ▶no feature 'switch';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 23 ▶use namespace::autoclean -also => ['_exp'];
Subroutine BEGIN: called CC=1 SCAR=0.0
16 23 ▶use Pod::Weaver::Config::Assembler;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 23 ▶use Module::Runtime 'use_module';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 23 ▶use PadWalker 'peek_sub';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 7583 ▶sub _exp { Pod::Weaver::Config::Assembler->expand_package($_[0]) }
Subroutine _exp: called CC=1 SCAR=0.0
21  
22 # This sub behaves somewhat like a Dist::Zilla pluginbundle's configure() -- it returns a list of strings or 1, 2
23 # or 3-element arrayrefs containing plugin specifications. The goal is to make this look as close to what
24 # weaver.ini looks like as possible.
25 77 ▶sub configure {
Subroutine configure: called CC=3 SCAR=11.0
Pod undocumented
26 77 my $self = shift;
27  
28 # I wouldn't have to do this ugliness if I could have some configuration values passed in from weaver.ini or
29 # the [PodWeaver] plugin's use of config_plugin (where I could define a 'licence' option)
30 77 my $podweaver_plugin = ${ peek_sub(\&Dist::Zilla::Plugin::PodWeaver::weaver)->{'$self'} };
31 77 ▶ my $licence_plugin = $podweaver_plugin && $podweaver_plugin->zilla->plugin_named('@Author::ETHER/License');
Condition100%3/3
$podweaver_plugin && $podweaver_plugin->zilla->plugin_named('@Author::ETHER/License')
!ll&&!rl&&r
1472
MC/DC100%2/2
$podweaver_plugin && $podweaver_plugin->zilla->plugin_named('@Author::ETHER/License')
$podweaver_plugin $podweaver_plugin->zilla->plugin_named('@Author::ETHER/License')
Truth table100%3/3
A && B
A= $podweaver_pluginB= $podweaver_plugin->zilla->plugin_named('@Author::ETHER/License')
ABresult
0X0
100
111
32 77 ▶ my $licence_filename = $licence_plugin ? $licence_plugin->filename : 'LICENCE';
Branch: 1 branch
BranchTrueFalseTotal
$licence_plugin ? : 72 5 77
33  
34 return (
35 # equivalent to [@CorePrep]
36 77 [ '-EnsurePod5' ],
37 [ '-H1Nester' ],
38 '-SingleEncoding',
39  
40 [ '-Transformer' => List => { transformer => 'List' } ],
41 [ '-Transformer' => Verbatim => { transformer => 'Verbatim' } ],
42  
43 [ 'Region' => 'header' ],
44 'Name',
45  
46 [ 'GenerateSection' => 'generate VERSION' => {
47 title => 'VERSION',
48 main_module_only => 0,
49 text => [ <<'VERSION',
50 version {{ join "\n\n",
51 $version,
52 $dist->is_trial ? 'This is a trial release!' : (),
53 $version < '1.0' && $version !~ /\..+\./ ? "I use a linearly-increasing version numbering scheme. No meaning should be\npresumed or inferred from the version being less than 1.0." : (),
54 }}
55 VERSION
56 ] },
57 ],
58  
59 [ 'Region' => 'prelude' ],
60 [ 'Generic' => 'SYNOPSIS' ],
61 [ 'Generic' => 'DESCRIPTION' ],
62 [ 'Generic' => 'OVERVIEW' ],
63  
64 [ 'Collect' => 'ATTRIBUTES' => { command => 'attr' } ],
65 [ 'Collect' => 'METHODS' => { command => 'method' } ],
66 [ 'Collect' => 'FUNCTIONS' => { command => 'func' } ],
67 [ 'Collect' => 'TYPES' => { command => 'type' } ],
68 'Leftovers',
69 [ 'Region' => 'postlude' ],
70  
71 [ 'GenerateSection' => 'generate GIVING THANKS' => {
72 title => 'GIVING THANKS',
73 main_module_only => 0,
74 text => [ '='.<<'THANKS',
75 for stopwords MetaCPAN GitHub
76  
77 If you found this module to be useful, please show your appreciation by
78 adding a +1 in L<MetaCPAN|https://metacpan.org/dist/{{ $name }}>
79 and a star in L<GitHub|{{ $repository_web }}>.
80 THANKS
81 ] },
82 ],
83 [ 'GenerateSection' => 'generate SUPPORT' => {
84 title => 'SUPPORT',
85 main_module_only => 0,
86 text => [ <<'SUPPORT',
87 {{ join("\n\n",
88 ($bugtracker_email && $bugtracker_email =~ /rt\.cpan\.org/)
89 ? "Bugs may be submitted through L<the RT bug tracker|$bugtracker_web>\n(or L<$bugtracker_email|mailto:$bugtracker_email>)."
90 : $bugtracker_web
91 ? "Bugs may be submitted through L<$bugtracker_web>."
92 : (),
93  
94 $distmeta->{resources}{x_MailingList} ? 'There is also a mailing list available for users of this distribution, at' . "\nL<" . $distmeta->{resources}{x_MailingList} . '>.' : (),
95  
96 $distmeta->{resources}{x_IRC}
97 ? 'There is also an irc channel available for users of this distribution, at' . "\nL<"
98 . do {
99 # try to extract the channel
100 if (my ($network, $channel) = ($distmeta->{resources}{x_IRC} =~ m!(?:://)?([\w-]+(?:\.[\w-]+)*)/?(#[\w-]+)!)) {
101 'C<' . $channel . '> on C<' . $network . '>|' . $distmeta->{resources}{x_IRC}
102 }
103 else {
104 $distmeta->{resources}{x_IRC}
105 }
106 }
107 . '>.'
108 : (),
109  
110 ($distmeta->{x_authority} // '') eq 'cpan:ETHER'
111 ? "I am also usually active on irc, as 'ether' at C<irc.perl.org> and C<irc.libera.chat>."
112 : (),
113 ) }}
114 SUPPORT
115 ] },
116 ],
117  
118 'Authors',
119 [ 'AllowOverride' => 'allow override AUTHOR' => {
120 header_re => '^AUTHORS?\b',
121 action => 'replace',
122 match_anywhere => 0,
123 },
124 ],
125  
126 [ 'Contributors' => { ':version' => '0.008' } ],
127 [ 'Legal' => { ':version' => '4.011', header => 'COPYRIGHT AND ' . $licence_filename } ],
128 [ 'Region' => 'footer' ],
129 );
130 }
131  
132 77 ▶sub mvp_bundle_config {
Subroutine mvp_bundle_config: called CC=2 SCAR=7.2
Pod undocumented
133 77 ▶ my $self = shift || __PACKAGE__;
Condition50%1/2
shift() || __PACKAGE__
l!l
770
MC/DC0%0/1
shift() || __PACKAGE__
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
134  
135 77 return map $self->_expand_config($_), $self->configure;
136 }
137  
138 23 my $prefix;
139 1407 ▶sub _prefix {
Subroutine _prefix: called CC=3 SCAR=11.3
140 1407 my $self = shift;
141 1407 ▶ return $prefix if defined $prefix;
Branch: 1 branch
BranchTrueFalseTotal
if defined $prefix 1392 15 1407
142 15 ▶ ($prefix = (ref($self) || $self)) =~ s/^Pod::Weaver::PluginBundle:://;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
0150
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
143 15 $prefix;
144 }
145  
146 1957 ▶sub _expand_config {
Subroutine _expand_config: called CC=14 SCAR=26.4
147 1957 my ($self, $this_spec) = @_;
148  
149 1957 ▶ die 'undefined config' if not $this_spec;
Branch: 1 branch
BranchTrueFalseTotal
unless $this_spec 1 1956 1957
150 1956 ▶ die 'unrecognized config format: ' . ref($this_spec) if ref($this_spec) and ref($this_spec) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $this_spec and ref $this_spec ne "ARRAY" 1 1955 1956
Condition100%3/3
ref $this_spec and ref $this_spec ne "ARRAY"
!ll&&!rl&&r
31816371
MC/DC100%2/2
ref $this_spec and ref $this_spec ne "ARRAY"
ref $this_spec ref $this_spec ne "ARRAY"
Truth table100%3/3
A and B
A= ref $this_specB= ref $this_spec ne "ARRAY"
ABresult
0X0
100
111
151  
152 1955 my ($name, $class, $payload);
153  
154 1955 ▶ if (not ref $this_spec) {
Branch: 3 branches
BranchTrueFalseTotal
if (not ref $this_spec) { } 318 1637 1955
elsif (@$this_spec == 1) { } 154 1483 1637
elsif (@$this_spec == 2) { } 706 777 1483
155 318 ($name, $class, $payload) = ($this_spec, _exp($this_spec), {});
156 }
157 elsif (@$this_spec == 1) {
158 154 ($name, $class, $payload) = ($this_spec->[0], _exp($this_spec->[0]), {});
159 }
160 elsif (@$this_spec == 2) {
161 706 ▶ $name = ref $this_spec->[1] ? $this_spec->[0] : $this_spec->[1];
Branch: 1 branch
BranchTrueFalseTotal
ref $this_spec->[1] ? : 158 548 706
162 706 ▶ $class = _exp(ref $this_spec->[1] ? $this_spec->[0] : $this_spec->[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $this_spec->[1] ? : 158 548 706
163 706 ▶ $payload = ref $this_spec->[1] ? $this_spec->[1] : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $this_spec->[1] ? : 158 548 706
164 }
165 else {
166 777 ($name, $class, $payload) = ($this_spec->[1], _exp($this_spec->[0]), $this_spec->[2]);
167 }
168  
169 1955 $name =~ s/^[@=-]//;
170  
171 # Region plugins have the custom plugin name moved to 'region_name' parameter,
172 # because we don't want our bundle name to be part of the region name.
173 1955 ▶ if ($class eq _exp('Region')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq _exp("Region")) 311 1644 1955
174 311 $name = $this_spec->[1];
175 311 $payload = { region_name => $this_spec->[1], %$payload };
176 }
177  
178 1955 ▶ use_module($class, $payload->{':version'}) if $payload->{':version'};
Branch: 1 branch
BranchTrueFalseTotal
if $payload->{":version"} 156 1799 1955
179  
180 # prepend '@Author::ETHER/' to each class name,
181 # except for Generic and Collect which are left alone.
182 1954 ▶ $name = '@' . $self->_prefix . '/' . $name
Branch: 1 branch
BranchTrueFalseTotal
if $class ne _exp("Generic") and $class ne _exp("Collect") 1407 547 1954
Condition100%3/3
$class ne _exp("Generic") and $class ne _exp("Collect")
!ll&&!rl&&r
2353121407
MC/DC100%2/2
$class ne _exp("Generic") and $class ne _exp("Collect")
$class ne _exp("Generic") $class ne _exp("Collect")
Truth table100%3/3
A and B
A= $class ne _exp("Generic")B= $class ne _exp("Collect")
ABresult
0X0
100
111
183 if $class ne _exp('Generic') and $class ne _exp('Collect');
184  
185 1954 return [ $name => $class => $payload ];
186 }
187  
188 23 1;
189  
190 __END__
« Dist/Zilla/PluginBundle/Author/ETHER.pm ↑ Summary auto/share/dist/Dist-Zilla-PluginBundle-Author-ETHER/profiles/default/Module.pm »