root/lang/perl/Acme-JapaneseCPANAuthors/trunk/lib/Acme/JapaneseCPANAuthors.pm

Revision 1065, 2.6 kB (checked in by charsbar, 14 months ago)

lang/perl/Acme-JapaneseCPANAuthors: switched to use Parse::CPAN::Authors/Packages and Gravatar::URL

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1package Acme::JapaneseCPANAuthors;
2
3use strict;
4use warnings;
5use Acme::JapaneseCPANAuthors::Registered;
6use Acme::JapaneseCPANAuthors::Utils;
7
8our $VERSION = '0.071104';
9
10sub count {
11  my $class = shift;
12
13  return scalar keys %JAPANESE_AUTHORS;
14}
15
16sub id {
17  my ($class, $id) = @_;
18
19  unless ( $id ) {
20    return sort keys %JAPANESE_AUTHORS;
21  }
22  else {
23    return $JAPANESE_AUTHORS{$id} ? 1 : 0;
24  }
25}
26
27sub name {
28  my ($class, $id) = @_;
29
30  unless ( $id ) {
31    return sort values %JAPANESE_AUTHORS;
32  }
33  else {
34    return $JAPANESE_AUTHORS{$id};
35  }
36}
37
38sub distributions {
39  my ($class, $id) = @_;
40
41  return unless $id;
42
43  require Parse::CPAN::Packages;
44  my $cpan = Parse::CPAN::Packages->new( _package_file() );
45
46  my @packages;
47  foreach my $package ( $cpan->distributions ) {
48    if ( $package->cpanid eq $id ) {
49      push @packages, $package;
50    }
51  }
52
53  return @packages;
54}
55
56sub avatar {
57  my ($class, $id, %options) = @_;
58
59  return unless $id;
60
61  require Parse::CPAN::Authors;
62  require Gravatar::URL;
63  my $cpan   = Parse::CPAN::Authors->new( _author_file() );
64  my $author = $cpan->author($id);
65
66  return Gravatar::URL::gravatar_url( email => $author->email, %options );
67}
68
691;
70
71__END__
72
73=head1 NAME
74
75Acme::JapaneseCPANAuthors - We are Japanese CPAN authors
76
77=head1 SYNOPSIS
78
79    use Acme::JapaneseCPANAuthors;
80    $number  = Acme::JapaneseCPANAuthors->count;
81    @ids     = Acme::JapaneseCPANAuthors->id;
82    %distros = Acme::JapaneseCPANAuthors->distributions('ISHIGAKI');
83    $uri     = Acme::JapaneseCPANAuthors->avatar('MIYAGAWA');
84
85=head1 DESCRIPTION
86
87Sometimes we just want to know something to confirm we're not
88alone, or to see if we're doing right things, or to look for
89someone we can rely on. This module provides you some basic
90information on us.
91
92=head1 METHODS
93
94=head2 count
95
96returns how many (registered) Japanese authors are known,
97or at least have some module(s).
98
99=head2 id
100
101returns all the registered ids by default. If called with an
102id, this returns if there's a registered Japanese author of
103the id.
104
105=head2 name
106
107returns all the registered users' name by default. If called
108with an id, this returns the name of the author of the id.
109
110=head2 distributions
111
112returns an array of Parse::CPAN::Packages::Distribution objects
113for the person of the id.
114
115=head2 avatar
116
117returns gravatar uri of the id shown at search.cpan.org.
118see L<http://site.gravatar.com/site/implement> for details.
119
120=head1 AUTHOR
121
122Kenichi Ishigaki, E<lt>ishigaki at cpan.orgE<gt>
123
124=head1 COPYRIGHT AND LICENSE
125
126Copyright (C) 2007 by Kenichi Ishigaki.
127
128This program is free software; you can redistribute it and/or
129modify it under the same terms as Perl itself.
130
131=cut
Note: See TracBrowser for help on using the browser.