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 35     35   244 use strict;
  35         75  
  35         1119  
3 35     35   171 use warnings;
  35         84  
  35         874  
4 35     35   195 use Data::Printer::Filter;
  35         78  
  35         292  
5 35     35   223 use Data::Printer::Common;
  35         91  
  35         6984  
6              
7             filter 'VSTRING' => \&parse;
8              
9             sub parse {
10 3     3 0 12 my ($vstring, $ddp) = @_;
11 3         6 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   1000 require version;
20 3         4106 $string = version->parse($$vstring)->normal;
21 3         22 });
22 3 50       28 $string = 'VSTRING object (unable to parse)' if $error;
23              
24 3 50 66     14 if ($ddp->show_tied and my $tie = ref tied $$vstring) {
25 0         0 $string .= " (tied to $tie)";
26             }
27 3         18 return $ddp->maybe_colorize($string, 'vstring');
28             };
29              
30             1;