Simple/HTMLLegacy.pm

filter: Statementstmt 29.7% 11 / 37 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 3 totaltotal 19.1% 14 / 73 CC 12 SCAR 46.5
CC
12
Cov
19%
pod2html
156.0
bad_opts
2.0
help_message
2.0
CRAP 104.5
« Simple/BlackBox.pm ↑ Summary Simple/RTF.pm »
1 package Pod::Simple::HTMLLegacy;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = "5.02";
8  
9 #--------------------------------------------------------------------------
10 #
11 # This class is meant to thinly emulate bad old Pod::Html
12 #
13 # TODO: some basic docs
14  
15 0 ▶sub pod2html {
Subroutine pod2html: not called CC=12 SCAR=50.5
Pod undocumented
16 0 my @args = (@_);
17  
18 0 my( $verbose, $infile, $outfile, $title );
19 0 my $index = 1;
20  
21 {
22 0 my($help);
23  
24 my($netscape); # dummy
25 0 local @ARGV = @args;
26 0 ▶ GetOptions(
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("help", \$help, "verbose!", \$verbose, "infile=s", \$infile, "outfile=s", \$outfile, "title=s", \$title, "index!", \$index, "netscape!", \$netscape) or return bad_opts(@args) 0 0 0
27 "help" => \$help,
28 "verbose!" => \$verbose,
29 "infile=s" => \$infile,
30 "outfile=s" => \$outfile,
31 "title=s" => \$title,
32 "index!" => \$index,
33  
34 "netscape!" => \$netscape,
35 ) or return bad_opts(@args);
36 0 ▶ bad_opts(@args) if @ARGV; # it should be all switches!
Branch: 1 branch
BranchTrueFalseTotal
if @ARGV 0 0 0
37 0 ▶ return help_message() if $help;
Branch: 1 branch
BranchTrueFalseTotal
if $help 0 0 0
38 }
39  
40 0 ▶ for($infile, $outfile) { $_ = undef unless defined and length }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ and length $_ 0 0 0
Condition0%0/3
defined $_ and length $_
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ and length $_
defined $_ length $_
Truth table0%0/3
A and B
A= defined $_B= length $_
ABresult
0X0
100
111
41  
42 0 ▶ if($verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose) 0 0 0
43 0 warn sprintf "%s version %s\n", __PACKAGE__, $VERSION;
44 0 warn "OK, processed args [@args] ...\n";
45 0 ▶ warn sprintf
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
46 " Verbose: %s\n Index: %s\n Infile: %s\n Outfile: %s\n Title: %s\n",
47 map defined($_) ? $_ : "(nil)",
48 $verbose, $index, $infile, $outfile, $title,
49 ;
50 0 *Pod::Simple::HTML::DEBUG = sub(){1};
51 }
52 0 require Pod::Simple::HTML;
53 0 Pod::Simple::HTML->VERSION(3);
54  
55 0 ▶ die "No such input file as $infile\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $infile and not -e $infile 0 0 0
Condition0%0/3
defined $infile and not -e $infile
!ll&&!rl&&r
000
MC/DC0%0/2
defined $infile and not -e $infile
defined $infile not -e $infile
Truth table0%0/3
A and not(B)
A= defined $infileB= not -e $infile
ABresult
0X0
100
111
56 if defined $infile and ! -e $infile;
57  
58  
59 0 my $pod = Pod::Simple::HTML->new;
60 0 ▶ $pod->force_title($title) if defined $title;
Branch: 1 branch
BranchTrueFalseTotal
if defined $title 0 0 0
61 0 $pod->index($index);
62 0 return $pod->parse_from_file($infile, $outfile);
63 }
64  
65 #--------------------------------------------------------------------------
66  
67 0 ▶sub bad_opts { die _help_message(); }
Subroutine bad_opts: not called CC=1 SCAR=6.9
Pod undocumented
68 0 ▶sub help_message { print STDOUT _help_message() }
Subroutine help_message: not called CC=1 SCAR=6.9
Pod undocumented
69  
70 #--------------------------------------------------------------------------
71  
72 0 ▶sub _help_message {
Subroutine _help_message: not called CC=1 SCAR=6.9
73  
74 0 join '',
75  
76 "[", __PACKAGE__, " version ", $VERSION, qq~]
77 Usage: pod2html --help --infile=<name> --outfile=<name>
78 --verbose --index --noindex
79  
80 Options:
81 --help - prints this message.
82 --[no]index - generate an index at the top of the resulting html
83 (default behavior).
84 --infile - filename for the pod to convert (input taken from stdin
85 by default).
86 --outfile - filename for the resulting html file (output sent to
87 stdout by default).
88 --title - title that will appear in resulting html file.
89 --[no]verbose - self-explanatory (off by default).
90  
91 Note that pod2html is DEPRECATED, and this version implements only
92 some of the options known to older versions.
93 For more information, see 'perldoc pod2html'.
94 ~;
95  
96 }
97  
98 1 1;
99 __END__
« Simple/BlackBox.pm ↑ Summary Simple/RTF.pm »