blib/lib/POD2/Base.pm

filter: Statementstmt 77.5% 45 / 58 Branchbran 59.0% 13 / 22 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 10 / 13 Podpod 100% 5 / 5 totaltotal 71.8% 74 / 103 CC 13 SCAR 16.7
CC
13
Cov
71%
print_pod
20.0
pod_dirs
4.0
_extract_lang
3.3
CRAP 5.3
↑ Summary
1  
2 package POD2::Base;
3  
4 3 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 $VERSION = '0.044_1';
10  
11 3 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod documented
14 3 my $proto = shift;
15 3 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
16 3 my $obj = bless {}, $class;
17 3 return $obj->_init( @_ );
18 }
19  
20 # instance variables:
21 # lang - the preferred language of the POD documents
22 # inc - alternate library dirs (if given, replaces the ones in @INC)
23  
24 3 ▶sub _init {
Subroutine _init: called CC=3 SCAR=11.0
25 3 my $self = shift;
26 3 ▶ my %args = @_ ? %{$_[0]} : ();
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3 0 3
27 3 ▶ if ( !exists $args{lang} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"lang"}) 1 2 3
28 1 $args{lang} = _extract_lang( ref $self );
29 }
30 #croak "???" unless $args{lang};
31 3 my $lang = uc $args{lang};
32 3 $self->{lang} = $lang;
33 3 $self->{inc} = $args{inc}; # XXX croak ?! must be array ref
34  
35 3 return $self;
36 }
37  
38 # $lang = _extract_lang($module);
39 1 ▶sub _extract_lang {
Subroutine _extract_lang: called CC=3 SCAR=12.0
40 1 my $module = shift;
41  
42 1 ▶ return $module eq __PACKAGE__ ? undef
Branch: 2 branches
BranchTrueFalseTotal
$module eq __PACKAGE__ ? : 0 1 1
$module =~ /::(\w+)\z/ ? : 1 0 1
43 : $module =~ /::(\w+)\z/ ? $1
44 : undef
45 ;
46 }
47  
48 3 ▶sub _lib_dirs {
Subroutine _lib_dirs: called CC=2 SCAR=6.9
49 3 my $self = shift;
50 3 ▶ return $self->{inc} ? @{$self->{inc}} : @INC;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'inc'} ? : 2 1 3
51 }
52  
53 3 ▶sub pod_dirs {
Subroutine pod_dirs: called CC=4 SCAR=13.9
Pod documented
54 3 my $self = shift;
55 3 ▶ my %options = @_ ? %{$_[0]} : ();
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 1 3
56 3 ▶ $options{test} = 1 unless exists $options{test};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"test"} 1 2 3
57  
58 3 my $lang = $self->{lang};
59 3 my @candidates = map { File::Spec->catdir( $_, 'POD2', $lang ) } $self->_lib_dirs; # XXX the right thing to do
60 3 ▶ if ( $options{test} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"test"}) 1 2 3
61 1 return grep { -d } @candidates;
62 }
63 2 return @candidates;
64 }
65  
66 #sub search_perlfunc_re {
67 # shift;
68 # return 'Alphabetical Listing of Perl Functions';
69 #}
70  
71 0 ▶sub pod_info {
Subroutine pod_info: not called CC=1 SCAR=6.9
Pod documented
72 0 shift;
73 0 return {};
74 }
75  
76 0 ▶sub print_pods {
Subroutine print_pods: not called CC=1 SCAR=6.9
Pod documented
77 0 my $self = shift;
78 0 $self->print_pod(sort keys %{$self->pod_info});
79 }
80  
81 0 ▶sub print_pod {
Subroutine print_pod: not called CC=4 SCAR=30.0
Pod documented
82 0 my $self = shift;
83 0 ▶ my @args = @_ ? @_ : @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
84  
85 0 my $pods = $self->pod_info;
86 0 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 0 0
87 0 (my $pod = lc(shift @args)) =~ s/\.pod$//;
88 0 ▶ if ( exists $pods->{$pod} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $pods->{$pod}) { } 0 0 0
89 0 print "\t'$pod' translated from Perl $pods->{$pod}\n";
90 }
91 else {
92 0 print "\t'$pod' doesn't yet exists\n";
93 }
94 }
95 }
96  
97 3 1;
↑ Summary