line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
9154
|
use strict; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
597
|
|
2
|
15
|
|
|
15
|
|
78
|
use warnings; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
673
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::File; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$MetaCPAN::API::File::VERSION = '0.44'; |
6
|
15
|
|
|
15
|
|
83
|
use Carp; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
1353
|
|
7
|
15
|
|
|
15
|
|
78
|
use Any::Moose 'Role'; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
84
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub file { |
14
|
6
|
|
|
6
|
0
|
5534
|
my $self = shift; |
15
|
6
|
|
|
|
|
13
|
my $url = ''; |
16
|
6
|
|
|
|
|
14
|
my $error = "Either provide a module name, 'id', or 'author and 'release' and an optional 'path'"; |
17
|
|
|
|
|
|
|
|
18
|
6
|
100
|
|
|
|
28
|
if ( @_ == 1 ) { |
|
|
100
|
|
|
|
|
|
19
|
1
|
|
|
|
|
3
|
$url = 'module/' . shift; |
20
|
|
|
|
|
|
|
} elsif ( @_ ) { |
21
|
4
|
|
|
|
|
15
|
my %opts = @_; |
22
|
|
|
|
|
|
|
|
23
|
4
|
100
|
66
|
|
|
37
|
if ( defined ( my $id = $opts{'id'} ) ) { |
|
|
100
|
|
|
|
|
|
24
|
1
|
|
|
|
|
5
|
$url = "file/$id"; |
25
|
|
|
|
|
|
|
} elsif ( |
26
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
27
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) |
28
|
|
|
|
|
|
|
) { |
29
|
2
|
|
100
|
|
|
15
|
my $path = $opts{'path'} || ''; |
30
|
2
|
|
|
|
|
13
|
$url = "file/$author/$release/$path"; |
31
|
|
|
|
|
|
|
} else { |
32
|
1
|
|
|
|
|
88
|
croak $error; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
205
|
croak $error; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
22
|
return $self->fetch( $url ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
MetaCPAN::API::File - File information for MetaCPAN::API |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
version 0.44 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This role provides MetaCPAN::API with fetching file information about modules |
59
|
|
|
|
|
|
|
and distribution releases. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 METHODS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $result = $mcpan->file( |
66
|
|
|
|
|
|
|
author => 'DOY', |
67
|
|
|
|
|
|
|
release => 'Moose-2.0201', |
68
|
|
|
|
|
|
|
path => 'lib/Moose.pm', |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# or |
72
|
|
|
|
|
|
|
my $result = $mcpan->file( |
73
|
|
|
|
|
|
|
author => 'DOY', |
74
|
|
|
|
|
|
|
release => 'Moose-2.0201', |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# or |
78
|
|
|
|
|
|
|
my $result1 = $mcpan->file('MetaCPAN::API'); |
79
|
|
|
|
|
|
|
my $result2 = $mcpan->file( id => 'EMfoAvoYhHpUK8MVJSkm4KN5GmY' ); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Searches MetaCPAN for a module or a specific release and returns |
82
|
|
|
|
|
|
|
file/directory information. If path is omitted, it gets information |
83
|
|
|
|
|
|
|
on the root directory. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Sawyer X <xsawyerx@cpan.org> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Sawyer X. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
94
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|