File Coverage

blib/lib/Filter/PPI/Transform.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Filter::PPI::Transform;
2              
3 1     1   38793 use strict;
  1         2  
  1         27  
4 1     1   4 use warnings;
  1         2  
  1         40  
5              
6             our $VERSION = 'v0.0.2'; # VERSION
7              
8 1     1   2191 use Filter::Simple;
  1         29871  
  1         6  
9 1     1   46 use Carp;
  1         2  
  1         184  
10              
11             FILTER {
12             shift;
13             my $trans_name = shift;
14             eval "require $trans_name" or croak "require $trans_name failed: $@";
15             croak "The first argument of use $trans_name MUST be subclass of PPI::Transform" if ! $trans_name->isa('PPI::Transform');
16             my $trans = $trans_name->new(@_);
17             my $doc = PPI::Document->new(\$_);
18             $trans->document($doc);
19             $_ = $doc->serialize;
20             };
21              
22             1;
23             __END__