Changeset 1065

Show
Ignore:
Timestamp:
11/04/07 01:47:13 (6 years ago)
Author:
charsbar
Message:

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

Location:
lang/perl/Acme-JapaneseCPANAuthors/trunk
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Acme-JapaneseCPANAuthors/trunk/Changes

    r404 r1065  
    11Revision history for Acme-JapaneseCPANAuthors 
     2 
     30.071006 2007/11/04 
     4  - switched to Parse::CPAN::Authors/Packages and Gravatar::URL 
    25 
    360.071006 2007/10/06 
  • lang/perl/Acme-JapaneseCPANAuthors/trunk/MANIFEST

    r341 r1065  
    22lib/Acme/JapaneseCPANAuthors.pm 
    33lib/Acme/JapaneseCPANAuthors/Registered.pm 
     4lib/Acme/JapaneseCPANAuthors/Utils.pm 
    45Makefile.PL 
    56MANIFEST                        This list of files 
  • lang/perl/Acme-JapaneseCPANAuthors/trunk/Makefile.PL

    r404 r1065  
    99  ABSTRACT_FROM  => 'lib/Acme/JapaneseCPANAuthors.pm', 
    1010  PREREQ_PM => { 
    11     'CPAN' => 0,  # not yet sure which version we should require 
    12     'Digest::MD5' => 0, 
    13     'Test::UseAllModules' => 0, 
    14     'URI::Escape' => 0, 
     11    'Gravatar::URL'         => 0, 
     12    'Parse::CPAN::Authors' => 0, 
     13    'Parse::CPAN::Packages' => 0, 
     14    'Test::UseAllModules'  => 0, 
    1515  }, 
    1616  ($ExtUtils::MakeMaker::VERSION >= 6.31 
  • lang/perl/Acme-JapaneseCPANAuthors/trunk/lib/Acme/JapaneseCPANAuthors.pm

    r529 r1065  
    44use warnings; 
    55use Acme::JapaneseCPANAuthors::Registered; 
     6use Acme::JapaneseCPANAuthors::Utils; 
    67 
    7 our $VERSION = '0.071006'; 
     8our $VERSION = '0.071104'; 
    89 
    910sub count { 
     
    4041  return unless $id; 
    4142 
    42   require CPAN; 
    43   my $author = $CPAN::META->instance('CPAN::Author' => $id); 
     43  require Parse::CPAN::Packages; 
     44  my $cpan = Parse::CPAN::Packages->new( _package_file() ); 
    4445 
    45   # ripped from CPAN.pm 
    46   my @checksumfile = $id =~ /(.)(.)(.*)/; 
    47   $checksumfile[1] = join '', @checksumfile[0,1]; 
    48   $checksumfile[2] = join '', @checksumfile[1,2]; 
    49  
    50   { 
    51     my @items = $author->dir_listing([$checksumfile[0], 'CHECKSUMS'], 0, 1); 
    52     # directory not found 
    53     return unless grep { $_->[2] eq $checksumfile[1] } @items; 
    54   } 
    55   { 
    56     my @items = $author->dir_listing([@checksumfile[0,1], 'CHECKSUMS'], 0, 1); 
    57     # directory not found 
    58     return unless grep { $_->[2] eq $checksumfile[2] } @items; 
     46  my @packages; 
     47  foreach my $package ( $cpan->distributions ) { 
     48    if ( $package->cpanid eq $id ) { 
     49      push @packages, $package; 
     50    } 
    5951  } 
    6052 
    61   my @items = $author->dir_listing([@checksumfile, 'CHECKSUMS'], 1, 1 ); 
    62  
    63   my %distros; 
    64   foreach my $item ( @items ) { 
    65     my $file = my $dist_id = $item->[2]; 
    66     next if $file =~ /\.meta/; 
    67     $dist_id =~ s/\-[\w\.]+(\.tar\.gz|\.tgz|\.zip)$//; 
    68     unshift @{ $distros{$dist_id} ||= [] }, "$id/$file"; 
    69   } 
    70  
    71   return %distros; 
     53  return @packages; 
    7254} 
    7355 
     
    7759  return unless $id; 
    7860 
    79   require CPAN; 
    80   my $author = CPAN::Shell->expand_by_method('CPAN::Author' => ['id'] => $id); 
     61  require Parse::CPAN::Authors; 
     62  require Gravatar::URL; 
     63  my $cpan   = Parse::CPAN::Authors->new( _author_file() ); 
     64  my $author = $cpan->author($id); 
    8165 
    82   require Digest::MD5; 
    83   my $cpan_email = $author->email; 
    84   my $gravatar_id = Digest::MD5::md5_hex($cpan_email); 
    85   my $uri = 'http://www.gravatar.com/avatar.php?gravatar_id='.$gravatar_id; 
    86   if ( $options{default} ) { 
    87     require URI::Escape; 
    88     $uri .= '&default='.URI::Escape::uri_escape($options{default}); 
    89   } 
    90   if ( $options{size} ) { 
    91     $uri .= '&size='.$options{size}; 
    92   } 
    93   if ( $options{rating} ) { 
    94     $uri .= '&rating='.$options{rating}; 
    95   } 
    96   return $uri; 
     66  return Gravatar::URL::gravatar_url( email => $author->email, %options ); 
    9767} 
    9868 
     
    140110=head2 distributions 
    141111 
    142 returns a hash whose keys are distribution names written/owned 
    143 by the person of the id, and the values are arrayrefs of the 
    144 distribution ids, with which you can create CPAN::Distribution 
    145 or CPAN::DistnameInfo object. 
     112returns an array of Parse::CPAN::Packages::Distribution objects 
     113for the person of the id. 
    146114 
    147115=head2 avatar