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

filter: Statementstmt 38.7% 38 / 98 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 25.0% 5 / 20 Podpod 0.0% 0 / 1 totaltotal 26.3% 43 / 163 CC 24 SCAR 32.4
CC
24
Cov
27%
__ANON__
90.0
__ANON__
20.0
_repository_data
12.0
CRAP 25.5
↑ Summary
1 package Dist::Zilla::PluginBundle::DOY;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Dist::Zilla::PluginBundle::DOY::AUTHORITY = 'cpan:DOY';
4 }
5 1 $Dist::Zilla::PluginBundle::DOY::VERSION = '0.15';
6 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 # ABSTRACT: Dist::Zilla plugins for me
8  
9 1 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Dist::Zilla;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 with 'Dist::Zilla::Role::PluginBundle::Easy';
13  
14  
15 1 has dist => (
16 is => 'ro',
17 isa => 'Str',
18 required => 1,
19 );
20  
21 1 has authority => (
22 is => 'ro',
23 isa => 'Str',
24 default => 'cpan:DOY',
25 );
26  
27 1 has github_user => (
28 is => 'ro',
29 isa => 'Str',
30 default => 'doy',
31 );
32  
33 has github_name => (
34 is => 'ro',
35 isa => 'Str',
36 lazy => 1,
37 0 ▶ default => sub { lc shift->dist },
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 1 );
39  
40 1 has repository => (
41 is => 'ro',
42 isa => 'Str',
43 );
44  
45 1 for my $attr (qw(repository_type repository_url repository_web)) {
46 has $attr => (
47 is => 'ro',
48 isa => 'Maybe[Str]',
49 lazy => 1,
50 0 ▶ default => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
51 0 my $self = shift;
52 0 my $data = $self->_repository_data;
53 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
54 0 return $data->{$attr};
55 },
56 3 );
57 }
58  
59 0 ▶sub _repository_data {
Subroutine _repository_data: not called CC=3 SCAR=24.8
60 0 my $self = shift;
61  
62 0 my $host = $self->repository;
63 0 ▶ return unless defined $host;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $host 0 0 0
64  
65 die "Unknown repository host $host"
66 0 ▶ unless exists $self->_repository_host_map->{$host};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->_repository_host_map->{$host} 0 0 0
67  
68 0 return $self->_repository_host_map->{$host};
69 }
70  
71 has _repository_host_map => (
72 is => 'ro',
73 isa => 'HashRef[HashRef[Str]]',
74 lazy => 1,
75 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
76 0 my $self = shift;
77 return {
78 0 'github' => {
79 repository_type => 'git',
80 repository_url => sprintf('git://github.com/%s/%s.git', $self->github_user, $self->github_name),
81 repository_web => sprintf('https://github.com/%s/%s', $self->github_user, $self->github_name),
82 },
83 'gitmo' => {
84 repository_type => 'git',
85 repository_url => sprintf('git://git.moose.perl.org/%s.git', $self->dist),
86 repository_web => sprintf('http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/%s.git;a=summary', $self->dist),
87 },
88 }
89 },
90 1 );
91  
92 has bugtracker => (
93 is => 'ro',
94 isa => 'Str',
95 lazy => 1,
96 0 ▶ default => sub { shift->repository eq 'github' ? 'github' : 'rt' },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
(shift())->repository eq 'github' ? : 0 0 0
97 1 );
98  
99 1 for my $attr (qw(bugtracker_web bugtracker_mailto)) {
100 has $attr => (
101 is => 'ro',
102 isa => 'Maybe[Str]',
103 lazy => 1,
104 0 ▶ default => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
105 0 my $self = shift;
106 0 my $data = $self->_bugtracker_data;
107 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
108 0 return $data->{$attr};
109 },
110 2 );
111 }
112  
113 0 ▶sub _bugtracker_data {
Subroutine _bugtracker_data: not called CC=3 SCAR=24.8
114 0 my $self = shift;
115  
116 0 my $host = $self->bugtracker;
117 0 ▶ return unless defined $host;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $host 0 0 0
118  
119 die "Unknown bugtracker host $host"
120 0 ▶ unless exists $self->_bugtracker_host_map->{$host};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->_bugtracker_host_map->{$host} 0 0 0
121  
122 0 return $self->_bugtracker_host_map->{$host};
123 }
124  
125 has _bugtracker_host_map => (
126 is => 'ro',
127 isa => 'HashRef[HashRef[Str]]',
128 lazy => 1,
129 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
130 0 my $self = shift;
131 return {
132 0 'github' => {
133 bugtracker_web => sprintf('https://github.com/%s/%s/issues', $self->github_user, $self->github_name),
134 },
135 'rt' => {
136 bugtracker_web => sprintf('http://rt.cpan.org/Public/Dist/Display.html?Name=%s', $self->dist),
137 bugtracker_mailto => sprintf('bug-%s@rt.cpan.org', lc $self->dist),
138 },
139 }
140 },
141 1 );
142  
143 has homepage => (
144 is => 'ro',
145 isa => 'Str',
146 lazy => 1,
147 0 ▶ default => sub { sprintf('http://metacpan.org/release/%s', shift->dist) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
148 1 );
149  
150 1 has awesome => (
151 is => 'ro',
152 isa => 'Str',
153 );
154  
155 1 has dynamic_config => (
156 is => 'ro',
157 isa => 'Str',
158 );
159  
160 has is_task => (
161 is => 'ro',
162 isa => 'Bool',
163 lazy => 1,
164 0 ▶ default => sub { shift->dist =~ /^Task-/ ? 1 : 0 },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
(shift())->dist =~ /^Task-/ ? : 0 0 0
165 1 );
166  
167 has is_test_dist => (
168 is => 'ro',
169 isa => 'Bool',
170 lazy => 1,
171 0 ▶ default => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
172 0 my $self = shift;
173 0 ▶ return 1 if $ENV{DZIL_FAKE_RELEASE};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DZIL_FAKE_RELEASE"} 0 0 0
174 0 ▶ return $self->dist =~ /^Foo-/ ? 1 : 0
Branch: 1 branch
BranchTrueFalseTotal
$self->dist =~ /^Foo-/ ? : 0 0 0
175 },
176 1 );
177  
178 1 has done_testing => (
179 is => 'ro',
180 isa => 'Bool',
181 default => 1,
182 );
183  
184 has _plugins => (
185 is => 'ro',
186 isa => 'ArrayRef[Str]',
187 lazy => 1,
188 0 ▶ default => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
189 0 my $self = shift;
190 [
191 0 ▶ qw(
Branch: 3 branches
BranchTrueFalseTotal
$self->awesome ? : 0 0 0
$self->is_task ? : 0 0 0
$self->is_test_dist ? : 0 0 0
192 GatherDir
193 PruneCruft
194 ManifestSkip
195 MetaYAML
196 License
197 Readme
198 RunExtraTests
199 ExecDir
200 ShareDir
201 ),
202 ($self->awesome ? $self->awesome : 'MakeMaker'),
203 qw(
204 Manifest
205 TestRelease
206 ConfirmRelease
207 MetaConfig
208 MetaJSON
209 NextRelease
210 CheckChangesHasContent
211 PkgVersion
212 Authority
213 PodCoverageTests
214 PodSyntaxTests
215 Test::NoTabs
216 EOLTests
217 Test::Compile
218 Metadata
219 MetaResources
220 Git::Check
221 Git::Commit
222 Git::Tag
223 Git::NextVersion
224 ContributorsFromGit
225 MetaProvides::Package
226 ),
227 ($self->is_task ? 'TaskWeaver' : 'PodWeaver'),
228 ($self->is_test_dist ? 'FakeRelease' : 'UploadToCPAN'),
229 ]
230 },
231 1 );
232  
233 has plugin_options => (
234 is => 'ro',
235 isa => 'HashRef[HashRef[Str]]',
236 init_arg => undef,
237 lazy => 1,
238 0 ▶ default => sub {
Subroutine __ANON__: not called CC=9 SCAR=45.0
239 0 my $self = shift;
240 0 my %opts = (
241 'NextRelease' => { format => '%-5v %{yyyy-MM-dd}d' },
242 'Authority' => { authority => $self->authority },
243 'Git::Check' => { allow_dirty => '' },
244 'Git::Tag' => { tag_format => '%v', tag_message => '' },
245 'Git::NextVersion' => {
246 version_regexp => '^(\d+\.\d+)$',
247 first_version => '0.01'
248 },
249 'Git::Commit' => {
250 commit_msg => 'changelog',
251 },
252 );
253  
254 $opts{Metadata} = {
255 0 ▶ dynamic_config => 1,
Branch: 1 branch
BranchTrueFalseTotal
if $self->dynamic_config 0 0 0
256 } if $self->dynamic_config;
257  
258 0 for my $metaresource (qw(repository.type repository.url repository.web bugtracker.web bugtracker.mailto homepage)) {
259 0 (my $method = $metaresource) =~ s/\./_/g;
260 0 my $value = $self->$method;
261 0 ▶ if (!$value) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value) 0 0 0
262 0 ▶ warn "*** resources.$metaresource is not configured! This needs to be fixed! ***"
Branch: 1 branch
BranchTrueFalseTotal
unless $metaresource eq "bugtracker.mailto" 0 0 0
263 unless $metaresource eq 'bugtracker.mailto';
264 0 next;
265 }
266 0 $opts{MetaResources}{$metaresource} = $value;
267 }
268 delete $opts{MetaResources}{'repository.type'}
269 0 ▶ unless exists $opts{MetaResources}{'repository.url'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"MetaResources"}{"repository.url"} 0 0 0
270  
271 0 for my $option (keys %{ $self->payload }) {
272 0 ▶ next unless $option =~ /^([A-Z][^_]*)_(.+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $option =~ /^([A-Z][^_]*)_(.+)$/ 0 0 0
273 0 my ($plugin, $plugin_option) = ($1, $2);
274 0 ▶ $opts{$plugin} ||= {};
Condition0%0/2
$opts{$plugin} ||= {}
l!l
00
MC/DC0%0/1
$opts{$plugin} ||= {}
$opts{$plugin}
Truth table0%0/2
A
A= $opts{$plugin}
Aresult
11
00
275 0 $opts{$plugin}->{$plugin_option} = $self->payload->{$option};
276 }
277  
278 0 return \%opts;
279 },
280 1 );
281  
282 0 ▶around BUILDARGS => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
283 0 my $orig = shift;
284 0 my $class = shift;
285 0 my $args = $class->$orig(@_);
286 0 return { %{ $args->{payload} }, %{ $args } };
287 1 };
288  
289 0 ▶sub configure {
Subroutine configure: not called CC=3 SCAR=24.8
Pod undocumented
290 0 my $self = shift;
291  
292 0 ▶ $self->add_plugins(
Branch: 1 branch
BranchTrueFalseTotal
if $self->done_testing 0 0 0
293 [ 'Prereqs' => 'TestMoreDoneTesting' => {
294 -phase => 'test',
295 -type => 'requires',
296 'Test::More' => '0.88',
297 } ]
298 ) if $self->done_testing;
299 $self->add_plugins(
300 0 ▶ map { [ $_ => ($self->plugin_options->{$_} || {}) ] }
Condition0%0/2
$self->plugin_options->{$_} || {}
l!l
00
MC/DC0%0/1
$self->plugin_options->{$_} || {}
$self->plugin_options->{$_}
Truth table0%0/2
A
A= $self->plugin_options->{$_}
Aresult
11
00
301 0 @{ $self->_plugins },
302 );
303 }
304  
305  
306 1 __PACKAGE__->meta->make_immutable;
307 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
308  
309 1 1;
310  
311 __END__
↑ Summary