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