line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
8488
|
use strict; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
657
|
|
2
|
15
|
|
|
15
|
|
86
|
use warnings; |
|
15
|
|
|
|
|
24
|
|
|
15
|
|
|
|
|
709
|
|
3
|
|
|
|
|
|
|
package MetaCPAN::API::Source; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$MetaCPAN::API::Source::VERSION = '0.44'; |
6
|
15
|
|
|
15
|
|
73
|
use Carp; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
1069
|
|
7
|
15
|
|
|
15
|
|
89
|
use Any::Moose 'Role'; |
|
15
|
|
|
|
|
27
|
|
|
15
|
|
|
|
|
92
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub source { |
11
|
3
|
|
|
3
|
1
|
9596
|
my $self = shift; |
12
|
3
|
100
|
|
|
|
19
|
my %opts = @_ ? @_ : (); |
13
|
3
|
|
|
|
|
8
|
my $url = ''; |
14
|
3
|
|
|
|
|
4
|
my $error = "Provide 'author' and 'release' and 'path'"; |
15
|
|
|
|
|
|
|
|
16
|
3
|
100
|
|
|
|
199
|
%opts or croak $error; |
17
|
|
|
|
|
|
|
|
18
|
2
|
100
|
66
|
|
|
27
|
if ( |
|
|
|
66
|
|
|
|
|
19
|
|
|
|
|
|
|
defined ( my $author = $opts{'author'} ) && |
20
|
|
|
|
|
|
|
defined ( my $release = $opts{'release'} ) && |
21
|
|
|
|
|
|
|
defined ( my $path = $opts{'path'} ) |
22
|
|
|
|
|
|
|
) { |
23
|
1
|
|
|
|
|
6
|
$url = "source/$author/$release/$path"; |
24
|
|
|
|
|
|
|
} else { |
25
|
1
|
|
|
|
|
127
|
croak $error; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
10
|
$url = $self->base_url . "/$url"; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
18
|
my $result = $self->ua->get($url); |
31
|
1
|
50
|
|
|
|
29270
|
$result->{'success'} |
32
|
|
|
|
|
|
|
or croak "Failed to fetch '$url': " . $result->{'reason'}; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
172
|
return $result->{'content'}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=pod |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
MetaCPAN::API::Source - Source information for MetaCPAN::API |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 VERSION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
version 0.44 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This role provides MetaCPAN::API with fetching of source files. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 source |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $source = $mcpan->source( |
60
|
|
|
|
|
|
|
author => 'DOY', |
61
|
|
|
|
|
|
|
release => 'Moose-2.0201', |
62
|
|
|
|
|
|
|
path => 'lib/Moose.pm', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Searches MetaCPAN for a module or a specific release and returns the plain |
66
|
|
|
|
|
|
|
source. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Renee Baecker <module@renee-baecker.de> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Renee Baecker. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
77
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Sawyer X <xsawyerx@cpan.org> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Sawyer X. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
88
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|