/usr/share/perl5/WWW/Finger/CPAN.pm is in libwww-finger-perl 0.105-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | package WWW::Finger::CPAN;
use 5.010;
use common::sense;
use utf8;
use Digest::MD5 0 qw(md5_hex);
use JSON 2.00 qw(from_json);
use LWP::Simple 0 qw(get);
use parent qw(WWW::Finger);
BEGIN {
$WWW::Finger::CPAN::AUTHORITY = 'cpan:TOBYINK';
$WWW::Finger::CPAN::VERSION = '0.105';
}
sub speed { 50 }
sub new
{
my $class = shift;
my $ident = shift;
my $self = bless {}, $class;
$ident = "mailto:$ident"
unless $ident =~ /^[a-z0-9\.\-\+]+:/i;
$ident = URI->new($ident);
return undef
unless $ident;
$self->{ident} = $ident;
my ($user, $host) = split /\@/, $self->{ident}->to;
return undef
unless lc $host eq 'cpan.org';
return $self;
}
sub name
{
my $self = shift;
my $name = $self->metacpan_data->{name};
return wantarray
? @{ [$name] }
: $name;
}
sub mbox
{
my $self = shift;
my @e = @{$self->metacpan_data->{email}};
return wantarray
? @e
: $e[0];
}
sub pauseid
{
my $self = shift;
my ($user, $host) = split /\@/, uc $self->{ident}->to;
return wantarray
? @{[ $user ]}
: $user;
}
sub cpanpage
{
my $self = shift;
my $user = $self->pauseid;
my $cpanpage = 'https://metacpan.org/author/' . (uc $user) . '/';
return wantarray
? @{[$cpanpage]}
: $cpanpage;
}
sub homepage
{
my $self = shift;
my @hp = @{$self->metacpan_data->{website}};
push @hp, scalar $self->cpanpage
unless grep { $self->cpanpage eq $_ } @hp;
return wantarray
? @hp
: $hp[0];
}
sub image
{
my $self = shift;
my $md5 = lc md5_hex(lc $self->{ident}->to);
return wantarray
? @{ ["http://www.gravatar.com/avatar/$md5.jpg"] }
: "http://www.gravatar.com/avatar/$md5.jpg";
}
sub weblog
{
my $self = shift;
my @blog = map { $_->{url} } @{$self->metacpan_data->{blog}};
return wantarray
? @blog
: $blog[0];
}
sub metacpan_data
{
my $self = shift;
unless ($self->{metacpan_data})
{
my $user = $self->pauseid;
my $uri = sprintf('http://api.metacpan.org/v0/author/%s', uc $user);
$self->{metacpan_data} = from_json(get($uri));
}
$self->{metacpan_data};
}
sub releases
{
my $self = shift;
unless ($self->{releases})
{
my $user = $self->pauseid;
my $uri = sprintf('http://api.metacpan.org/v0/release/_search?q=author:%s%%20AND%%20status:latest&size=100', uc $user);
$self->{releases} = [ map { $_->{_source} } @{ from_json(get($uri))->{hits}->{hits} } ];
}
return wantarray
? @{ $self->{releases} }
: scalar @{ $self->{releases} };
}
sub webid
{
my $self = shift;
my $user = $self->pauseid;
my $webid = 'http://purl.org/NET/cpan-uri/person/' . lc $user;
return wantarray
? @{[ $webid ]}
: $webid;
}
1;
__END__
=head1 NAME
WWW::Finger::CPAN - WWW::Finger implementation using MetaCPAN.
=head1 DESCRIPTION
Additional methods (other than standard WWW::Finger):
=over
=item * C<pauseid> - returns the person's PAUSE ID.
=item * C<cpanpage> - returns the person's metacpan.org homepage.
=item * C<metacpan_data> - hashref of interesting data.
=item * C<releases> - list of releases. If called in scalar context, count of releases.
=back
=head1 SEE ALSO
L<WWW::Finger>.
=head1 AUTHOR
Toby Inkster, E<lt>tobyink@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENCE
Copyright (C) 2009-2012 by Toby Inkster
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
=cut
|