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

filter: Statementstmt 50.0% 78 / 156 Branchbran 0.0% 0 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 52.7% 19 / 36 Podpod n/a totaltotal 43.3% 97 / 224 CC 18 SCAR 28.6
CC
18
Cov
41%
__ANON__
83.3
__ANON__
16.3
_resolve_repository_with
9.9
CRAP 17.4
↑ Summary
1 package Dist::Zilla::PluginBundle::SCHWIGON;
2 # git description: v0.019-6-gbe6cde0
3  
4 1 our $AUTHORITY = 'cpan:SCHWIGON';
5 # ABSTRACT: Build your distributions like SCHWIGON does
6 1 $Dist::Zilla::PluginBundle::SCHWIGON::VERSION = '0.021';
7 # (well actually like FLORA - as it is shamelessly stolen)
8  
9 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Moose 1.00;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Method::Signatures::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use MooseX::Types::URI qw(Uri);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use MooseX::Types::Email qw(EmailAddress);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use MooseX::Types::Moose qw(Bool Str CodeRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use MooseX::Types::Structured 0.20 qw(Map Dict Optional);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use namespace::autoclean -also => 'lower';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 1 has dist => (
21 is => 'ro',
22 isa => Str,
23 required => 1,
24 );
25  
26 1 has authority => (
27 is => 'ro',
28 isa => Str,
29 default => 'cpan:SCHWIGON',
30 );
31  
32 # backcompat
33 1 has auto_prereq => (
34 is => 'ro',
35 isa => Bool,
36 default => 1,
37 );
38  
39 has auto_prereqs => (
40 is => 'ro',
41 isa => Bool,
42 lazy => 1,
43 0 ▶ default => sub { shift->auto_prereq },
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 1 );
45  
46 1 has is_task => (
47 is => 'ro',
48 isa => Bool,
49 lazy => 1,
50 builder => '_build_is_task',
51 );
52  
53 0 ▶method _build_is_task {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine _build_is_task: not called CC=2 SCAR=14.6
54 0 ▶ return $self->dist =~ /^Task-/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->dist =~ /^Task-/ ? : 0 0 0
55 1 }
56  
57 1 has weaver_config_plugin => (
58 is => 'ro',
59 isa => Str,
60 default => '@SCHWIGON',
61 );
62  
63 1 has static_version => (
64 is => 'ro',
65 isa => Str,
66 predicate => 'has_static_version',
67 );
68  
69 1 has release_branch => (
70 is => 'ro',
71 isa => Str,
72 predicate => 'has_release_branch',
73 );
74  
75 1 has disable_pod_coverage_tests => (
76 is => 'ro',
77 isa => Bool,
78 default => 0,
79 );
80  
81 1 has disable_trailing_whitespace_tests => (
82 is => 'ro',
83 isa => Bool,
84 default => 0,
85 );
86  
87 1 has disable_tab_tests => (
88 is => 'ro',
89 isa => Bool,
90 default => 0,
91 );
92  
93 1 has bugtracker_url => (
94 isa => Uri,
95 coerce => 1,
96 lazy => 1,
97 builder => '_build_bugtracker_url',
98 handles => {
99 bugtracker_url => 'as_string',
100 },
101 );
102  
103 0 ▶method _build_bugtracker_url {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine _build_bugtracker_url: not called CC=1 SCAR=3.5
104 0 return sprintf $self->_rt_uri_pattern, $self->dist;
105 1 }
106  
107 1 has bugtracker_email => (
108 is => 'ro',
109 isa => EmailAddress,
110 lazy => 1,
111 builder => '_build_bugtracker_email',
112 );
113  
114 0 ▶method _build_bugtracker_email {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=3.5
115 0 return sprintf 'bug-%s@rt.cpan.org', $self->dist;
116 1 }
117  
118 1 has _rt_uri_pattern => (
119 is => 'ro',
120 isa => Str,
121 default => 'http://rt.cpan.org/Public/Dist/Display.html?Name=%s',
122 );
123  
124 1 has homepage_url => (
125 isa => Uri,
126 coerce => 1,
127 lazy => 1,
128 builder => '_build_homepage_url',
129 handles => {
130 homepage_url => 'as_string',
131 },
132 );
133  
134 1 has skip_pod_modules => (
135 is => 'ro',
136 isa => Str,
137 lazy => 1,
138 default => '',
139 handles => {
140 skip => 'as_string',
141 },
142 );
143  
144 1 has test_compile_skip => (
145 is => 'ro',
146 isa => Str,
147 predicate => 'has_test_compile_skip',
148 );
149  
150 0 ▶method _build_homepage_url {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=3.5
151 0 return sprintf $self->_cpansearch_pattern, $self->dist;
152 1 }
153  
154 1 has _cpansearch_pattern => (
155 is => 'ro',
156 isa => Str,
157 default => 'http://metacpan.org/release/%s',
158 );
159  
160 1 has repository => (
161 isa => Uri,
162 coerce => 1,
163 lazy => 1,
164 builder => '_build_repository_url',
165 handles => {
166 repository_url => 'as_string',
167 repository_scheme => 'scheme',
168 },
169 );
170  
171 1 has repository_at => (
172 is => 'ro',
173 isa => Str,
174 predicate => 'has_repository_at',
175 );
176  
177 1 has github_user => (
178 is => 'ro',
179 isa => Str,
180 default => 'renormalist',
181 );
182  
183 1 my $map_tc = Map[
184 Str, Dict[
185 pattern => CodeRef,
186 web_pattern => CodeRef,
187 type => Optional[Str],
188 mangle => Optional[CodeRef],
189 ]
190 ];
191  
192 coerce $map_tc, from Map[
193 Str, Dict[
194 pattern => Str|CodeRef,
195 web_pattern => Str|CodeRef,
196 type => Optional[Str],
197 mangle => Optional[CodeRef],
198 ]
199 0 ▶], via {
Subroutine __ANON__: not called CC=2 SCAR=17.9
200 0 my %in = %{ $_ };
201 return { map {
202 0 my $k = $_;
203 ($k => {
204 0 %{ $in{$k} },
205 (map {
206 0 my $v = $_;
207 (ref $in{$k}->{$v} ne 'CODE'
208 0 ▶ ? ($v => sub { $in{$k}->{$v} })
Subroutine __ANON__: not called CC=1 SCAR=6.9
209 0 ▶ : ()),
Branch: 1 branch
BranchTrueFalseTotal
ref $in{$k}{$v} ne 'CODE' ? : 0 0 0
210 } qw(pattern web_pattern)),
211 })
212 } keys %in };
213 1 };
214  
215 1 has _repository_host_map => (
216 traits => [qw(Hash)],
217 isa => $map_tc,
218 coerce => 1,
219 lazy => 1,
220 builder => '_build__repository_host_map',
221 handles => {
222 _repository_data_for => 'get',
223 },
224 );
225  
226 sub lower { lc shift }
227  
228 0 ▶method _build__repository_host_map {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=5.6
229 0 ▶ my $github_pattern = sub { sprintf 'git://github.com/%s/%%s.git', $self->github_user };
Subroutine __ANON__: not called CC=1 SCAR=6.9
230 0 ▶ my $github_web_pattern = sub { sprintf 'http://github.com/%s/%%s', $self->github_user };
Subroutine __ANON__: not called CC=1 SCAR=6.9
231 0 ▶ my $scsys_web_pattern_proto = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
232 0 return sprintf 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=%s/%%s.git;a=summary', $_[0];
233 0 };
234  
235 return {
236 github => {
237 pattern => $github_pattern,
238 web_pattern => $github_web_pattern,
239 # mangle => \&lower,
240 },
241 GitHub => {
242 pattern => $github_pattern,
243 web_pattern => $github_web_pattern,
244 },
245 gitmo => {
246 pattern => 'git://git.moose.perl.org/%s.git',
247 web_pattern => $scsys_web_pattern_proto->('gitmo'),
248 },
249 catsvn => {
250 type => 'svn',
251 pattern => 'http://dev.catalyst.perl.org/repos/Catalyst/%s/',
252 web_pattern => 'http://dev.catalystframework.org/svnweb/Catalyst/browse/%s',
253 },
254 (map {
255 0 ($_ => {
256 pattern => "git://git.shadowcat.co.uk/${_}/%s.git",
257 web_pattern => $scsys_web_pattern_proto->($_),
258 })
259 } qw(catagits p5sagit dbsrgits)),
260 };
261 1 }
262  
263 0 ▶method _build_repository_url {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=2 SCAR=15.1
264 0 ▶ return $self->_resolve_repository_with($self->repository_at, 'pattern')
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_repository_at 0 0 0
265 if $self->has_repository_at;
266 0 confess "Cannot determine repository url without repository_at. "
267 . "Please provide either repository_at or repository."
268 1 }
269  
270 1 has repository_web => (
271 isa => Uri,
272 coerce => 1,
273 lazy => 1,
274 builder => '_build_repository_web',
275 handles => {
276 repository_web => 'as_string',
277 },
278 );
279  
280 0 ▶method _build_repository_web {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine _build_repository_web: not called CC=2 SCAR=15.1
281 0 ▶ return $self->_resolve_repository_with($self->repository_at, 'web_pattern')
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_repository_at 0 0 0
282 if $self->has_repository_at;
283 0 confess "Cannot determine repository web url without repository_at. "
284 . "Please provide either repository_at or repository_web."
285 1 }
286  
287 0 ▶method _resolve_repository_with ($service, $thing) {
Subroutine BEGIN: called CC=1 SCAR=3.5
Subroutine _resolve_repository_with: not called CC=3 SCAR=23.0
288 0 my $dist = $self->dist;
289 0 my $data = $self->_repository_data_for($service);
290 0 ▶ confess "unknown repository service $service" unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
291 return sprintf $data->{$thing}->(),
292 (exists $data->{mangle}
293 0 ▶ ? $data->{mangle}->($dist)
Branch: 1 branch
BranchTrueFalseTotal
exists $data->{'mangle'} ? : 0 0 0
294 : $dist);
295 1 }
296  
297 1 has repository_type => (
298 is => 'ro',
299 isa => Str,
300 lazy => 1,
301 builder => '_build_repository_type',
302 );
303  
304 0 ▶method _build_repository_type {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=4 SCAR=27.9
305 0 my $data = $self->_repository_data_for($self->repository_at);
306 0 ▶ return $data->{type} if exists $data->{type};
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"type"} 0 0 0
307  
308 0 for my $vcs (qw(git svn)) {
309 0 ▶ return $vcs if $self->repository_scheme eq $vcs;
Branch: 1 branch
BranchTrueFalseTotal
if $self->repository_scheme eq $vcs 0 0 0
310 }
311  
312 0 confess "Unable to guess repository type based on the repository url. "
313 . "Please provide repository_type.";
314 1 }
315  
316 0 ▶override BUILDARGS => method ($class:) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
317 0 my $args = super;
318 0 return { %{ $args->{payload} }, %{ $args } };
319 1 };
320  
321 0 ▶method configure {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=9 SCAR=44.2
322 0 $self->add_bundle('@Basic');
323  
324 0 $self->add_plugins(qw(
325 MetaConfig
326 MetaJSON
327 MetaProvides::Package
328 PkgVersion
329 PodSyntaxTests
330 ));
331  
332 0 ▶ $self->add_plugins(['Test::Compile' => {
Branch: 1 branch
BranchTrueFalseTotal
$self->has_test_compile_skip ? : 0 0 0
333 $self->has_test_compile_skip
334 ? (skip => $self->test_compile_skip)
335 : (skip => [qw{ Test::TAPv13}]),
336 }]);
337  
338 0 ▶ $self->add_plugins('Test::NoTabs')
Branch: 1 branch
BranchTrueFalseTotal
unless $self->disable_tab_tests 0 0 0
339 unless $self->disable_tab_tests;
340  
341 0 ▶ $self->add_plugins(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->disable_pod_coverage_tests 0 0 0
342 ['Test::Pod::Coverage::Configurable' => {
343 'skip' => $self->skip_pod_modules,
344 }])
345 unless $self->disable_pod_coverage_tests;
346  
347 0 ▶ $self->add_plugins(
Branch: 1 branch
BranchTrueFalseTotal
$self->disable_trailing_whitespace_tests ? : 0 0 0
348 [MetaResources => {
349 'repository.type' => $self->repository_type,
350 'repository.url' => $self->repository_url,
351 'repository.web' => $self->repository_web,
352 'bugtracker.web' => $self->bugtracker_url,
353 'bugtracker.mailto' => $self->bugtracker_email,
354 'homepage' => $self->homepage_url,
355 }],
356 [Authority => {
357 authority => $self->authority,
358 do_metadata => 1,
359 }],
360 ['Test::EOL' => {
361 trailing_whitespace => $self->disable_trailing_whitespace_tests ? 0 : 1,
362 }],
363 );
364  
365 0 ▶ $self->is_task
Branch: 1 branch
BranchTrueFalseTotal
$self->is_task ? : 0 0 0
366 ? $self->add_plugins('TaskWeaver')
367 : $self->add_plugins(
368 [PodWeaver => {
369 config_plugin => $self->weaver_config_plugin,
370 }],
371 );
372  
373 0 ▶ $self->add_plugins('AutoPrereqs') if $self->auto_prereqs;
Branch: 1 branch
BranchTrueFalseTotal
if $self->auto_prereqs 0 0 0
374  
375 # roughly from here we diverge from FLORA
376  
377 0 $self->add_plugins('Git::Describe');
378 0 $self->add_plugins('CheckChangesHasContent');
379  
380 0 $self->add_plugins(['NextRelease' =>
381 { format => '%-9v %{yyyy-MM-dd}d' }]);
382  
383 0 ▶ $self->add_plugins(['Git::CheckFor::CorrectBranch' =>
Branch: 1 branch
BranchTrueFalseTotal
$self->has_release_branch ? : 0 0 0
384 { release_branch => ($self->has_release_branch
385 ? $self->release_branch
386 : 'master')
387 }]);
388  
389 0 ▶ if ($self->has_static_version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_static_version) { } 0 0 0
390 0 $self->add_plugins(['StaticVersion' => { version => $self->static_version }]);
391 } else {
392 0 $self->add_plugins('Git::NextVersion');
393 }
394  
395 0 $self->add_bundle('@Git');
396 1 }
397  
398 1 with 'Dist::Zilla::Role::PluginBundle::Easy';
399  
400 1 __PACKAGE__->meta->make_immutable;
401  
402 1 1;
403  
404 __END__
↑ Summary