| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package EPublisher::Source::Plugin::File; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | # ABSTRACT: File source plugin | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 8 |  |  | 8 |  | 57852 | use strict; | 
|  | 8 |  |  |  |  | 22 |  | 
|  | 8 |  |  |  |  | 238 |  | 
| 6 | 8 |  |  | 8 |  | 39 | use warnings; | 
|  | 8 |  |  |  |  | 16 |  | 
|  | 8 |  |  |  |  | 202 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 8 |  |  | 8 |  | 38 | use File::Basename; | 
|  | 8 |  |  |  |  | 16 |  | 
|  | 8 |  |  |  |  | 592 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 8 |  |  | 8 |  | 2909 | use EPublisher::Source::Base; | 
|  | 8 |  |  |  |  | 22 |  | 
|  | 8 |  |  |  |  | 315 |  | 
| 11 | 8 |  |  | 8 |  | 3090 | use EPublisher::Utils::PPI qw(extract_pod); | 
|  | 8 |  |  |  |  | 28 |  | 
|  | 8 |  |  |  |  | 2419 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | our @ISA = qw( EPublisher::Source::Base ); | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | our $VERSION = 0.05; | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub load_source{ | 
| 18 | 20 |  |  | 20 | 1 | 5077 | my ($self, $source_path) = @_; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 20 |  |  |  |  | 68 | my $options = $self->_config; | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 20 |  | 100 |  |  | 109 | my $file = $source_path // $options->{path}; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 20 | 100 |  |  |  | 74 | if ( !defined $file ) { | 
| 25 | 1 |  |  |  |  | 3 | $self->publisher->debug( "400: No path given" ); | 
| 26 | 1 |  |  |  |  | 4 | return; | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 19 | 100 |  |  |  | 432 | if( !-f $file ) { | 
| 30 | 3 |  |  |  |  | 13 | $self->publisher->debug( "400: $file is not a file" ); | 
| 31 | 3 |  |  |  |  | 14 | return; | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 16 |  |  |  |  | 84 | my $pod      = extract_pod( $file, $self->_config ); | 
| 35 | 16 |  |  |  |  | 24180 | my $filename = basename $file; | 
| 36 | 16 |  |  |  |  | 47 | my $title    = $filename; | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 16 | 100 |  |  |  | 79 | $options->{title} = '' if !defined $options->{title}; | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 16 | 100 |  |  |  | 79 | if ( $options->{title} eq 'pod' ) { | 
|  |  | 100 |  |  |  |  |  | 
| 41 | 5 |  |  |  |  | 26 | ($title) = $pod =~ m{ =head1 \s+ (.*) }x; | 
| 42 | 5 | 100 |  |  |  | 23 | $title = '' if !defined $title; | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  | elsif ( length $options->{title} ) { | 
| 45 | 3 |  |  |  |  | 8 | $title = $options->{title}; | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 16 |  |  |  |  | 196 | return { pod => $pod, filename => $filename, title => $title }; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | 1; | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | __END__ |