Patch/Release.pm

filter: Statementstmt 79.2% 84 / 106 Branchbran 41.6% 15 / 36 Conditioncond 29.4% 5 / 17 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 82.6% 19 / 23 Podpod 0.0% 0 / 1 totaltotal 63.4% 123 / 194 CC 25 SCAR 17.3
CC
25
Cov
65%
__ANON__
15.0
__ANON__
12.0
__ANON__
6.6
CRAP 5.6
« Patch/Command/Import.pm ↑ Summary Patch/Command/Squash.pm »
1 package Git::CPAN::Patch::Release;
2 5 our $AUTHORITY = 'cpan:YANICK';
3 5 $Git::CPAN::Patch::Release::VERSION = '2.3.4';
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Archive::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use File::Temp qw/ tempdir tempfile /;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 5 use experimental qw/
15 signatures
16 postderef
17 5 ▶/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 has tmpdir => (
20 is => 'ro',
21 isa => 'Path::Tiny',
22 lazy => 1,
23 default => sub {
24 1 ▶ return Path::Tiny->tempdir();
Subroutine __ANON__: called CC=1 SCAR=0.0
25 }
26 5 );
27  
28 has author_name => (
29 is => 'ro',
30 isa => 'Str',
31 lazy => 1,
32 default => sub {
33 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=8 SCAR=27.1
34  
35 1 ▶ if ( $self->meta_info ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->meta_info) 1 0 1
36 1 my $author = $self->meta_info->{metadata}{author};
37 1 ▶ $author = $author->[0] if ref $author;
Branch: 1 branch
BranchTrueFalseTotal
if ref $author 1 0 1
38  
39 1 ▶ if ( !$author or $author eq 'unknown' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $author or $author eq "unknown") 0 1 1
Condition33%1/3
not $author or $author eq "unknown"
l!l&&r!l&&!r
001
MC/DC0%0/2
not $author or $author eq "unknown"
not $author $author eq "unknown"
Truth table33%1/3
not(A) or B
A= not $authorB= $author eq "unknown"
ABresult
1X1
011
000
40 0 $author = $self->meta_info->{author};
41 }
42  
43 1 ▶ return $author =~ /^\s*(.*?)\s*</ ? $1 : $author if $author;
Branch: 2 branches
BranchTrueFalseTotal
if $author 1 0 1
$author =~ /^\s*(.*?)\s*</ ? : 1 0 1
44 }
45  
46 0 ▶ return $self->author_cpan || 'unknown';
Condition0%0/2
$self->author_cpan || 'unknown'
l!l
00
MC/DC0%0/1
$self->author_cpan || 'unknown'
$self->author_cpan
Truth table0%0/2
A
A= $self->author_cpan
Aresult
11
00
47 },
48 5 );
49  
50 has author_cpan => (
51 is => 'ro',
52 isa => 'Maybe[Str]',
53 lazy => 1,
54 default => sub {
55 1 ▶ my $author = eval{$_[0]->meta_info->{author}};
Subroutine __ANON__: called CC=3 SCAR=11.3
56 1 ▶ $author = ref $author ? $author->[0] : $author;
Branch: 1 branch
BranchTrueFalseTotal
ref $author ? : 0 1 1
57 1 ▶ $author = uc($1) if $author =~ /<?(\S+)\@cpan\.org/i;
Branch: 1 branch
BranchTrueFalseTotal
if $author =~ /<?(\S+)\@cpan\.org/i 0 1 1
58 1 return $author;
59 },
60 5 );
61  
62 has author_email => (
63 is => 'ro',
64 isa => 'Maybe[Str]',
65 predicate => 'has_author_email',
66 lazy => 1,
67 default => sub {
68 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=5 SCAR=18.9
69  
70 1 ▶ if ( $self->meta_info ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->meta_info) 1 0 1
71 1 ▶ my $author = $self->meta_info->{metadata}{author} || $self->meta_info->{author};
Condition33%1/3
$self->meta_info->{'metadata'}{'author'} || $self->meta_info->{'author'}
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->meta_info->{'metadata'}{'author'} || $self->meta_info->{'author'}
$self->meta_info->{'metadata'}{'author'} $self->meta_info->{'author'}
Truth table33%1/3
A || B
A= $self->meta_info->{'metadata'}{'author'}B= $self->meta_info->{'author'}
ABresult
1X1
011
000
72 1 ▶ $author = $author->[0] if ref $author;
Branch: 1 branch
BranchTrueFalseTotal
if ref $author 1 0 1
73 1 ▶ return $1 if $author =~ /<(.*?)>\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $author =~ /<(.*?)>\s*$/ 1 0 1
74 }
75 0 return $self->author_cpan . '@cpan.org';
76 },
77 5 );
78  
79 sub author_sig {
80 0 ▶ my $self = shift;
Subroutine author_sig: not called CC=1 SCAR=6.9
Pod undocumented
81  
82 0 return sprintf "%s <%s>", $self->author_name, $self->author_email;
83 }
84  
85 has download_url => (
86 is => 'ro',
87 isa => 'Str',
88 lazy => 1,
89 default => sub {
90 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=8.1
91 1 ▶ return $self->meta_info && $self->meta_info->{download_url};
Condition33%1/3
$self->meta_info && $self->meta_info->{'download_url'}
!ll&&!rl&&r
001
MC/DC0%0/2
$self->meta_info && $self->meta_info->{'download_url'}
$self->meta_info $self->meta_info->{'download_url'}
Truth table33%1/3
A && B
A= $self->meta_infoB= $self->meta_info->{'download_url'}
ABresult
0X0
100
111
92 },
93 5 );
94  
95 has date => (
96 is => 'ro',
97 isa => 'Maybe[Str]',
98 lazy => 1,
99 default => sub {
100 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=8.1
101 1 ▶ return $self->meta_info && $self->meta_info->{date};
Condition33%1/3
$self->meta_info && $self->meta_info->{'date'}
!ll&&!rl&&r
001
MC/DC0%0/2
$self->meta_info && $self->meta_info->{'date'}
$self->meta_info $self->meta_info->{'date'}
Truth table33%1/3
A && B
A= $self->meta_infoB= $self->meta_info->{'date'}
ABresult
0X0
100
111
102 },
103 5 );
104  
105 5 has version => (
106 is => 'ro',
107 isa => 'Str',
108 );
109  
110 has tarball => (
111 is => 'ro',
112 isa => 'Str',
113 lazy => 1,
114 default => sub {
115 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=4 SCAR=16.3
116 1 ▶ if ( $self->download_url ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->download_url) 1 0 1
117  
118 1 my( undef, $file ) = tempfile();
119 1 $file .= ".tar.gz";
120  
121 1 ▶ if ( $self->download_url =~ /^(?:ht|f)tp/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->download_url =~ /^(?:ht|f)tp/) { } 0 1 1
122 0 require LWP::Simple;
123 0 ▶ LWP::Simple::getstore( $self->download_url => $file )
Branch: 1 branch
BranchTrueFalseTotal
LWP::Simple::getstore($self->download_url, $file) or die "could not retrieve ", $self->download_url, "\n" 0 0 0
124 or die "could not retrieve ", $self->download_url, "\n";
125 }
126 else {
127 1 require File::Copy;
128  
129 1 File::Copy::copy( $self->download_url => $file );
130 }
131  
132 1 return $file;
133 }
134  
135 0 return undef;
136 },
137 5 );
138  
139 ▶has extracted_dir => (
Subroutine __ANON__: called CC=2 SCAR=6.9
140 is => 'ro',
141 lazy => 1,
142 default => sub($self) {
143  
144 1 my $archive = Archive::Any->new( $self->tarball );
145 1 my $tmpdir = $self->tmpdir;
146 1 $archive->extract( $tmpdir );
147  
148 1 ▶ return $tmpdir if $archive->is_impolite;
Branch: 1 branch
BranchTrueFalseTotal
if $archive->is_impolite 0 1 1
149  
150 1 my $dir;
151 1 opendir $dir, $tmpdir;
152 1 my( $sub ) = grep { !/^\.\.?$/ } readdir $dir;
153  
154 1 return join '/', $tmpdir, $sub;
155 },
156 5 );
157  
158 ▶has cpan_parse => (
Subroutine __ANON__: not called CC=1 SCAR=6.9
159 is => 'ro',
160 predicate => 'has_cpan_parse',
161 lazy => 1,
162 default => sub($self) {
163 0 require CPAN::ParseDistribution;
164 0 CPAN::ParseDistribution->new( $self->tarball );
165 },
166 5 );
167  
168 has metacpan => (
169 is => 'ro',
170 lazy => 1,
171 default => sub {
172 0 ▶ require MetaCPAN::Client;
Subroutine __ANON__: not called CC=1 SCAR=6.9
173 0 MetaCPAN::Client->new;
174 }
175 5 );
176  
177 ▶has meta_info => (
Subroutine __ANON__: not called CC=3 SCAR=24.8
178 is => 'ro',
179 lazy => 1,
180 predicate => 'has_meta_info',
181 default => sub($self) {
182 0 require MetaCPAN::Client;
183  
184 0 ▶ if( my $release = $self->metacpan->release({ all =>
Branch: 1 branch
BranchTrueFalseTotal
if (my $release = $self->metacpan->release({"all", [{"distribution", $self->dist_name}, {"version", $self->dist_version}]})) 0 0 0
185 [
186 { distribution => $self->dist_name },
187 { version => $self->dist_version },
188 ]
189 }) ) {
190 0 $release = $release->next;
191 0 ▶ return $release->data if $release;
Branch: 1 branch
BranchTrueFalseTotal
if $release 0 0 0
192 }
193  
194 # TODO check on cpan if the info is not there
195  
196 0 require CPAN::Meta;
197  
198 0 my( $result ) = map { CPAN::Meta->load_file($_) }
199 0 grep { $_->exists }
200 0 map { path( $self->extracted_dir )->child( "META.$_" ) } qw/ json yml /;
201  
202 0 return $result;
203  
204 },
205 5 );
206  
207 ▶has dist_version => (
Subroutine __ANON__: called CC=2 SCAR=7.6
208 is => 'ro',
209 lazy => 1,
210 default => sub($self) {
211 $self->has_meta_info
212 ? $self->meta_info->{version}
213 1 ▶ : $self->cpan_parse->distversion
Branch: 1 branch
BranchTrueFalseTotal
$self->has_meta_info ? : 1 0 1
214 },
215 5 );
216  
217 ▶has dist_name => (
Subroutine __ANON__: called CC=3 SCAR=14.2
218 is => 'ro',
219 lazy => 1,
220 default => sub($self) {
221 $self->has_meta_info
222 ? $self->meta_info->{distribution} || $self->meta_info->{name}
223 1 ▶ : $self->cpan_parse->dist
Branch: 1 branch
BranchTrueFalseTotal
$self->has_meta_info ? : 1 0 1
Condition33%1/3
$self->meta_info->{"distribution"} or $self->meta_info->{"name"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->meta_info->{"distribution"} or $self->meta_info->{"name"}
$self->meta_info->{"distribution"} $self->meta_info->{"name"}
Truth table33%1/3
A or B
A= $self->meta_info->{"distribution"}B= $self->meta_info->{"name"}
ABresult
1X1
011
000
224 ;
225 },
226 5 );
227  
228 5 1;
229  
230 __END__
231  
232 =pod
233  
234 =encoding UTF-8
235  
236 =head1 NAME
237  
238 Git::CPAN::Patch::Release
239  
240 =head1 VERSION
241  
242 version 2.3.4
243  
244 =head1 AUTHOR
245  
246 Yanick Champoux <yanick@cpan.org>
247  
248 =head1 COPYRIGHT AND LICENSE
249  
250 This software is copyright (c) 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009 by Yanick Champoux.
251  
252 This is free software; you can redistribute it and/or modify it under
253 the same terms as the Perl 5 programming language system itself.
254  
255 =cut
« Patch/Command/Import.pm ↑ Summary Patch/Command/Squash.pm »