blib/lib/Dist/Zilla/Plugin/Author/Plicease/Upload.pm

filter: Statementstmt 100% 52 / 52 Branchbran 87.5% 14 / 16 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 97.5% 78 / 80 CC 10 SCAR 18.9
CC
10
Cov
97%
__ANON__
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.6
« example/unbundle.pl ↑ Summary blib/lib/Dist/Zilla/Plugin/Author/Plicease/Core.pm »
1 2 package Dist::Zilla::Plugin::Author::Plicease::Upload 2.81 {
2  
3 2 ▶ use 5.022;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶ use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ABSTRACT: Upload a dist to CPAN
8  
9  
10 2 extends 'Dist::Zilla::Plugin::UploadToCPAN';
11  
12 has cpan => (
13 is => 'ro',
14 4 ▶ default => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
15 2 );
16  
17 has url => (
18 is => 'ro',
19 6 ▶ default => sub { 'http://dist.wdlabs.com/' },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 2 );
21  
22 6 ▶ around before_release => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 6 my $orig = shift;
24 6 my $self = shift;
25  
26 # don't check username / password here
27 # do it during release
28 2 };
29  
30 6 ▶ around release => sub {
Subroutine __ANON__: called CC=10 SCAR=23.0
31 6 my $orig = shift;
32 6 my $self = shift;
33 6 my($archive) = @_;
34  
35 6 my($local_release_dir) = grep { -d } map { Path::Tiny->new($_) } qw( ~/www/dist.wdlabs.com/docs ~/dev/site-dist/docs );
36  
37 6 my @cmd;
38  
39 6 ▶ if($self->cpan && $self->zilla->chrome->prompt_yn("upload to CPAN?"))
Branch: 2 branches
BranchTrueFalseTotal
if ($self->cpan and $self->zilla->chrome->prompt_yn('upload to CPAN?')) { } 2 4 6
elsif (defined $local_release_dir) { } 3 1 4
Condition100%3/3
$self->cpan and $self->zilla->chrome->prompt_yn("upload to CPAN?")
!ll&&!rl&&r
312
MC/DC100%2/2
$self->cpan and $self->zilla->chrome->prompt_yn("upload to CPAN?")
$self->cpan $self->zilla->chrome->prompt_yn("upload to CPAN?")
Truth table100%3/3
A and B
A= $self->cpanB= $self->zilla->chrome->prompt_yn("upload to CPAN?")
ABresult
0X0
100
111
40 {
41 2 eval {
42 2 ▶ die "no username" unless length $self->username;
Branch: 1 branch
BranchTrueFalseTotal
unless length $self->username 1 1 2
43 1 ▶ die "no password" unless length $self->password;
Branch: 1 branch
BranchTrueFalseTotal
unless length $self->password 0 1 1
44 1 $self->$orig(@_);
45 };
46 2 ▶ if(my $error = $@)
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = $@) 1 1 2
47 {
48 1 $self->zilla->log("error uploading to cpan: $error");
49 1 $self->zilla->log("you will have to manually upload the dist");
50 }
51 2 return;
52 }
53 elsif(defined $local_release_dir)
54 {
55 3 @cmd = ('cp', $archive, "$local_release_dir");
56 }
57 else
58 {
59 1 $self->zilla->log("no release process available, upload tarball manually");
60 1 return;
61 }
62  
63 {
64 3 $self->zilla->log("% @cmd");
65 3 eval {
66 3 system @cmd;
67 3 ▶ die "failed to execute: $!\n" if $? == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $? == -1 0 3 3
68 3 ▶ die "exited with status @{[ $? >> 8 ]}\n" if $?;
Branch: 1 branch
BranchTrueFalseTotal
if $? 1 2 3
69 };
70 3 ▶ if(my $error = $@)
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = $@) { } 1 2 3
71 {
72 1 $self->zilla->log("NOTE COPY FAILED: $error");
73 1 $self->zilla->log("manual upload will be required");
74 }
75 else
76 {
77 2 $self->zilla->log("don't forget to commit and push $local_release_dir");
78 2 $self->zilla->log("download URL: " . $self->url . "$archive");
79 }
80 }
81  
82 3 return;
83 2 };
84  
85 2 __PACKAGE__->meta->make_immutable;
86  
87 }
88  
89 2 1;
90  
91 __END__
« example/unbundle.pl ↑ Summary blib/lib/Dist/Zilla/Plugin/Author/Plicease/Core.pm »