Stardoc/Document/Pod.pm

filter: Statementstmt 100% 55 / 55 Branchbran 77.7% 14 / 18 Conditioncond 100% 5 / 5 MC/DCmcdc 100% 3 / 3 Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 3 totaltotal 91.7% 89 / 97 CC 15 SCAR 20.6
CC
15
Cov
95%
format
14.1
format_template
2.0
BEGIN
1.0
CRAP 7.9
« Module/Install/Stardoc.pm ↑ Summary Stardoc/Module/Perl.pm »
1 ##
2 # name: Stardoc::Document::Pod
3 # abstract: Stardoc Pod Generator
4 # author: Ingy döt Net <ingy@cpan.org>
5 # copyright: 2011
6 # license: perl
7  
8 package Stardoc::Document::Pod;
9 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Template::Toolkit::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use IO::All;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 has module => (
15 is => 'ro',
16 );
17  
18 1 my $layout = [
19 {name => 'encoding', requires => ['encoding']},
20 {name => 'name', requires => ['name', 'abstract']},
21 'synopsis',
22 'description',
23 'other',
24 {name => 'see', requires => ['see']},
25 {name => 'author', requires => ['author']},
26 {name => 'license', requires => ['copyright']},
27 {name => 'cut'},
28 ];
29  
30 2 ▶sub format {
Subroutine format: called CC=14 SCAR=26.5
Pod undocumented
31 2 my ($self) = @_;
32 2 my $module = $self->module;
33 2 my $data = $module->meta;
34 2 my $pod = '';
35  
36 OUTER:
37 2 for my $entry (@$layout) {
38 18 ▶ my $name = ref($entry) ? $entry->{name} : $entry;
Branch: 1 branch
BranchTrueFalseTotal
ref $entry ? : 12 6 18
39 18 ▶ if ($name eq 'other') {
Branch: 3 branches
BranchTrueFalseTotal
if ($name eq 'other') { } 2 16 18
elsif ($module->can($name) and $module->$name) { } 4 12 16
elsif (ref $entry) { } 12 0 12
40 2 for my $section (@{$module->other}) {
41 2 ▶ $pod .= "\n" if $pod;
Branch: 1 branch
BranchTrueFalseTotal
if $pod 2 0 2
42 2 $pod .= $section->{text};
43 }
44 }
45 ▶ elsif ($module->can($name) and $module->$name) {
Condition100%3/3
$module->can($name) and $module->$name
!ll&&!rl&&r
664
MC/DC100%2/2
$module->can($name) and $module->$name
$module->can($name) $module->$name
Truth table100%3/3
A and B
A= $module->can($name)B= $module->$name
ABresult
0X0
100
111
46 4 ▶ $pod .= "\n" if $pod;
Branch: 1 branch
BranchTrueFalseTotal
if $pod 4 0 4
47 4 $pod .= $module->$name->{text};
48 }
49 elsif (ref $entry) {
50 12 ▶ my $requires = $entry->{requires} || [];
Condition100%2/2
$entry->{'requires'} || []
l!l
102
MC/DC100%1/1
$entry->{'requires'} || []
$entry->{'requires'}
Truth table100%2/2
A
A= $entry->{'requires'}
Aresult
11
00
51 12 ▶ $data->{$_} or next OUTER for @$requires;
Branch: 1 branch
BranchTrueFalseTotal
$data->{$_} or next OUTER 11 1 12
52 11 ▶ $pod .= "\n" if $pod;
Branch: 1 branch
BranchTrueFalseTotal
if $pod 9 2 11
53 11 $pod .= $self->format_template($name, $data);
54 }
55 }
56 2 return $pod;
57 }
58  
59 11 ▶sub format_template {
Subroutine format_template: called CC=2 SCAR=7.0
Pod undocumented
60 11 my ($self, $name, $data) = @_;
61 11 ▶ my $template = eval {
Branch: 1 branch
BranchTrueFalseTotal
my $template = eval { do { "Stardoc::Pod::Templates"->$name } } or next 11 0 11
62 11 Stardoc::Pod::Templates->$name;
63 } or next;
64 11 tt->render(\$template, $data);
65 }
66  
67 0 ▶sub format_section {
Subroutine format_section: not called CC=1 SCAR=0.0
Pod undocumented
68 }
69  
70 package Stardoc::Pod::Templates;
71  
72 1 ▶use constant name => <<'...';
Subroutine BEGIN: called CC=1 SCAR=0.0
73 =head1 NAME
74  
75 [% name %] - [% abstract %]
76 ...
77  
78 1 ▶use constant status => <<'...';
Subroutine BEGIN: called CC=1 SCAR=0.0
79 =head1 STATUS
80  
81 [% status %]
82 ...
83  
84 1 ▶use constant encoding => <<'...';
Subroutine BEGIN: called CC=1 SCAR=0.0
85 =encoding [% encoding %]
86 ...
87  
88 1 ▶use constant see => <<'...';
Subroutine BEGIN: called CC=1 SCAR=0.0
89 =head1 SEE ALSO
90  
91 =over
92 [% FOR also = see %]
93 =item *
94  
95 L<[% also %]>
96 [% END %]
97 =back
98 ...
99  
100 1 ▶use constant author => <<'...';
Subroutine BEGIN: called CC=1 SCAR=0.0
101 =head1 AUTHOR
102  
103 [% author.0.name %][% IF author.0.email %] <[% author.0.email %]>[% END %]
104 ...
105  
106 1 ▶use constant license => <<'...';
Subroutine BEGIN: called CC=1 SCAR=0.0
107 =head1 COPYRIGHT AND LICENSE
108  
109 Copyright (c) [% copyright %]. [% author.0.name %].
110  
111 This program is free software; you can redistribute it and/or modify it
112 under the same terms as Perl itself.
113  
114 See http://www.perl.com/perl/misc/Artistic.html
115 ...
116  
117 1 ▶use constant cut => <<'...';
Subroutine BEGIN: called CC=1 SCAR=0.0
118 =cut
119 ...
120  
121 1 1;
« Module/Install/Stardoc.pm ↑ Summary Stardoc/Module/Perl.pm »