| 1 | package Pod::Html::HtmlTree; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Pod::Html; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use File::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use File::Path; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use List::Util qw/first/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | our $VERSION = 0.92; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 14 | 4 | ▶ | my $self = shift || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # default setting. | ||||||||||||||||||||||||||||
| 17 | 4 | $self->{pod_exts} = [ 'pm' ,'pl' ,'cgi','pod' ]; | |||||||||||||||||||||||||||
| 18 | 4 | $self->{mask_dir} = 0775; | |||||||||||||||||||||||||||
| 19 | 4 | $self->{mask_html} = 0664; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 4 | bless $self , $class; | |||||||||||||||||||||||||||
| 22 | 4 | return $self; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 4 | ▶ | sub create { | ||||||||||||||||||||||||||
|
Subroutine
create: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 4 | my $paths_ref = $self->_get_paths(); | |||||||||||||||||||||||||||
| 29 | 4 | my $umask = umask 0000; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 4 | for my $file_ref ( @{ $paths_ref } ) { | |||||||||||||||||||||||||||
| 32 | 3 | ▶ | if ( !-d dirname( $file_ref->{outfile} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 3 | mkpath( dirname( $file_ref->{outfile} ) , 0 , $self->{mask_dir} ) ; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | 3 | ▶ | $self->{args} = $self->{args} || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'args'} || []
MC/DC100%1/1
$self->{'args'} || []
$self->{'args'}
Truth table100%2/2
A
A= $self->{'args'}
| |||||||||||||||||||||||||||||
| 36 | 3 | my @args = @{ $self->{args} } ; | |||||||||||||||||||||||||||
| 37 | 3 | push ( @args , '--infile=' . $file_ref->{infile} ); | |||||||||||||||||||||||||||
| 38 | 3 | push ( @args , '--outfile=' . $file_ref->{outfile} ); | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 3 | pod2html( @args ); | |||||||||||||||||||||||||||
| 41 | 2 | chmod $self->{mask_html} , $file_ref->{outfile} ; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 3 | unlink './pod2htmd.tmp'; | |||||||||||||||||||||||||||
| 44 | 3 | unlink './pod2htmi.tmp'; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3 | umask $umask; | |||||||||||||||||||||||||||
| 47 | 3 | return $paths_ref; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | ▶ | sub args { | ||||||||||||||||||||||||||
|
Subroutine
args: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 52 | 1 | my $arg = shift; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | $self->{args} = []; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | foreach my $key ( keys %{ $arg } ) { | |||||||||||||||||||||||||||
| 57 | 14 | ▶ | my $value = $arg->{$key} eq '0' ? "--$key" : "--$key=$arg->{$key}" ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 14 | push @{ $self->{args} } , $value ; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | #{{{ setter | ||||||||||||||||||||||||||||
| 63 | 2 | ▶ | sub pod_exts { | ||||||||||||||||||||||||||
|
Subroutine
pod_exts: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | 2 | $self->{pod_exts} = shift; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub mask_dir { | ||||||||||||||||||||||||||
|
Subroutine
mask_dir: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 69 | 0 | $self->{mask_dir} = shift; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub mask_html { | ||||||||||||||||||||||||||
|
Subroutine
mask_html: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 74 | 0 | $self->{mask_html} = shift; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub indir { | ||||||||||||||||||||||||||
|
Subroutine
indir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 79 | 1 | $self->{indir} = shift; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | sub outdir { | ||||||||||||||||||||||||||
|
Subroutine
outdir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 84 | 1 | $self->{outdir} = shift; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | #}}} | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | #{{{ PRIVATE | ||||||||||||||||||||||||||||
| 90 | 4 | ▶ | sub _get_paths { | ||||||||||||||||||||||||||
|
Subroutine
_get_paths: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||
| 91 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 92 | 4 | my @infiles = (); | |||||||||||||||||||||||||||
| 93 | 4 | my @paths = (); | |||||||||||||||||||||||||||
| 94 | File::Find::find( | ||||||||||||||||||||||||||||
| 95 | 16 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 96 | 16 | my $file_name = $_; | |||||||||||||||||||||||||||
| 97 | 16 | ▶ | if (!-d $_ && $self->_is_ok_ext( $file_name ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not -d $_ and $self->_is_ok_ext($file_name)
MC/DC100%2/2
not -d $_ and $self->_is_ok_ext($file_name)
not -d $_
$self->_is_ok_ext($file_name)
Truth table100%3/3
not(A) and B
A= not -d $_B= $self->_is_ok_ext($file_name)
| |||||||||||||||||||||||||||||
| 98 | 3 | push @infiles , $File::Find::name ; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | }, | ||||||||||||||||||||||||||||
| 101 | $self->{indir} | ||||||||||||||||||||||||||||
| 102 | 4 | ); | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # set { outfile , infile } in array | ||||||||||||||||||||||||||||
| 105 | 4 | for my $infile ( @infiles ) { | |||||||||||||||||||||||||||
| 106 | # get ext | ||||||||||||||||||||||||||||
| 107 | 3 | my @splited_file_by_dot = split /\./ , $infile ; | |||||||||||||||||||||||||||
| 108 | 3 | my $ext = $splited_file_by_dot[-1]; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | # get outfile | ||||||||||||||||||||||||||||
| 111 | 3 | my $outfile = $infile; | |||||||||||||||||||||||||||
| 112 | 3 | my $os = fileparse_set_fstype(); | |||||||||||||||||||||||||||
| 113 | 3 | ▶ | if( $os eq 'MSWin32' || $os eq 'DOS' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$os eq "MSWin32" or $os eq "DOS"
MC/DC0%0/2
$os eq "MSWin32" or $os eq "DOS"
$os eq "MSWin32"
$os eq "DOS"
Truth table33%1/3
A or B
A= $os eq "MSWin32"B= $os eq "DOS"
| |||||||||||||||||||||||||||||
| 114 | 0 | my $indir = $self->{indir}; | |||||||||||||||||||||||||||
| 115 | 0 | my $outdir = $self->{outdir}; | |||||||||||||||||||||||||||
| 116 | 0 | $outfile =~ s/\\/\//g; | |||||||||||||||||||||||||||
| 117 | 0 | $indir =~ s/\\/\//g; | |||||||||||||||||||||||||||
| 118 | 0 | $outdir =~ s/\\/\//g; | |||||||||||||||||||||||||||
| 119 | 0 | $outfile =~ s/$indir/$outdir/; | |||||||||||||||||||||||||||
| 120 | 0 | $outfile =~ s/\.$ext/\.html/; | |||||||||||||||||||||||||||
| 121 | 0 | $outfile =~ s/\//\\/g; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | else { | ||||||||||||||||||||||||||||
| 124 | 3 | $outfile =~ s/$self->{indir}/$self->{outdir}/; | |||||||||||||||||||||||||||
| 125 | 3 | $outfile =~ s/\.$ext/\.html/; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | # make file hash | ||||||||||||||||||||||||||||
| 129 | 3 | my $file_ref = { | |||||||||||||||||||||||||||
| 130 | infile => $infile , | ||||||||||||||||||||||||||||
| 131 | outfile => $outfile , | ||||||||||||||||||||||||||||
| 132 | }; | ||||||||||||||||||||||||||||
| 133 | 3 | push @paths , $file_ref ; | |||||||||||||||||||||||||||
| 134 | }; | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 4 | return \@paths; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 4 | ▶ | sub _is_ok_ext { | ||||||||||||||||||||||||||
|
Subroutine
_is_ok_ext: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 140 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 141 | 4 | my $file_name = shift; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 4 | ▶ | my $find = first { $file_name =~ /\.$_$/} @{ $self->{pod_exts} }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 144 | 4 | ▶ | return $find ? 1 : 0 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | #}}} | ||||||||||||||||||||||||||||
| 147 | 1 | 1; | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | __END__ | ||||||||||||||||||||||||||||