ProjectDocs/Doc.pm

filter: Statementstmt 92.3% 72 / 78 Branchbran 41.6% 5 / 12 Conditioncond 55.5% 5 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 93.3% 14 / 15 Podpod 0.0% 0 / 4 totaltotal 78.2% 97 / 124 CC 11 SCAR 13.3
CC
11
Cov
83%
is_modified
12.0
_set_relpath
5.3
_mkdir
4.1
CRAP 3.8
« ProjectDocs/DocManager.pm ↑ Summary ProjectDocs/Parser/XHTML.pm »
1 package Pod::ProjectDocs::Doc;
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 with 'Pod::ProjectDocs::File';
10  
11 4 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 has 'origin' => (
17 is => 'rw',
18 isa => 'Str',
19 );
20  
21 4 has 'suffix' => (
22 is => 'rw',
23 isa => 'Str',
24 );
25  
26 4 has 'origin_root' => (
27 is => 'rw',
28 isa => 'Str',
29 );
30  
31 4 has 'title' => (
32 is => 'rw',
33 isa => 'Str',
34 );
35  
36 4 has 'data' => (
37 is => 'ro',
38 default => <<'DATA',
39 <div class="box">
40 <h1 class="t1">[% title | html %]</h1>
41 <table>
42 <tr>
43 <td class="label">Description</td>
44 <td class="cell">[% desc | html | html_line_break %]</td>
45 </tr>
46 </table>
47 </div>
48 <div class="path">
49 <a href="[% outroot _ '/index.html' | relpath %]">[% title | html %]</a> &gt; [% mgr_desc | html %] &gt;
50 [% name | html %]
51 </div>
52 <div>
53 [% IF !nosourcecode %]
54 <a href="[% src | relpath %]">Source</a>
55 [% END %]
56 </div>
57 DATA
58 );
59  
60 5 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
61 5 my $self = shift;
62  
63 # This must be done after the other data is available.
64 5 $self->_set_relpath;
65 5 return;
66 }
67  
68 5 ▶sub _set_relpath {
Subroutine _set_relpath: called CC=5 SCAR=16.8
69 5 my $self = shift;
70 5 my $suffix = $self->suffix;
71 5 my ( $name, $dir ) = fileparse $self->origin, qr/\.$suffix/;
72 5 my $reldir = File::Spec->abs2rel( $dir, $self->origin_root );
73 5 ▶ $reldir ||= File::Spec->curdir;
Condition33%1/3
$reldir ||= "File::Spec"->curdir
l!l&&r!l&&!r
500
MC/DC0%0/2
$reldir ||= "File::Spec"->curdir
$reldir "File::Spec"->curdir
Truth table33%1/3
A ||= B
A= $reldirB= "File::Spec"->curdir
ABresult
1X1
011
000
74 5 my $outroot = $self->config->outroot;
75 5 $self->_check_dir( $reldir, $outroot );
76 5 $self->_check_dir( $reldir, File::Spec->catdir( $outroot, "src" ) );
77 5 my $relpath = File::Spec->catdir( $reldir, $name );
78 5 ▶ $relpath =~ s:\\:/:g if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 5 5
79  
80 5 ▶ if ( lc $suffix eq 'pm' || lc $suffix eq 'pod' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $suffix eq 'pm' or lc $suffix eq 'pod') { } 5 0 5
Condition66%2/3
lc $suffix eq "pm" or lc $suffix eq "pod"
l!l&&r!l&&!r
410
MC/DC0%0/2
lc $suffix eq "pm" or lc $suffix eq "pod"
lc $suffix eq "pm" lc $suffix eq "pod"
Truth table66%2/3
A or B
A= lc $suffix eq "pm"B= lc $suffix eq "pod"
ABresult
1X1
011
000
81 5 $self->name( join "::", File::Spec->splitdir($relpath) );
82 }
83 else {
84 0 $self->name( join "/", File::Spec->splitdir($relpath) );
85 }
86 5 $self->relpath( $relpath . "." . $suffix . ".html" );
87 5 return;
88 }
89  
90 10 ▶sub _check_dir {
Subroutine _check_dir: called CC=2 SCAR=6.9
91 10 my ( $self, $dir, $path ) = @_;
92 10 $self->_mkdir($path);
93 10 my @dirs = File::Spec->splitdir($dir);
94 10 foreach my $dir (@dirs) {
95 10 $path = File::Spec->catdir( $path, $dir );
96 10 $self->_mkdir($path);
97 }
98 10 return;
99 }
100  
101 20 ▶sub _mkdir {
Subroutine _mkdir: called CC=4 SCAR=14.1
102 20 my ( $self, $path ) = @_;
103 20 ▶ unless ( -e $path && -d _ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $path and -d _) 10 10 20
Condition66%2/3
-e $path and -d _
!ll&&!rl&&r
10010
MC/DC50%1/2
-e $path and -d _
-e $path -d _
Truth table66%2/3
A and B
A= -e $pathB= -d _
ABresult
0X0
100
111
104 10 ▶ mkdir( $path, 0755 )
Branch: 1 branch
BranchTrueFalseTotal
mkdir $path, 493 or Carp::croak("Can't make directory [$path].") 10 0 10
105 or Carp::croak(qq/Can't make directory [$path]./);
106 }
107 20 return;
108 }
109  
110 9 ▶sub get_output_src_path {
Subroutine get_output_src_path: called CC=1 SCAR=0.0
Pod undocumented
111 9 my $self = shift;
112 9 my $outroot = File::Spec->catdir( $self->config->outroot, "src" );
113 9 my $relpath = $self->relpath;
114 9 my $suffix = $self->suffix;
115 9 $relpath =~ s/\.html$//;
116 9 my $path = File::Spec->catfile( $outroot, $relpath );
117 9 return $path;
118 }
119  
120 4 ▶sub copy_src {
Subroutine copy_src: called CC=1 SCAR=0.0
Pod undocumented
121 4 my $self = shift;
122 4 my $origin = $self->origin;
123 4 my $newsrc = $self->get_output_src_path;
124 4 File::Copy::copy( $origin, $newsrc );
125 4 return;
126 }
127  
128 0 ▶sub is_modified {
Subroutine is_modified: not called CC=3 SCAR=24.8
Pod undocumented
129 0 my $self = shift;
130 0 my $origin = $self->origin;
131 0 my $newsrc = $self->get_output_src_path;
132 0 ▶ return 1 unless ( -e $newsrc );
Branch: 1 branch
BranchTrueFalseTotal
unless -e $newsrc 0 0 0
133 0 ▶ return ( -M $origin < -M $newsrc ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-M $origin < -M $newsrc ? : 0 0 0
134 }
135  
136 4 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
137  
138 4 1;
« ProjectDocs/DocManager.pm ↑ Summary ProjectDocs/Parser/XHTML.pm »