bin/pmdesc

filter: Statementstmt 83.9% 47 / 56 Branchbran 62.5% 10 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 80.7% 63 / 78 CC 3 SCAR 5.9
CC
3
Cov
79%
getversion
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« bin/pmexp ↑ Summary blib/lib/pmtools.pm »
1 #!/usr/bin/env perl
2 # pmdesc -- show NAME section
3  
4 # ------ pragmas
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use FindBin qw($Bin);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '2.1.0';
11  
12 # ------ define variables
13 2 my $errors; # error count
14 my $fullpath; # full module path
15 2 my $module; # module name
16 2 my $use_pod; # use .pod instead of .pm file for systems with split POD/pm
17 2 my $vers; # module version
18  
19 2 ▶BEGIN { $^W = 1 }
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 GetOptions ("splitpod" => \$use_pod);
22  
23 2 $errors = 0;
24  
25 2 MODULE: for $module (@ARGV) {
26 2 ▶ if ($use_pod) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_pod) { } 1 1 2
27 1 $fullpath = `$^X $Bin/podpath $module`;
28 } else {
29 1 $fullpath = `$^X $Bin/pmpath $module`;
30 }
31 2 ▶ if ($?) {
Branch: 1 branch
BranchTrueFalseTotal
if ($?) 0 2 2
32 0 $errors++;
33 0 next;
34 }
35 2 chomp $fullpath;
36 2 ▶ unless (open(POD, "< $fullpath")) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open POD, "< $fullpath") 0 2 2
37 0 warn "$0: cannot open $fullpath: $!";
38 0 $errors++;
39 0 next;
40 }
41  
42 2 local $/ = '';
43 2 local $_;
44 2 ▶ while (<POD>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline POD)) 132 0 132
45 132 ▶ if (/=head\d\s+NAME/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/=head\d\s+NAME/) 2 130 132
46 2 chomp($_ = <POD>);
47 2 s/^.*?-\s+//s;
48 2 s/\n/ /g;
49 #write;
50 2 my $v;
51 2 ▶ if (defined ($vers = getversion($module))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($vers = getversion($module))) { } 2 0 2
52 2 print "$module ($vers) ";
53 } else {
54 0 print "$module ";
55 }
56 2 print "- $_\n";
57  
58 2 next MODULE;
59 }
60 }
61 0 print "no description found\n";
62 0 $errors++;
63 }
64  
65 2 ▶sub getversion {
Subroutine getversion: called CC=3 SCAR=11.4
66 2 my $module = shift;
67  
68 2 my $vers;
69 2 ▶ if ( $^O eq "MSWin32" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 2 2
70 0 $vers = `$^X -S $Bin/pmvers $module 2>NUL`;
71 } else {
72 2 $vers = `$^X -S $Bin/pmvers $module 2>/dev/null`;
73 }
74 2 ▶ return if $?;
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 2 2
75 2 chomp $vers;
76 2 return $vers;
77 }
78  
79 2 exit ($errors != 0);
80  
81 __END__
« bin/pmexp ↑ Summary blib/lib/pmtools.pm »