File Coverage

blib/lib/Data/Printer/Filter/VSTRING.pm
Criterion Covered Total %
statement 20 21 95.2
branch 2 4 50.0
condition 2 3 66.6
subroutine 6 6 100.0
pod 0 1 0.0
total 30 35 85.7


line stmt bran cond sub pod time code
1             package Data::Printer::Filter::VSTRING;
2 32     32   189 use strict;
  32         60  
  32         894  
3 32     32   143 use warnings;
  32         56  
  32         653  
4 32     32   137 use Data::Printer::Filter;
  32         63  
  32         173  
5 32     32   173 use Data::Printer::Common;
  32         55  
  32         5369  
6              
7             filter 'VSTRING' => \&parse;
8              
9             sub parse {
10 3     3 0 8 my ($vstring, $ddp) = @_;
11 3         12 my $string = '';
12              
13             # The reason we don't simply do:
14             # use version 0.77 ();
15             # is because it was causing some issues with UNIVERSAL on Perl 5.8 and
16             # some versions of version.pm. So now we do it on runtime on the filter.
17             # ->parse() will raise an error unless version.pm >= 0.77.
18             my $error = Data::Printer::Common::_tryme(sub {
19 3     3   923 require version;
20 3         3644 $string = version->parse($$vstring)->normal;
21 3         32 });
22 3 50       15 $string = 'VSTRING object (unable to parse)' if $error;
23              
24 3 50 66     13 if ($ddp->show_tied and my $tie = ref tied $$vstring) {
25 0         0 $string .= " (tied to $tie)";
26             }
27 3         13 return $ddp->maybe_colorize($string, 'vstring');
28             };
29              
30             1;