File Coverage

blib/lib/EPublisher/Target/Plugin/Text.pm
Criterion Covered Total %
statement 46 46 100.0
branch 10 10 100.0
condition 5 5 100.0
subroutine 10 10 100.0
pod 1 1 100.0
total 72 72 100.0


line stmt bran cond sub pod time code
1             package EPublisher::Target::Plugin::Text;
2              
3             # ABSTRACT: Use Ascii text as a target for EPublisher
4              
5 5     5   60971 use strict;
  5         20  
  5         171  
6 5     5   27 use warnings;
  5         10  
  5         169  
7              
8 5     5   28 use Carp;
  5         19  
  5         318  
9 5     5   33 use File::Basename;
  5         9  
  5         339  
10 5     5   2836 use File::Temp;
  5         66776  
  5         363  
11 5     5   846 use IO::String;
  5         4670  
  5         150  
12 5     5   2777 use Pod::Text;
  5         208023  
  5         423  
13              
14 5     5   1130 use EPublisher;
  5         12  
  5         131  
15 5     5   2297 use EPublisher::Target::Base;
  5         13  
  5         1345  
16             our @ISA = qw(EPublisher::Target::Base);
17              
18             our $VERSION = 0.03;
19             our $DEBUG = 0;
20              
21             sub deploy {
22 6     6 1 940 my ($self, $sources) = @_;
23            
24 6   100     29 my $pods = $sources || $self->_config->{source};
25 6   100     19 my $width = $self->_config->{width} || 78;
26 6         16 my $sentence = $self->_config->{sentence};
27 6         14 my $output = $self->_config->{output};
28              
29 6 100       19 $pods = [] if !defined $pods;
30 6 100       21 $pods = [ { pod => $pods } ] if !ref $pods;
31              
32 6 100       23 return if 'ARRAY' ne ref $pods;
33 5 100       9 return if !@{ $pods };
  5         19  
34              
35 4 100       14 if ( !$output ) {
36 1         11 my $fh = File::Temp->new;
37 1         739 $output = $fh->filename;
38             }
39              
40 4         259 my $io = IO::String->new( join "\n\n", map{ $_->{pod} }@{$pods} );
  4         50  
  4         10  
41 4         283 my $parser = Pod::Text->new( sentence => $sentence, width => $width );
42              
43 4         763 $parser->parse_from_filehandle( $io, $output );
44            
45 4         3986 return $output;
46             }
47              
48             1;
49              
50             __END__