Acme-CPANAuthors-CPAN-OneHundred

 view release on metacpan or  search on metacpan

examples/templates/t/10cpanauthor.t  view on Meta::CPAN

#!perl
use strict;
use warnings;
use Test::More;

plan skip_all => "can't load Acme::CPANAuthors"
    unless eval "use Acme::CPANAuthors; 1";
plan tests => 9;

my $authors  = eval { Acme::CPANAuthors->new("CPAN::OneHundred") };
is( $@, "", "creating a new Acme::CPANAuthors object with CPAN 100 authors" );
isa_ok( $authors, "Acme::CPANAuthors" );

my $number = [% COUNT %];
is( $authors->count, $number, " .. \$authors->count matches current count" );

my @ids = $authors->id;
cmp_ok( ~~@ids, ">", 0, " .. \$authors->id gives a non-empty list" );
is( ~~@ids, $number, " .. \$authors->id equals \$authors->count" );

SKIP: {
    my $file;
    eval { $file = Acme::CPANAuthors::Utils::_cpan_authors_file() };
    skip "CPAN configuration not available", 4 if($@ || !$file);

    $file = undef;
    eval { $file = Acme::CPANAuthors::Utils::_cpan_packages_file() };
    skip "CPAN configuration not available", 4 if($@ || !$file);

    my @distros  = $authors->distributions('[% TOPDOG %]');
    cmp_ok( ~~@distros, ">", 0, " .. \$authors->distributions('[% TOPDOG %]') gives a non-empty list" );

    @distros = $authors->distributions('XXXXXX');
    cmp_ok( ~~@distros, "==", 0, " .. \$authors->distributions('XXXXXX') gives an empty list" );

    my $name = $authors->name('[% TOPDOG %]');
    is($name, "[% TOPCAT %]", " .. \$authors->name('[% TOPDOG %]') returns [% TOPCAT %]" );

#    SKIP: {
#        skip "en.gravatar.com is not available", 2
#            if(pingtest('en.gravatar.com'));
#
#        my $url;
#        eval { $url = $authors->avatar_url('[% TOPDOG %]') };
#        skip "en.gravatar.com is not available", 1 if($@);
#        $url ||= '';
#        is($url, 'http://www.gravatar.com/avatar/2459f554c069e44527716e3f35e1d0d1', ".. \$authors->avatar_url('[% TOPDOG %]') returns a URL" );
#
#        eval { $url = $authors->avatar_url('BARBIE') };
#        skip "en.gravatar.com is not available", 1 if($@);
#        $url ||= '';
#        cmp_ok( length($url), ">", 0, " .. \$authors->avatar_url('BINGOS') gives a non-empty string" );
#    }

    SKIP: {
        skip "api.cpanauthors.org is not available", 1
            if(pingtest('api.cpanauthors.org'));

        my $kwalitee;
        eval { $kwalitee = $authors->kwalitee('[% TOPDOG %]') };
        skip "api.cpanauthors.org is not available", 1 if($@);
        isa_ok( $kwalitee, "HASH", " .. \$authors->kwalitee('[% TOPDOG %]')" );
    }
}

sub pingtest {
    my $domain = shift or return 1;
    my $cmd =   $^O =~ /solaris/i                           ? "ping -s $domain 56 1" :
                $^O =~ /dos|os2|mswin32|netware|cygwin/i    ? "ping -n 1 $domain "
                                                            : "ping -c 1 $domain >/dev/null 2>&1";

    eval { system($cmd) }; 
    if($@) {                # can't find ping, or wrong arguments?
        diag($@);
        return 1;
    }

    my $retcode = $? >> 8;  # ping returns 1 if unable to connect
    return $retcode;
}

examples/update100.pl  view on Meta::CPAN

    $line =~ s/^\s+(.*?)/        $1/;
    $line =~ s/^\s+(.*?)/        - $1/ unless($line =~ /^\s+[\[\-]/);
    $content .= "$line\n";
}
print $fh $content;
$fh->close;

# update other files
my $parser = Template->new(\%config);        # initialise parser
for my $template (@files) {
    eval {
        # parse to text
        $parser->process($template,\%tvars,$template) or die $parser->error();
    };

    die "TT PARSER ERROR: eval=$@, error=" . $parser->error  if($@);
}

# now store new data
system("cp data/cpan100.csv data/cpan100.old.csv ");
system("mv cpan100.csv data");

if($options{build}) {
    # build tarball
    system("perl Makfile.PL");
    system("make dist");

t/10cpanauthor.t  view on Meta::CPAN

#!perl
use strict;
use warnings;
use Test::More;

plan skip_all => "can't load Acme::CPANAuthors"
    unless eval "use Acme::CPANAuthors; 1";
plan tests => 9;

my $authors  = eval { Acme::CPANAuthors->new("CPAN::OneHundred") };
is( $@, "", "creating a new Acme::CPANAuthors object with CPAN 100 authors" );
isa_ok( $authors, "Acme::CPANAuthors" );

my $number = 41;
is( $authors->count, $number, " .. \$authors->count matches current count" );

my @ids = $authors->id;
cmp_ok( ~~@ids, ">", 0, " .. \$authors->id gives a non-empty list" );
is( ~~@ids, $number, " .. \$authors->id equals \$authors->count" );

SKIP: {
    my $file;
    eval { $file = Acme::CPANAuthors::Utils::_cpan_authors_file() };
    skip "CPAN configuration not available", 4 if($@ || !$file);

    $file = undef;
    eval { $file = Acme::CPANAuthors::Utils::_cpan_packages_file() };
    skip "CPAN configuration not available", 4 if($@ || !$file);

    my @distros  = $authors->distributions('PERLANCAR');
    cmp_ok( ~~@distros, ">", 0, " .. \$authors->distributions('PERLANCAR') gives a non-empty list" );

    @distros = $authors->distributions('XXXXXX');
    cmp_ok( ~~@distros, "==", 0, " .. \$authors->distributions('XXXXXX') gives an empty list" );

    my $name = $authors->name('PERLANCAR');
    is($name, "perlancar", " .. \$authors->name('PERLANCAR') returns perlancar" );

#    SKIP: {
#        skip "en.gravatar.com is not available", 2
#            if(pingtest('en.gravatar.com'));
#
#        my $url;
#        eval { $url = $authors->avatar_url('PERLANCAR') };
#        skip "en.gravatar.com is not available", 1 if($@);
#        $url ||= '';
#        is($url, 'http://www.gravatar.com/avatar/2459f554c069e44527716e3f35e1d0d1', ".. \$authors->avatar_url('PERLANCAR') returns a URL" );
#
#        eval { $url = $authors->avatar_url('BARBIE') };
#        skip "en.gravatar.com is not available", 1 if($@);
#        $url ||= '';
#        cmp_ok( length($url), ">", 0, " .. \$authors->avatar_url('BINGOS') gives a non-empty string" );
#    }

    SKIP: {
        skip "api.cpanauthors.org is not available", 1
            if(pingtest('api.cpanauthors.org'));

        my $kwalitee;
        eval { $kwalitee = $authors->kwalitee('PERLANCAR') };
        skip "api.cpanauthors.org is not available", 1 if($@);
        isa_ok( $kwalitee, "HASH", " .. \$authors->kwalitee('PERLANCAR')" );
    }
}

sub pingtest {
    my $domain = shift or return 1;
    my $cmd =   $^O =~ /solaris/i                           ? "ping -s $domain 56 1" :
                $^O =~ /dos|os2|mswin32|netware|cygwin/i    ? "ping -n 1 $domain "
                                                            : "ping -c 1 $domain >/dev/null 2>&1";

    eval { system($cmd) }; 
    if($@) {                # can't find ping, or wrong arguments?
        diag($@);
        return 1;
    }

    my $retcode = $? >> 8;  # ping returns 1 if unable to connect
    return $retcode;
}

t/90podtest.t  view on Meta::CPAN

#!perl -T
use strict;
use warnings;

use Test::More;

# Skip if doing a regular install
plan skip_all => "Author tests not required for installation"
    unless ( $ENV{AUTOMATED_TESTING} );

eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();

t/91podcover.t  view on Meta::CPAN

#!perl -T
use strict;
use warnings;

use Test::More;

# Skip if doing a regular install
plan skip_all => "Author tests not required for installation"
    unless ( $ENV{AUTOMATED_TESTING} );

eval "use Test::Pod::Coverage 0.08";
plan skip_all => "Test::Pod::Coverage 0.08 required for testing POD coverage" if $@;
all_pod_coverage_ok();

t/94metatest.t  view on Meta::CPAN

#!perl -T
use strict;
use warnings;

use Test::More;

# Skip if doing a regular install
plan skip_all => "Author tests not required for installation"
    unless ( $ENV{AUTOMATED_TESTING} );

eval "use Test::CPAN::Meta";
plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@;

plan 'no_plan';

my $meta = meta_spec_ok(undef,undef,@_);

use Acme::CPANAuthors::CPAN::OneHundred;
my $version = $Acme::CPANAuthors::CPAN::OneHundred::VERSION;

is($meta->{version},$version,
    'META.yml distribution version matches');

if($meta->{provides}) {
    for my $mod (keys %{$meta->{provides}}) {
        is($meta->{provides}{$mod}{version},$version,
            "META.yml entry [$mod] version matches distribution version");

        eval "require $mod";
        my $VERSION = '$' . $mod . '::VERSION';
        my $v = eval "$VERSION";
        is($meta->{provides}{$mod}{version},$v,
            "META.json entry [$mod] version matches module version");

        isnt($meta->{provides}{$mod}{version},0);
    }
}

t/96metatest.t  view on Meta::CPAN

#!perl -T
use strict;
use warnings;

use Test::More;

# Skip if doing a regular install
plan skip_all => "Author tests not required for installation"
    unless ( $ENV{AUTOMATED_TESTING} );

eval "use Test::CPAN::Meta::JSON";
plan skip_all => "Test::CPAN::Meta::JSON required for testing META.json files" if $@;

plan 'no_plan';

my $meta = meta_spec_ok(undef,undef,@_);

use Acme::CPANAuthors::CPAN::OneHundred;
my $version = $Acme::CPANAuthors::CPAN::OneHundred::VERSION;

is($meta->{version},$version,
    'META.json distribution version matches');

if($meta->{provides}) {
    for my $mod (keys %{$meta->{provides}}) {
        is($meta->{provides}{$mod}{version},$version,
            "META.json entry [$mod] version matches distribution version");

        eval "require $mod";
        my $VERSION = '$' . $mod . '::VERSION';
        my $v = eval "$VERSION";
        is($meta->{provides}{$mod}{version},$v,
            "META.json entry [$mod] version matches module version");

        isnt($meta->{provides}{$mod}{version},0);
    }
}



( run in 0.628 second using v1.01-cache-2.11-cpan-98e64b0badf )