Simple/Base/Examine.pm

filter: Statementstmt 80.3% 41 / 51 Branchbran 54.5% 12 / 22 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 85.7% 6 / 7 Podpod n/a totaltotal 67.7% 61 / 90 CC 14 SCAR 19.2
CC
14
Cov
70%
_examine_glob
12.0
_examine_type
8.1
_examine
6.6
CRAP 6.8
« Simple/Base/Include.pm ↑ Summary Simple/Util.pm »
1 ## no critic (ProhibitUnusedPrivateSubroutines)
2 package Text::Template::Simple::Base::Examine;
3 32 $Text::Template::Simple::Base::Examine::VERSION = '0.91';
4 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 32 ▶use Text::Template::Simple::Util qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 32 ▶use Text::Template::Simple::Constants qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 386 ▶sub _examine {
Subroutine _examine: called CC=6 SCAR=18.8
11 386 my $self = shift;
12 386 my $TMP = shift;
13 386 my($type, $thing) = $self->_examine_type( $TMP );
14 386 my $rv;
15  
16 386 ▶ if ( $type eq 'ERROR' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'ERROR') { } 0 386 386
elsif ($type eq 'GLOB') { } 0 386 386
17 0 $rv = $thing;
18 0 $self->[TYPE] = $type;
19 }
20 elsif ( $type eq 'GLOB' ) {
21 0 $rv = $self->_examine_glob( $thing );
22 0 $self->[TYPE] = $type;
23 }
24 else {
25 386 ▶ if ( my $path = $self->io->file_exists( $thing ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $path = $self->io->file_exists($thing)) { } 283 103 386
26 283 $rv = $self->io->slurp( $path );
27 283 $self->[TYPE] = 'FILE';
28 283 $self->[TYPE_FILE] = $path;
29 }
30 else {
31 # just die if file is absent, but user forced the type as FILE
32 103 ▶ $self->io->slurp( $thing ) if $type eq 'FILE';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "FILE" 2 101 103
33 101 $rv = $thing;
34 101 $self->[TYPE] = 'STRING';
35 }
36 }
37  
38 384 ▶ LOG( EXAMINE => sprintf q{%s; LENGTH: %s}, $self->[TYPE], length $rv ) if DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 384 384
39 384 return $rv;
40 }
41  
42 0 ▶sub _examine_glob {
Subroutine _examine_glob: not called CC=3 SCAR=24.8
43 0 my($self, $thing) = @_;
44 0 my $type = ref $thing;
45 0 ▶ fatal( 'tts.base.examine.notglob' => $type ) if $type ne 'GLOB';
Branch: 1 branch
BranchTrueFalseTotal
if $type ne "GLOB" 0 0 0
46 0 ▶ fatal( 'tts.base.examine.notfh' ) if ! fileno $thing;
Branch: 1 branch
BranchTrueFalseTotal
unless fileno $thing 0 0 0
47 0 return $self->io->slurp( $thing );
48 }
49  
50 386 ▶sub _examine_type {
Subroutine _examine_type: called CC=7 SCAR=21.0
51 386 my $self = shift;
52 386 my $TMP = shift;
53 386 my $ref = ref $TMP;
54  
55 386 ▶ return EMPTY_STRING , $TMP if ! $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 384 2 386
56 2 ▶ return GLOB => $TMP if $ref eq 'GLOB';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "GLOB" 0 2 2
57  
58 2 ▶ if ( ref $TMP eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $TMP eq "ARRAY") 2 0 2
59 2 ▶ my $ftype = shift @{ $TMP } || fatal('tts.base.examine._examine_type.ftype');
Condition33%1/3
shift @{$TMP;} || fatal('tts.base.examine._examine_type.ftype')
l!l&&r!l&&!r
200
MC/DC0%0/2
shift @{$TMP;} || fatal('tts.base.examine._examine_type.ftype')
shift @{$TMP;} fatal('tts.base.examine._examine_type.ftype')
Truth table33%1/3
A || B
A= shift @{$TMP;}B= fatal('tts.base.examine._examine_type.ftype')
ABresult
1X1
011
000
60 2 ▶ my $fthing = shift @{ $TMP } || fatal('tts.base.examine._examine_type.fthing');
Condition33%1/3
shift @{$TMP;} || fatal('tts.base.examine._examine_type.fthing')
l!l&&r!l&&!r
200
MC/DC0%0/2
shift @{$TMP;} || fatal('tts.base.examine._examine_type.fthing')
shift @{$TMP;} fatal('tts.base.examine._examine_type.fthing')
Truth table33%1/3
A || B
A= shift @{$TMP;}B= fatal('tts.base.examine._examine_type.fthing')
ABresult
1X1
011
000
61 2 ▶ fatal('tts.base.examine._examine_type.extra') if @{ $TMP };
Branch: 1 branch
BranchTrueFalseTotal
if @{$TMP;} 0 2 2
62 2 return uc $ftype, $fthing;
63 }
64  
65 0 return fatal('tts.base.examine._examine_type.unknown', $ref);
66 }
67  
68 32 1;
69  
70 __END__
« Simple/Base/Include.pm ↑ Summary Simple/Util.pm »