File Coverage

blib/lib/EPublisher/Source/Plugin/Module.pm
Criterion Covered Total %
statement 34 37 91.8
branch 7 14 50.0
condition 2 6 33.3
subroutine 8 8 100.0
pod 1 1 100.0
total 52 66 78.7


line stmt bran cond sub pod time code
1             package EPublisher::Source::Plugin::Module;
2              
3             # ABSTRACT: Module source plugin
4              
5 2     2   13 use strict;
  2         4  
  2         60  
6 2     2   10 use warnings;
  2         3  
  2         63  
7              
8 2     2   969 use Module::Info;
  2         13036  
  2         59  
9              
10 2     2   599 use Data::Dumper;
  2         6584  
  2         114  
11              
12 2     2   15 use File::Basename;
  2         5  
  2         115  
13              
14 2     2   873 use EPublisher::Source::Base;
  2         5  
  2         63  
15 2     2   833 use EPublisher::Utils::PPI qw(extract_pod);
  2         7  
  2         737  
16              
17             our @ISA = qw( EPublisher::Source::Base );
18              
19             our $VERSION = 0.04;
20              
21             sub load_source{
22 2     2 1 823 my ($self) = @_;
23            
24 2         6 my $options = $self->_config;
25            
26 2 50       12 return unless $options->{name};
27              
28 2 100       4 my @my_inc = @{ $options->{lib} || [] };
  2         29  
29            
30 2         24 my $mod = Module::Info->new_from_module( $options->{name}, @my_inc );
31              
32 2 50       480 return if !$mod;
33 2 50       23 return if !$mod->file;
34              
35 2         20 my $pod = extract_pod( $mod->file, $self->_config );
36 2         65693 my $filename = File::Basename::basename( $mod->file );
37 2         128 my $title = $options->{name};
38              
39 2 50 33     24 if ( $options->{title} and $options->{title} eq 'pod' ) {
    50 33        
40 0         0 ($title) = $pod =~ m{ =head1 \s+ (.*) }x;
41 0 0       0 $title = '' if !defined $title;
42             }
43             elsif ( $options->{title} and $options->{title} ne 'pod' ) {
44 0         0 $title = $options->{title};
45             }
46              
47 2         27 return { pod => $pod, filename => $filename, title => $title };
48             }
49              
50             1;
51              
52             __END__