| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | ##-*- Mode: CPerl -*- | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | ## File: DDC::Format::Dumper.pm | 
| 4 |  |  |  |  |  |  | ## Author: Bryan Jurish | 
| 5 |  |  |  |  |  |  | ## Description: | 
| 6 |  |  |  |  |  |  | ##  + DDC Query utilities: output formatting: Data::Dumper | 
| 7 |  |  |  |  |  |  | ##====================================================================== | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | package DDC::Format::Dumper; | 
| 10 | 26 |  |  | 26 |  | 16526 | use Data::Dumper; | 
|  | 26 |  |  |  |  | 167800 |  | 
|  | 26 |  |  |  |  | 1664 |  | 
| 11 | 26 |  |  | 26 |  | 209 | use IO::File; | 
|  | 26 |  |  |  |  | 60 |  | 
|  | 26 |  |  |  |  | 3124 |  | 
| 12 | 26 |  |  | 26 |  | 179 | use Carp; | 
|  | 26 |  |  |  |  | 60 |  | 
|  | 26 |  |  |  |  | 1266 |  | 
| 13 | 26 |  |  | 26 |  | 170 | use strict; | 
|  | 26 |  |  |  |  | 62 |  | 
|  | 26 |  |  |  |  | 7057 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | ##====================================================================== | 
| 16 |  |  |  |  |  |  | ## Globals | 
| 17 |  |  |  |  |  |  | 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 |  |  |  |  |  |  | sub new { | 
| 28 | 0 |  |  | 0 | 1 |  | my $that = shift; | 
| 29 | 0 |  | 0 |  |  |  | my $fmt = bless { | 
| 30 |  |  |  |  |  |  | indent=>1, | 
| 31 |  |  |  |  |  |  | dumper=>undef, | 
| 32 |  |  |  |  |  |  | @_ | 
| 33 |  |  |  |  |  |  | }, ref($that)||$that; | 
| 34 | 0 | 0 |  |  |  |  | if (!defined($fmt->{dumper})) { | 
| 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 |  |  |  |  |  |  | sub reset { | 
| 43 | 0 |  |  | 0 | 1 |  | $_[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 |  |  |  |  |  |  | sub hitString { | 
| 53 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub toString { | 
| 62 | 0 |  |  | 0 | 1 |  | my ($fmt,$hits) = @_; | 
| 63 | 0 |  |  |  |  |  | return $fmt->{dumper}->Reset->Indent($fmt->{indent})->Names(['hits'])->Values([$hits])->Dump; | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | 1; ##-- be happy | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | __END__ |