script/podmanual

filter: Statementstmt 71.4% 35 / 49 Branchbran 25.0% 9 / 36 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 54.4% 49 / 90 CC 1 SCAR 0.0
CC
1
Cov
52%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Pod/Manual/PodXML2Docbook.pm ↑ Summary blib/lib/Pod/Manual/Docbook2LaTeX.pm »
1 #!/usr/bin/perl
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Pod::Manual;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 my $VERSION = '0.08';
11  
12 3 my $title;
13 3 my $output_file = 'manual';
14 3 my $format = 'pdf';
15 3 my $silent = 0;
16 3 my $opt_help = 0;
17 3 my $opt_man = 0;
18  
19 3 ▶GetOptions(
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("title=s", \$title, "output=s", \$output_file, "format=s", \$format, "silent!", \$silent, "man", \$opt_man, "help", \$opt_help) or pod2usage(1) 3 0 3
20 'title=s' => \$title,
21 'output=s' => \$output_file,
22 'format=s' => \$format,
23 'silent!' => \$silent,
24 'man' => \$opt_man,
25 'help' => \$opt_help,
26 ) or pod2usage(1);
27  
28 3 ▶pod2usage(1) if $opt_help;
Branch: 1 branch
BranchTrueFalseTotal
if $opt_help 0 3 3
29 3 ▶pod2usage( -verbose => 2 ) if $opt_man;
Branch: 1 branch
BranchTrueFalseTotal
if $opt_man 0 3 3
30  
31 3 my $manual = Pod::Manual->new( { title => $title } );
32  
33 # the chapters are either passed as arguments,
34 # or taken from STDIN
35 3 ▶$manual->add_chapters( @ARGV ? @ARGV : split /\r?\n/, join q{}, <> );
Branch: 1 branch
BranchTrueFalseTotal
@ARGV ? : 3 0 3
36  
37 3 ▶if ( $format eq 'pdf' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($format eq 'pdf') { } 0 3 3
elsif ($format eq 'docbook') { } 3 0 3
elsif (lc $format eq 'latex') { } 0 0 0
38 0 $output_file =~ s/(\.pdf)?$/.pdf/; # add .pdf, if missing
39 0 $manual->save_as_pdf($output_file);
40 }
41 elsif ( $format eq 'docbook' ) {
42 3 my $output_fh;
43 3 ▶ if ( $output_file eq 'stdout' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output_file eq 'stdout') { } 3 0 3
44 3 ▶ open $output_fh, '>-'
Branch: 1 branch
BranchTrueFalseTotal
open $output_fh, ">-" or die "can't pipe to stdout: $!\n" 3 0 3
45 or die "can't pipe to stdout: $!\n";
46 }
47 else {
48 0 ▶ $output_file .= '.docbook' unless $output_file =~ /\.\w+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $output_file =~ /\.\w+$/ 0 0 0
49 0 ▶ die "$output_file already exists\n" if -e $output_file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $output_file 0 0 0
50 0 ▶ open $output_fh, '>', $output_file
Branch: 1 branch
BranchTrueFalseTotal
open $output_fh, ">", $output_file or die "can't write to ${output_file}: $!\n" 0 0 0
51 or die "can't write to $output_file: $!\n";
52 }
53 3 print {$output_fh} $manual->as_docbook;
54 }
55 elsif ( lc($format) eq 'latex' ) {
56 0 my $output_fh;
57 0 ▶ if ( $output_file eq 'stdout' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output_file eq 'stdout') { } 0 0 0
58 0 ▶ open $output_fh, '>-'
Branch: 1 branch
BranchTrueFalseTotal
open $output_fh, ">-" or die "can't pipe to stdout: $!\n" 0 0 0
59 or die "can't pipe to stdout: $!\n";
60 }
61 else {
62 0 ▶ $output_file .= '.tex' unless $output_file =~ /\.\w+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $output_file =~ /\.\w+$/ 0 0 0
63 0 ▶ die "$output_file already exists\n" if -e $output_file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $output_file 0 0 0
64 0 ▶ open $output_fh, '>', $output_file
Branch: 1 branch
BranchTrueFalseTotal
open $output_fh, ">", $output_file or die "can't write to ${output_file}: $!\n" 0 0 0
65 or die "can't write to $output_file: $!\n";
66 }
67 0 print {$output_fh} $manual->as_latex;
68 }
69 else {
70 0 die "format must be 'pdf', 'docbook' or 'LaTeX'\n";
71 }
72  
73 3 ▶warn "document '$output_file' created\n" unless $silent;
Branch: 1 branch
BranchTrueFalseTotal
unless $silent 0 3 3
74  
75 3 exit;
76  
77 __END__
« blib/lib/Pod/Manual/PodXML2Docbook.pm ↑ Summary blib/lib/Pod/Manual/Docbook2LaTeX.pm »