| 1 | package Acme::JapaneseCPANAuthors; |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use Acme::JapaneseCPANAuthors::Registered; |
|---|
| 6 | use Acme::JapaneseCPANAuthors::Utils; |
|---|
| 7 | |
|---|
| 8 | our $VERSION = '0.071104'; |
|---|
| 9 | |
|---|
| 10 | sub count { |
|---|
| 11 | my $class = shift; |
|---|
| 12 | |
|---|
| 13 | return scalar keys %JAPANESE_AUTHORS; |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | sub 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 | |
|---|
| 27 | sub 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 | |
|---|
| 38 | sub 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 | |
|---|
| 56 | sub 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 | |
|---|
| 69 | 1; |
|---|
| 70 | |
|---|
| 71 | __END__ |
|---|
| 72 | |
|---|
| 73 | =head1 NAME |
|---|
| 74 | |
|---|
| 75 | Acme::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 | |
|---|
| 87 | Sometimes we just want to know something to confirm we're not |
|---|
| 88 | alone, or to see if we're doing right things, or to look for |
|---|
| 89 | someone we can rely on. This module provides you some basic |
|---|
| 90 | information on us. |
|---|
| 91 | |
|---|
| 92 | =head1 METHODS |
|---|
| 93 | |
|---|
| 94 | =head2 count |
|---|
| 95 | |
|---|
| 96 | returns how many (registered) Japanese authors are known, |
|---|
| 97 | or at least have some module(s). |
|---|
| 98 | |
|---|
| 99 | =head2 id |
|---|
| 100 | |
|---|
| 101 | returns all the registered ids by default. If called with an |
|---|
| 102 | id, this returns if there's a registered Japanese author of |
|---|
| 103 | the id. |
|---|
| 104 | |
|---|
| 105 | =head2 name |
|---|
| 106 | |
|---|
| 107 | returns all the registered users' name by default. If called |
|---|
| 108 | with an id, this returns the name of the author of the id. |
|---|
| 109 | |
|---|
| 110 | =head2 distributions |
|---|
| 111 | |
|---|
| 112 | returns an array of Parse::CPAN::Packages::Distribution objects |
|---|
| 113 | for the person of the id. |
|---|
| 114 | |
|---|
| 115 | =head2 avatar |
|---|
| 116 | |
|---|
| 117 | returns gravatar uri of the id shown at search.cpan.org. |
|---|
| 118 | see L<http://site.gravatar.com/site/implement> for details. |
|---|
| 119 | |
|---|
| 120 | =head1 AUTHOR |
|---|
| 121 | |
|---|
| 122 | Kenichi Ishigaki, E<lt>ishigaki at cpan.orgE<gt> |
|---|
| 123 | |
|---|
| 124 | =head1 COPYRIGHT AND LICENSE |
|---|
| 125 | |
|---|
| 126 | Copyright (C) 2007 by Kenichi Ishigaki. |
|---|
| 127 | |
|---|
| 128 | This program is free software; you can redistribute it and/or |
|---|
| 129 | modify it under the same terms as Perl itself. |
|---|
| 130 | |
|---|
| 131 | =cut |
|---|