File Coverage

blib/lib/Pod/Abstract/Filter/unoverlay.pm
Criterion Covered Total %
statement 9 27 33.3
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 36 36.1


line stmt bran cond sub pod time code
1             package Pod::Abstract::Filter::unoverlay;
2 1     1   1195 use strict;
  1         2  
  1         30  
3 1     1   5 use warnings;
  1         2  
  1         24  
4              
5 1     1   5 use base qw(Pod::Abstract::Filter);
  1         1  
  1         340  
6              
7             our $VERSION = '0.20';
8              
9             =head1 NAME
10              
11             Pod::Abstract::Filter::unoverlay - paf command to remove "overlay" blocks
12             from a Pod document, as created by the paf overlay command.
13              
14             =begin :overlay
15              
16             =overlay METHODS Pod::Abstract::Filter
17              
18             =end :overlay
19              
20             =head1 METHODS
21              
22             =head2 new
23              
24             =for overlay from Pod::Abstract::Filter
25              
26             =head2 filter
27              
28             Strips any sections marked C<=for overlay> from the listed overlay
29             specification from the target document. This will expunge everything
30             that has been previously overlaid or marked for overlay from the
31             specified documents.
32              
33             =cut
34              
35             sub filter {
36 0     0 1   my $self = shift;
37 0           my $pa = shift;
38            
39 0           my ($overlay_list) = $pa->select("//begin[. =~ {^:overlay}](0)");
40 0 0         unless($overlay_list) {
41 0           die "No overlay defined in document\n";
42             }
43 0           my @overlays = $overlay_list->select("/overlay");
44 0           foreach my $overlay (@overlays) {
45 0           my $o_def = $overlay->body;
46 0           my ($section, $module) = split " ", $o_def;
47            
48 0           my ($t) = $pa->select("//[\@heading =~ {$section}](0)");
49 0           my @t_headings = $t->select("/[\@heading]");
50 0           foreach my $hdg (@t_headings) {
51 0           my @overlay_from =
52             $hdg->select(
53             "/for[. =~ {^overlay from }]");
54 0           my @from_current = grep {
55 0           substr($_->body, -(length $module)) eq $module
56             } @overlay_from;
57 0 0         if(@from_current) {
58 0           $hdg->detach;
59             }
60             }
61             }
62 0           return $pa;
63             }
64              
65             =head1 AUTHOR
66              
67             Ben Lilburne
68              
69             =head1 COPYRIGHT AND LICENSE
70              
71             Copyright (C) 2009 Ben Lilburne
72              
73             This program is free software; you can redistribute it and/or modify
74             it under the same terms as Perl itself.
75              
76             =cut
77              
78             1;