| 1 | package Pod::ProjectDocs::DocManager; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | our $VERSION = '0.53'; # VERSION | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Carp(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use File::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use IO::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Pod::ProjectDocs::Doc; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 4 | has 'config' => ( is => 'ro', ); | |||||||||||||||||||||||||||
| 15 | 4 | has 'desc' => ( | |||||||||||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||||||||||
| 17 | isa => 'Str', | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | 4 | has 'suffix' => ( is => 'rw', ); | |||||||||||||||||||||||||||
| 20 | 4 | has 'parser' => ( is => 'ro', ); | |||||||||||||||||||||||||||
| 21 | has 'docs' => ( | ||||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||
| 23 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||
| 24 | 9 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 4 | ); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 9 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 29 | 9 | $self->_find_files(); | |||||||||||||||||||||||||||
| 30 | 9 | return; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 9 | ▶ | sub _find_files { | ||||||||||||||||||||||||||
|
Subroutine
_find_files: called CC=7 SCAR=20.1
| |||||||||||||||||||||||||||||
| 34 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 35 | 9 | foreach my $dir ( @{ $self->config->libroot } ) { | |||||||||||||||||||||||||||
| 36 | 9 | ▶ | unless ( -e $dir && -d _ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e $dir and -d _
MC/DC0%0/2
-e $dir and -d _
-e $dir
-d _
Truth table33%1/3
A and B
A= -e $dirB= -d _
| |||||||||||||||||||||||||||||
| 37 | 0 | Carp::croak(qq/$dir isn't detected or it's not a directory./); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 9 | my $suffixs = $self->suffix; | |||||||||||||||||||||||||||
| 41 | 9 | ▶ | $suffixs = [$suffixs] if !ref $suffixs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 9 | foreach my $dir ( @{ $self->config->libroot } ) { | |||||||||||||||||||||||||||
| 43 | 9 | foreach my $suffix (@$suffixs) { | |||||||||||||||||||||||||||
| 44 | 40 | ▶ | my $wanted = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.9
| |||||||||||||||||||||||||||||
| 45 | 40 | ▶ | return unless $File::Find::name =~ /\.$suffix$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 5 | ( my $path = $File::Find::name ) =~ s#^\\.##; | |||||||||||||||||||||||||||
| 47 | 5 | my ( $fname, $fdir ) = | |||||||||||||||||||||||||||
| 48 | File::Basename::fileparse( $path, qr/\.$suffix/ ); | ||||||||||||||||||||||||||||
| 49 | 5 | my $reldir = File::Spec->abs2rel( $fdir, $dir ); | |||||||||||||||||||||||||||
| 50 | 5 | ▶ | $reldir ||= File::Spec->curdir; | ||||||||||||||||||||||||||
|
Condition33%1/3
$reldir ||= "File::Spec"->curdir
MC/DC0%0/2
$reldir ||= "File::Spec"->curdir
$reldir
"File::Spec"->curdir
Truth table33%1/3
A ||= B
A= $reldirB= "File::Spec"->curdir
| |||||||||||||||||||||||||||||
| 51 | 5 | my $relpath = File::Spec->catdir( $reldir, $fname ); | |||||||||||||||||||||||||||
| 52 | 5 | $relpath .= "."; | |||||||||||||||||||||||||||
| 53 | 5 | $relpath .= $suffix; | |||||||||||||||||||||||||||
| 54 | 5 | ▶ | $relpath =~ s:\\:/:g if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 5 | my $matched = 0; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 5 | foreach my $regex ( @{ $self->config->except } ) { | |||||||||||||||||||||||||||
| 58 | 2 | ▶ | if ( $relpath =~ /$regex/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | $matched = 1; | |||||||||||||||||||||||||||
| 60 | 0 | last; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # check if there is actually any POD inside, skip otherwise | ||||||||||||||||||||||||||||
| 65 | 5 | my $content = join( '', | |||||||||||||||||||||||||||
| 66 | IO::File->new( $File::Find::name, 'r' )->getlines() ); | ||||||||||||||||||||||||||||
| 67 | 5 | ▶ | $matched = 1 if $content !~ m{^=(head1|head2|item|cut)}ismxg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 5 | ▶ | unless ($matched) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 5 | push @{ $self->docs }, | |||||||||||||||||||||||||||
| 71 | Pod::ProjectDocs::Doc->new( | ||||||||||||||||||||||||||||
| 72 | config => $self->config, | ||||||||||||||||||||||||||||
| 73 | origin => $path, | ||||||||||||||||||||||||||||
| 74 | origin_root => $dir, | ||||||||||||||||||||||||||||
| 75 | suffix => $suffix, | ||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 12 | }; | |||||||||||||||||||||||||||
| 79 | 12 | File::Find::find( { no_chdir => 1, wanted => $wanted }, $dir ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 9 | $self->docs( [ sort { $a->name cmp $b->name } @{ $self->docs } ] ); | |||||||||||||||||||||||||||
| 83 | 9 | return; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 4 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 4 | 1; | |||||||||||||||||||||||||||
| 89 | __END__ | ||||||||||||||||||||||||||||