File Coverage

blib/lib/Pod/Tree/PerlMap.pm
Criterion Covered Total %
statement 8 29 27.5
branch 0 4 0.0
condition 0 6 0.0
subroutine 3 9 33.3
pod 5 6 83.3
total 16 54 29.6


line stmt bran cond sub pod time code
1             package Pod::Tree::PerlMap;
2 1     1   8104789 use 5.006;
  1         10  
3 1     1   11 use strict;
  1         7  
  1         44  
4 1     1   12 use warnings;
  1         9  
  1         419  
5              
6             our $VERSION = '1.29';
7              
8             sub new {
9 0     0 0   my ($class) = @_;
10              
11 0           my $perl_map = { prefix => '' };
12              
13 0           bless $perl_map, $class;
14             }
15              
16             sub set_depth {
17 0     0 1   my ( $perl_map, $depth ) = @_;
18              
19 0           $perl_map->{prefix} = '../' x $depth;
20             }
21              
22             sub add_page {
23 0     0 1   my ( $perl_map, $page, $file ) = @_;
24              
25 0           $perl_map->{page}{$page} = $file;
26             }
27              
28             sub add_func {
29 0     0 1   my ( $perl_map, $func, $file ) = @_;
30              
31 0           $perl_map->{func}{$func} = $file;
32             }
33              
34             sub force_func {
35 0     0 1   my ( $perl_map, $force_func ) = @_;
36              
37 0           $perl_map->{force_func} = $force_func;
38             }
39              
40             sub map {
41 0     0 1   my ( $perl_map, $base, $page, $section ) = @_;
42              
43             # print "map $base, $page, $section ->";
44              
45 0           my $prefix = $perl_map->{prefix};
46 0           my $force_func = $perl_map->{force_func};
47 0           my $func = ( split m(\s+), $section )[0]; # e.g. L<"eval BLOCK">
48 0           my $file = $perl_map->{func}{$func};
49              
50 0 0 0       if ( ( $page eq 'perlfunc' or $page eq '' and $force_func ) and $file ) {
    0 0        
51 0           $page = $prefix . 'pod/func/' . $file;
52 0           $section = '';
53             }
54             elsif ( $perl_map->{page}{$page} ) {
55 0           $page = $prefix . $perl_map->{page}{$page};
56             }
57              
58             # print "$base, $page, $section\n";
59 0           ( $base, $page, $section );
60             }
61              
62             1
63              
64             __END__