blib/lib/DDC/Format.pm

filter: Statementstmt 43.4% 10 / 23 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 3 / 8 Podpod 100% 5 / 5 totaltotal 38.3% 18 / 47 CC 5 SCAR 21.3
CC
5
Cov
31%
toFile
20.0
new
6.0
reset
2.0
CRAP 8.4
« blib/lib/DDC/PP/CQueryOptions.pm ↑ Summary blib/lib/DDC/PP/CQuery.pm »
1 #-*- Mode: CPerl -*-
2  
3 ## File: DDC::Format.pm
4 ## Author: Bryan Jurish <moocow@cpan.org>
5 ## Description:
6 ## + DDC Query utilities: output formatting
7 ##======================================================================
8  
9 package DDC::Format;
10 26 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 26 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 ##======================================================================
15 ## Globals
16  
17 ##======================================================================
18 ## Constructors, etc.
19  
20 ## $fmt = $CLASS_OR_OBJ->new(%args)
21 ## + %args:
22 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
23 0 my $that = shift;
24 0 ▶ return bless { @_ }, ref($that)||$that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
25 }
26  
27 ## $fmt = $fmt->reset()
28 ## + reset counters, etc.
29 0 ▶sub reset { return $_[0]; }
Subroutine reset: not called CC=1 SCAR=6.9
Pod documented
30  
31 ##======================================================================
32 ## API
33  
34 ## $str = $fmt->toString($hitList)
35 0 ▶sub toString {
Subroutine toString: not called CC=1 SCAR=6.9
Pod documented
36 0 my ($fmt,$hits) = @_;
37 0 return "$hits";
38 }
39  
40 ## undef = $fmt->toFile($hitList,$file)
41 ## + default implementation calls $fmt->toFh()
42 0 ▶sub toFile {
Subroutine toFile: not called CC=4 SCAR=30.0
Pod documented
43 0 my ($fmt,$hits,$file) = @_;
44 0 ▶ my $fh = ref($file) ? $file : IO::File->new(">$file");
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 0 0 0
45 0 ▶ confess(ref($fmt)."::toFile(): open failed for '$file': $!") if (!$fh);
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 0 0
46 0 my $rc = $fmt->toFh($hits,$fh);
47 0 ▶ $fh->close() if (!ref($file));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $file 0 0 0
48 0 return $rc;
49 }
50  
51 ## undef = $fmt->toFh($hitList,$fh)
52 ## + default implementation calls $fmt->toString()
53 0 ▶sub toFh {
Subroutine toFh: not called CC=1 SCAR=6.9
Pod documented
54 0 my ($fmt,$hits,$fh) = @_;
55 0 $fh->print($fmt->toString($hits));
56 }
57  
58  
59 26 1; ##-- be happy
60  
61 __END__
« blib/lib/DDC/PP/CQueryOptions.pm ↑ Summary blib/lib/DDC/PP/CQuery.pm »