App-SimpleScan
view release on metacpan or search on metacpan
t/App/SimpleScan/Plugin/TestExpand.pm view on Meta::CPAN
package App::SimpleScan::Plugin::TestExpand;
our $VERSION = '0.01';
use warnings;
use strict;
use Carp;
use File::Path;
my($test_expand);
sub import {
no strict 'refs';
*{caller() . '::test_expand'} = \&test_expand;
}
sub filters {
return \&filter;
}
sub init {
my ($class, $app) = @_;
no strict 'refs';
*{caller() . '::expander'} = \&test_expand;
$app->{Expander} = "ping!";
}
sub test_expand {
my($self, $value) = @_;
$test_expand = $value if defined $value;
$test_expand;
}
sub options {
return ('test_expand' => \$test_expand,
);
}
sub validate_options {
my($class, $app) = @_;
if (defined ($app->test_expand)) {
$app->pragma('test_expand')->($app);
}
}
sub pragmas {
return (['test_expand' => \&test_expand_pragma],
);
}
sub test_expand_pragma {
my ($self, $args) = @_;
$self->stack_code(qq(# Adding test expansion comment\n));
}
sub filter {
my($app, @code) = @_;
return @code unless $app->test_expand;
push @code, qq(# per-test comment\n);
return @code;
}
1; # Magic true value required at end of module
__END__
=head1 NAME
App::SimpleScan::Plugin::TestExpand - Dummy plugin to test per-test expansion
=head1 VERSION
This document describes App::SimpleScan::Plugin::TestExpand version 0.01
=head1 SYNOPSIS
use App::SimpleScan;
my $app = new App::SimpleScan;
$app->go; # plugin loaded automatically here
=head1 DESCRIPTION
Supports the C<%%test_expand> pragma plus the C<--test_expand> option.
( run in 1.299 second using v1.01-cache-2.11-cpan-39bf76dae61 )