Dist-Zilla-Plugin-CheckVersionIncrement

 view release on metacpan or  search on metacpan

lib/Dist/Zilla/Plugin/CheckVersionIncrement.pm  view on Meta::CPAN

sub before_release {
    my ($self) = @_;

    my $pkg = $self->zilla->name;
    $pkg =~ s/-/::/g;
    ### $pkg

    my $pkg_version = version->parse($self->zilla->version);
    my $indexed_version;

    my $ua = LWP::UserAgent->new(keep_alive => 1);
    $ua->env_proxy;
    my $res = $ua->get("http://cpanidx.org/cpanidx/json/mod/$pkg");
    if ($res->is_success) {
        my $yaml_octets = encode_utf8($res->decoded_content);
        my $payload = JSON::PP->new->decode($yaml_octets);
        if (@$payload) {
            $indexed_version = version->parse($payload->[0]{mod_vers});
        }
    }

t/main.t  view on Meta::CPAN

use strict;
use warnings;

use autodie;
use Test::DZil;
use LWP::UserAgent;
use Encode qw(encode_utf8);
use JSON::PP;

# Check if we can get to CPAN index, skip if not
my $ua = LWP::UserAgent->new(keep_alive => 1);
$ua->env_proxy;
my $res = $ua->get("http://cpanidx.org/cpanidx/json/mod/Dist-Zilla-Plugin-CheckVersionIncrement");
if (!$res->is_success) {
    plan skip_all => 'Cannot access CPAN index';
}
# Check that CPAN index returns something that contains a version
# number, skip if not
my $yaml_octets = encode_utf8($res->decoded_content);
my $payload = JSON::PP->new->decode($yaml_octets);
if (!(@$payload && $payload->[0]{mod_vers})) {



( run in 0.901 second using v1.01-cache-2.11-cpan-39bf76dae61 )