App-ForExample

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN


    my $libscan = \&{"ExtUtils::MM_Any::libscan"};
    *{"ExtUtils::MM_Any::libscan"} = sub {
        return '' unless $libscan->(@_);
        return '' if $_[1] =~ /\.sw[p-z]$/;
        return $_[1];
    };
}

{
    map { my ($pk, $vr) = split m/\s/; build_requires $pk => $vr || 0 } grep { ! /^\s*#/ } split m/\n/, <<_END_;
Test::Most
Test::Output
Directory::Scratch
_END_

    map { my ($pk, $vr) = split m/\s/; requires $pk => $vr || 0 } grep { ! /^\s*#/ } split m/\n/, <<_END_;
Carp
Getopt::Chain 0.014
Moose 0.76
Path::Class
Template
_END_
}

if (-e 'inc/.author') {
    my $all_from = join '/', 'lib', split m/-/, name . '.pm';
    `perldoc -tF $all_from > README` if ! -e 'README' || (stat $all_from)[9] > (stat 'README')[9];
}

install_script 'script/for-example';

tests_recursive 't';

auto_install;

WriteAll;

t/Test.pm  view on Meta::CPAN

sub run_for_example (@) {
    App::ForExample->new->run([ @_ ]);
}

sub run_for_example_eg (@) {
    run_for_example @_, qw# --home /home/rob/develop/App-ForExample/Eg --hostname eg.localhost --package Eg #
}

sub stdout_same_as (&$;$) {
    my $run = shift;
    my $file = file( split m/\/+/, shift );
    my $explain = shift;

    my $content = scalar $file->slurp;

    unlike $content, qr/\bUsage: for-example\b/ unless $file =~ m/help/;
    cmp_ok length $content, '>=', 100;
    stdout_is { $run->() } $content, $explain;
}

my $scratch;



( run in 1.113 second using v1.01-cache-2.11-cpan-62a16548d74 )