Dist-Zilla-Plugin-ReportVersions-Tiny

 view release on metacpan or  search on metacpan

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

package Dist::Zilla::Plugin::ReportVersions::Tiny;
$Dist::Zilla::Plugin::ReportVersions::Tiny::VERSION = '1.12';
use Moose;
with 'Dist::Zilla::Role::FileGatherer';
with 'Dist::Zilla::Role::TextTemplate';
with 'Dist::Zilla::Role::PrereqSource';

use Dist::Zilla::File::FromCode;
use version;

before register_component => sub {
    warn
        '!!! [ReportVersions::Tiny] is deprecated; recommended alternative: [Test::ReportPrereqs]'
};


sub mvp_multivalue_args { qw{exclude include} };
has exclude => (is => 'ro', isa => 'ArrayRef', default => sub { [] });
has include => (is => 'ro', isa => 'ArrayRef', default => sub { [] });

our $template = q{use strict;
use warnings;
use Test::More 0.88;
# This is a relatively nice way to avoid Test::NoWarnings breaking our
# expectations by adding extra tests, without using no_plan.  It also helps
# avoid any other test module that feels introducing random tests, or even
# test plans, is a nice idea.
our $success = 0;
END { $success && done_testing; }

# List our own version used to generate this
my $v = "\nGenerated by {{$my_package}} v{{$my_version}}\n";

eval {                     # no excuses!
    # report our Perl details
    my $want = {{ $perl }};
    $v .= "perl: $] (wanted $want) on $^O from $^X\n\n";
};
defined($@) and diag("$@");

# Now, our module version dependencies:
sub pmver {
    my ($module, $wanted) = @_;
    (my $file = "$module.pm") =~ s{::}{/}g;
    $wanted = " (want $wanted)";
    my $pmver;
    eval { require $file };
    if ($@) {
        if ($@ =~ m/Can't locate .* in \@INC/) {
            $pmver = 'module not found.';
        } else {
            diag("${module}: $@");
            $pmver = 'died during require.';
        }
    } else {
        my $version;
        eval { $version = $module->VERSION; };
        if ($@) {
            diag("${module}: $@");
            $pmver = 'died during VERSION check.';
        } elsif (defined $version) {
            $pmver = "$version";
        } else {
            $pmver = '<undef>';
        }
    }

    # So, we should be good, right?
    return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n");
}

{{$module_code}}


# All done.
$v .= <<'EOT';

Thanks for using my code.  I hope it works for you.
If not, please try and include this output in the bug report.



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