Acme-CPANAuthors

 view release on metacpan or  search on metacpan

lib/Acme/CPANAuthors.pm  view on Meta::CPAN

  }

  return @packages;
}

sub avatar_url {
  my ($self, $id, %options) = @_;

  return unless $id;

  eval {require Gravatar::URL; 1}
      or warn($@), return;
  my $author = cpan_authors->author($id) or return;

  my $default = delete $options{default};
  return Gravatar::URL::gravatar_url(
    email => $author->email,
    %options,
    default => Gravatar::URL::gravatar_url(
      # Fall back to the CPAN address, as used by metacpan, which will in
      # turn fall back to a generated image.

lib/Acme/CPANAuthors.pm  view on Meta::CPAN


sub _get_authors_of {
  my $category = shift;

  $category =~ s/^Acme::CPANAuthors:://;

  return if $category =~ /^(?:Register|Utils|Search)$/;

  my $package = "Acme::CPANAuthors\::$category";
  unless ($package->can('authors')) {
    eval "require $package";
    if ( $@ ) {
      carp "$category CPAN Authors are not registered yet: $@";
      return;
    }
    # some may actually lack 'authors' interface
    return unless $package->can('authors');
  }
  $package->authors;
}

lib/Acme/CPANAuthors/Utils.pm  view on Meta::CPAN

  my ($dir, $basename) = @_;

  my $file;
  if ($ENV{ACME_CPANAUTHORS_HOME}) {
    $file = _catfile($ENV{ACME_CPANAUTHORS_HOME}, $dir, $basename);
    return $file if $file && -r $file;
  }
  require File::Path;
  for my $parent (File::Spec->tmpdir, '.') {
    my $tmpdir = File::Spec->catdir($parent, '.acmecpanauthors', $dir);
    eval { File::Path::mkpath($tmpdir) };
    next unless -d $tmpdir && -r _;
    $file = _catfile($tmpdir, $basename);
    my $how_old = -M $file;
    if (!-r $file or !$how_old or $how_old > 1) {
      require HTTP::Tiny;
      my $ua = HTTP::Tiny->new(env_proxy => 1);
      my $res = $ua->mirror('http://www.cpan.org/'.$dir.'/'.$basename, $file);
      next unless $res->{success};
    }
    return $file if -r $file;

lib/Acme/CPANAuthors/Utils/Kwalitee.pm  view on Meta::CPAN

sub fetch {
  my ($class, $id) = @_;

  return unless $id;

  my $res = $class->_ua->get(_uri(lc $id));
  unless ($res->{success} && $res->{status} == 200) {
    $class->_error("$res->{status} $res->{reason}");
  }

  my $json = eval { JSON::PP::decode_json($res->{content}) };
  if ($@) {
    $class->_error($@);
  }
  return $json;
}

sub _error {
  my ($class, $error) = @_;

  die "API SERVER ERROR\n"

lib/Acme/CPANAuthors/Utils/Packages.pm  view on Meta::CPAN

  return unless defined $dist->version && $dist->dist;

  # see if it's latest
  my $distname = $info->dist;
  my $latest = $self->{latest_dists}{$distname};
  unless ($latest) {
    $self->{latest_dists}{$distname} = $dist;
    return $dist;
  }
  my ($distv, $latestv);
  eval {
    no warnings;
    $distv   = version->new( $dist->version   || 0 );
    $latestv = version->new( $latest->version || 0 );
  };
  if ($distv && $latestv) {
    if ($distv > $latestv) {
      $self->{latest_dists}{$distname} = $dist;
    }
  }
  else {

t/03_extra.t  view on Meta::CPAN

use strict;
use warnings;
use lib 't/lib';
use Test::More;
use Acme::CPANAuthors;

BEGIN {
  eval {require Gravatar::URL; 1} or
    plan skip_all => "this test requires Gravatar::URL";
}

plan tests => 1;

local $ENV{ACME_CPANAUTHORS_HOME} = 't/data';

my $authors = Acme::CPANAuthors->new('TestExtra');

my $avatar_url = $authors->avatar_url('AADLER');

t/05_kwalitee.t  view on Meta::CPAN

use strict;
use warnings;
use lib 't/lib';
use Test::More 0.88;
use Acme::CPANAuthors;

SKIP: {
  my $kwalitee = eval { Acme::CPANAuthors->kwalitee('ISHIGAKI') };
  if ($@) {
    skip "API server seems down; sorry for the inconvenience", 3;
  }
  ok ref $kwalitee eq 'HASH' && %$kwalitee;
  ok $kwalitee->{info},          "has info";
  ok $kwalitee->{distributions}, "has distributions";
}

done_testing;

t/06_parse_mailrc.t  view on Meta::CPAN


# try with the gzipped filename
$p = Acme::CPANAuthors::Utils::Authors->new($gzfilename);
is_fine($p);

# try with the contents
#$p = Acme::CPANAuthors::Utils::Authors->new($contents);
#is_fine($p);

# try with fake filename
eval { Acme::CPANAuthors::Utils::Authors->new("xyzzy") };
like $@ => qr/Failed to read/;

# try with fake gzipped filename
eval { Acme::CPANAuthors::Utils::Authors->new("xyzzy.gz") };
like $@ => qr/Failed to read/;

sub is_fine {
    my $p = shift;

    isa_ok( $p, 'Acme::CPANAuthors::Utils::Authors' );

    my $a = $p->author('AASSAD');
    isa_ok( $a, 'Acme::CPANAuthors::Utils::Authors::Author' );
    is( $a->pauseid, 'AASSAD' );

t/08_inline_package.t  view on Meta::CPAN


package # hide from pause
  Acme::CPANAuthors::TestInline;
use Acme::CPANAuthors::Register (
  ISHIGAKI => 'Kenichi Ishigaki',
);

package main;
use Acme::CPANAuthors;

my $authors = eval { Acme::CPANAuthors->new('TestInline') };
ok !$@, "no errors";
ok $authors && $authors->name('ISHIGAKI') eq 'Kenichi Ishigaki', "got a correct name";

t/99_pod.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;

eval "use Test::Pod 1.18";
plan skip_all => 'Test::Pod 1.18 required' if $@;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
all_pod_files_ok();

t/99_podcoverage.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;

eval "use Test::Pod::Coverage 1.04";
plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};

all_pod_coverage_ok();



( run in 1.393 second using v1.01-cache-2.11-cpan-ceb78f64989 )