Acme-Pi
view release on metacpan or search on metacpan
inc/MyCheckVersionIncremented.pm view on Meta::CPAN
use Encode ();
use YAML::Tiny;
use CPAN::DistnameInfo;
# copied from [PromptIfStale] - TODO use CPAN::Common::Index instead.
sub _indexed_distversion_via_query
{
my ($self, $module) = @_;
my $url = 'http://cpanmetadb.plackperl.org/v1.0/package/' . $module;
$self->log_debug([ 'fetching %s', $url ]);
my $res = HTTP::Tiny->new->get($url);
$self->log('could not query the index?'), return undef if not $res->{success};
my $data = $res->{content};
if (my $charset = HTTP::Headers->new(%{ $res->{headers} })->content_type_charset)
{
$data = Encode::decode($charset, $data, Encode::FB_CROAK);
}
$self->log_debug([ 'got response: %s', $data ]);
my $payload = YAML::Tiny->read_string($data);
$self->log('invalid payload returned?'), return undef unless $payload;
$self->log_debug([ '%s not indexed', $module ]), return undef if not defined $payload->[0]{version};
return CPAN::DistnameInfo->new($payload->[0]{distfile})->version;
}
1;
( run in 2.124 seconds using v1.01-cache-2.11-cpan-3cd7ad12f66 )