line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
23205
|
use 5.006; # our |
|
3
|
|
|
|
|
6
|
|
2
|
3
|
|
|
3
|
|
10
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
57
|
|
3
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
265
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Role::xPANResolver; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 'v0.3.0'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# FILENAME: xPANResolver.pm |
12
|
|
|
|
|
|
|
# CREATED: 30/10/11 14:05:14 by Kent Fredric (kentnl) <kentfredric@gmail.com> |
13
|
|
|
|
|
|
|
# ABSTRACT: Tools to resolve a package to a URI from a CPAN/DARKPAN mirror. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
3
|
|
365
|
use Moose::Role qw( around ); |
|
3
|
|
|
|
|
286104
|
|
|
3
|
|
|
|
|
19
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
around dump_config => sub { |
29
|
|
|
|
|
|
|
my ( $orig, $self, @args ) = @_; |
30
|
|
|
|
|
|
|
my $config = $self->$orig(@args); |
31
|
|
|
|
|
|
|
my $payload = $config->{ +__PACKAGE__ } = {}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
## no critic (RequireInterpolationOfMetachars) |
34
|
|
|
|
|
|
|
$payload->{ q[$] . __PACKAGE__ . q[::VERSION] } = $VERSION; |
35
|
|
|
|
|
|
|
$payload->{q[$App::Cache::VERSION]} = $App::Cache::VERSION if $INC{'App/Cache.pm'}; |
36
|
|
|
|
|
|
|
$payload->{q[$Parse::CPAN::Packages::VERSION]} = $Parse::CPAN::Packages::VERSION if $INC{'Parse/CPAN/Packages.pm'}; |
37
|
|
|
|
|
|
|
$payload->{q[$URI::VERSION]} = $URI::VERSION if $INC{'URI.pm'}; |
38
|
|
|
|
|
|
|
return $config; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
3
|
|
7917
|
no Moose::Role; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
10
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $c; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _cache { |
46
|
0
|
0
|
|
0
|
|
|
return $c if defined $c; |
47
|
0
|
|
|
|
|
|
$c = do { |
48
|
0
|
|
|
|
|
|
require App::Cache; |
49
|
|
|
|
|
|
|
## no critic (ProhibitMagicNumbers) |
50
|
0
|
|
|
|
|
|
App::Cache->new( |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
ttl => 30 * 60, |
53
|
|
|
|
|
|
|
application => __PACKAGE__, |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
}; |
57
|
0
|
|
|
|
|
|
return $c; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _content_for { |
61
|
0
|
|
|
0
|
|
|
my ( undef, $url ) = @_; |
62
|
0
|
|
|
|
|
|
return _cache->get_url($url); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _parse_for { |
66
|
0
|
|
|
0
|
|
|
my ( $self, $url ) = @_; |
67
|
0
|
|
|
|
|
|
my $cache_url = $url . '#parsed'; |
68
|
0
|
|
|
|
|
|
require Parse::CPAN::Packages; |
69
|
|
|
|
|
|
|
return _cache->get_code( |
70
|
|
|
|
|
|
|
$cache_url, |
71
|
|
|
|
|
|
|
sub { |
72
|
0
|
|
|
0
|
|
|
my $content = $self->_content_for($url); |
73
|
0
|
|
|
|
|
|
return Parse::CPAN::Packages->new($content); |
74
|
|
|
|
|
|
|
}, |
75
|
0
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _resolver_for { |
79
|
0
|
|
|
0
|
|
|
my ( $self, $baseurl ) = @_; |
80
|
0
|
|
|
|
|
|
require URI; |
81
|
0
|
|
|
|
|
|
my $path = URI->new('modules/02packages.details.txt.gz'); |
82
|
0
|
|
|
|
|
|
my $absurl = $path->abs($baseurl)->as_string; |
83
|
0
|
|
|
|
|
|
return $self->_parse_for($absurl); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub resolve_module { |
87
|
0
|
|
|
0
|
1
|
|
my ( $self, $baseurl, $module ) = @_; |
88
|
0
|
|
|
|
|
|
my $p = $self->_resolver_for($baseurl)->package($module); |
89
|
0
|
|
|
|
|
|
my $d = $p->distribution(); |
90
|
0
|
|
|
|
|
|
require URI; |
91
|
0
|
|
|
|
|
|
my $modroot = URI->new('authors/id/')->abs( URI->new($baseurl) ); |
92
|
0
|
|
|
|
|
|
my $modpath = URI->new( $d->prefix )->abs($modroot); |
93
|
0
|
|
|
|
|
|
return $modpath->as_string; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=encoding UTF-8 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Dist::Zilla::Role::xPANResolver - Tools to resolve a package to a URI from a CPAN/DARKPAN mirror. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 VERSION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
version v0.3.0 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 resolve_module |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::xPANResolver'; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub foo { |
119
|
|
|
|
|
|
|
my $self = @_; |
120
|
|
|
|
|
|
|
my $uri = $self->resolve_module( |
121
|
|
|
|
|
|
|
'http://some.darkpan.org', 'FizzBuzz::Bazz' |
122
|
|
|
|
|
|
|
); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This should resolve the Module to the applicable package, and return the most |
126
|
|
|
|
|
|
|
recent distribution. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
It should then return a fully qualified path to that resource suitable for |
129
|
|
|
|
|
|
|
passing to C<wget> or C<cpanm>. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=begin MetaPOD::JSON v1.1.0 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
{ |
134
|
|
|
|
|
|
|
"namespace":"Dist::Zilla::Role::xPANResolver", |
135
|
|
|
|
|
|
|
"interface":"role" |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=end MetaPOD::JSON |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentnl@cpan.org>. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
150
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |