File Coverage

blib/lib/Data/Printer/Filter/Digest.pm
Criterion Covered Total %
statement 19 19 100.0
branch 5 6 83.3
condition 3 6 50.0
subroutine 4 4 100.0
pod n/a
total 31 35 88.5


line stmt bran cond sub pod time code
1             package Data::Printer::Filter::Digest;
2 1     1   6 use strict;
  1         1  
  1         23  
3 1     1   5 use warnings;
  1         1  
  1         20  
4 1     1   3 use Data::Printer::Filter;
  1         2  
  1         6  
5              
6             filter 'Digest::base' => \&_print_digest;
7              
8             # these modules don't inherit from Digest::base but have the same interface:
9             filter 'Digest::MD2' => \&_print_digest;
10             filter 'Digest::MD4' => \&_print_digest;
11              
12             sub _print_digest {
13 6     6   11 my ($obj, $ddp) = @_;
14 6         47 my $digest = $obj->clone->hexdigest;
15 6         23 my $str = $digest;
16 6         9 my $ref = ref $obj;
17              
18 6 100 66     15 if ( !exists $ddp->extra_config->{filter_digest}{show_class_name}
19             || $ddp->extra_config->{filter_digest}{show_class_name} ) {
20 4         13 $str .= " ($ref)";
21             }
22              
23 6 50 33     12 if( !exists $ddp->extra_config->{filter_digest}{show_reset}
24             || $ddp->extra_config->{filter_digest}{show_reset}
25             ) {
26 6 100       22 if ($digest eq $ref->new->hexdigest) {
27 2         15 $str .= ' [reset]';
28             }
29             }
30              
31 6         48 return $ddp->maybe_colorize($str, 'datetime', '#ffaaff');
32             }
33              
34             1;
35              
36             __END__