blib/lib/DDC/Format/Dumper.pm

filter: Statementstmt 56.0% 14 / 25 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 4 / 8 Podpod 100% 4 / 4 totaltotal 50.0% 22 / 44 CC 3 SCAR 15.3
CC
3
Cov
47%
new
12.0
reset
2.0
hitString
2.0
CRAP 4.6
« blib/lib/DDC/HitList.pm ↑ Summary blib/lib/DDC/Format/JSON.pm »
1 ##-*- Mode: CPerl -*-
2  
3 ## File: DDC::Format::Dumper.pm
4 ## Author: Bryan Jurish <moocow@cpan.org>
5 ## Description:
6 ## + DDC Query utilities: output formatting: Data::Dumper
7 ##======================================================================
8  
9 package DDC::Format::Dumper;
10 26 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 26 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 26 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 ##======================================================================
16 ## Globals
17 26 our @ISA = qw(DDC::Format);
18  
19 ##======================================================================
20 ## Constructors, etc.
21  
22 ## $fmt = $CLASS_OR_OBJ->new(%args)
23 ## + %args:
24 ## (
25 ## indent=>$level, ##-- Data::Dumper level (default=1)
26 ## )
27 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
28 0 my $that = shift;
29 0 ▶ my $fmt = bless {
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
30 indent=>1,
31 dumper=>undef,
32 @_
33 }, ref($that)||$that;
34 0 ▶ if (!defined($fmt->{dumper})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fmt->{"dumper"}) 0 0 0
35 0 $fmt->{dumper} = Data::Dumper->new([])->Purity(1)->Terse(0)->Deepcopy(1);
36 }
37 0 return $fmt;
38 }
39  
40 ## $fmt = $fmt->reset()
41 ## + reset counters, etc.
42 0 ▶sub reset {
Subroutine reset: not called CC=1 SCAR=6.9
Pod documented
43 0 $_[0]{dumper}->Reset->Indent($_[0]{indent});
44 0 return $_[0]->SUPER::reset();
45 }
46  
47 ##======================================================================
48 ## Helper functions
49  
50 ## $hitStr = $fmt->hitString($hit)
51 ## + increments $fmt->{start}
52 0 ▶sub hitString {
Subroutine hitString: not called CC=1 SCAR=6.9
Pod documented
53 0 my ($fmt,$hit) = @_;
54 0 return $fmt->{dumper}->Reset->Indent($fmt->{indent})->Names(['hit'])->Values([$hit])->Dump;
55 }
56  
57 ##======================================================================
58 ## API
59  
60 ## $str = $fmt->toString(\@hits)
61 0 ▶sub toString {
Subroutine toString: not called CC=1 SCAR=6.9
Pod documented
62 0 my ($fmt,$hits) = @_;
63 0 return $fmt->{dumper}->Reset->Indent($fmt->{indent})->Names(['hits'])->Values([$hits])->Dump;
64 }
65  
66 26 1; ##-- be happy
67  
68 __END__
« blib/lib/DDC/HitList.pm ↑ Summary blib/lib/DDC/Format/JSON.pm »