line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Socialtext::CPANWiki::RSSFeed; |
2
|
1
|
|
|
1
|
|
12
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
488
|
use XML::Liberal; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use LWP::Simple qw/get/; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
|
|
|
|
|
|
my $class = shift; |
9
|
|
|
|
|
|
|
my $self = { |
10
|
|
|
|
|
|
|
rdf_uri => 'http://search.cpan.org/uploads.rdf', |
11
|
|
|
|
|
|
|
@_, |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
bless $self, $class; |
14
|
|
|
|
|
|
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=for comment |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
{ # example |
20
|
|
|
|
|
|
|
'link' => 'http://search.cpan.org/~dmaki/XML-RSS-LibXML-0.30_01/', |
21
|
|
|
|
|
|
|
'desc' => 'XML::RSS with XML::LibXML', |
22
|
|
|
|
|
|
|
'version' => '0.30_01', |
23
|
|
|
|
|
|
|
'name' => 'XML-RSS-LibXML', |
24
|
|
|
|
|
|
|
'author' => 'Daisuke Maki', |
25
|
|
|
|
|
|
|
'pause_id' => 'dmaki' |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub parse_feed { |
31
|
|
|
|
|
|
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $uri = $self->{rdf_uri}; |
34
|
|
|
|
|
|
|
my $rdf = get($uri); |
35
|
|
|
|
|
|
|
die "Couldn't get rdf" unless $rdf; |
36
|
|
|
|
|
|
|
my $parser = XML::Liberal->new( 'LibXML' ); |
37
|
|
|
|
|
|
|
my $doc = $parser->parse_string($rdf); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
print "Fetching latest cpan rss ...\n"; |
40
|
|
|
|
|
|
|
my @items = $doc->getElementsByTagName('item'); |
41
|
|
|
|
|
|
|
die "No items in $uri!\n" unless @items; |
42
|
|
|
|
|
|
|
my @releases; |
43
|
|
|
|
|
|
|
for my $i (@items) { |
44
|
|
|
|
|
|
|
my $r = _parse_release($i); |
45
|
|
|
|
|
|
|
next unless $r; |
46
|
|
|
|
|
|
|
push @releases, $r; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
return \@releases; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _parse_release { |
52
|
|
|
|
|
|
|
my $i = shift; |
53
|
|
|
|
|
|
|
my ($title_elem) = $i->getElementsByTagName('title'); |
54
|
|
|
|
|
|
|
my $package_string = $title_elem->textContent; |
55
|
|
|
|
|
|
|
return if $package_string eq 'search.cpan.org'; |
56
|
|
|
|
|
|
|
unless ($package_string =~ m/(.+)-(v?\d+(?:\.[\d_]+)+)$/) { |
57
|
|
|
|
|
|
|
warn "Couldn't parse version: $package_string"; |
58
|
|
|
|
|
|
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
my %release = ( |
61
|
|
|
|
|
|
|
name => $1, |
62
|
|
|
|
|
|
|
version => $2, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my ($link_elem) = $i->getElementsByTagName('link'); |
66
|
|
|
|
|
|
|
$release{link} = $link_elem->textContent; |
67
|
|
|
|
|
|
|
$release{pause_id} = $1 if $release{link} =~ m#search\.cpan\.org/~(\w+)/#; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my ($desc_elem) = $i->getElementsByTagName('description'); |
70
|
|
|
|
|
|
|
$release{desc} = $desc_elem ? $desc_elem->textContent : 'No description'; |
71
|
|
|
|
|
|
|
my ($author_elem) = $i->getElementsByTagName('dc:creator'); |
72
|
|
|
|
|
|
|
$release{author} = $author_elem->textContent; |
73
|
|
|
|
|
|
|
return \%release; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |