Reporter/Dumper/YAML.pm

filter: Statementstmt 79.4% 31 / 39 Branchbran 50.0% 5 / 10 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 1 totaltotal 65.7% 48 / 73 SCAR 24.5
CC
9
Cov
68%
_ident_from
8.1
dump
6.8
__ANON__
2.0
CRAP 11.6
« Reporter/Sender/Dir.pm ↑ Summary Reporter/Summarizer/MooseException.pm »
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Exception::Reporter::Dumper::YAML;
4 # ABSTRACT: a dumper to turn any scalar value into a plaintext YAML record
5 2 $Exception::Reporter::Dumper::YAML::VERSION = '0.014';
6 2 ▶use parent 'Exception::Reporter::Dumper';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use YAML::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub _ident_from {
12 8 ▶ my ($self, $str, $x) = @_;
Subroutine _ident_from: called CC=5 SCAR=20.9
13  
14 8 $str =~ s/\A\n+//;
15 8 ($str) = split /\n/, $str;
16  
17 8 ▶ unless (defined $str and length $str and $str =~ /\S/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $str and length $str and $str =~ /\S/) 0 8 8
Condition33%2/6
defined $str and length $str and $str =~ /\S/
!ll&&!rl&&r
008
defined $str and length $str
!ll&&!rl&&r
008
MC/DC0%0/3
defined $str and length $str and $str =~ /\S/
defined $str length $str $str =~ /\S/
Truth table25%1/4
A and B and C
A= defined $strB= length $strC= $str =~ /\S/
ABCresult
0XX0
10X0
1100
1111
18 0 ▶ $str = sprintf "<<unknown%s>>", $x ? ' ($x)' : '';
Branch: 1 branch
BranchTrueFalseTotal
$x ? : 0 0 0
19 }
20  
21 8 return $str;
22 }
23  
24 sub dump {
25 6 ▶ my ($self, $value, $arg) = @_;
Subroutine dump: called CC=5 SCAR=19.2
Pod undocumented
26 6 ▶ my $basename = $arg->{basename} || 'dump';
Condition50%1/2
$arg->{'basename'} || 'dump'
l!l
60
MC/DC0%0/1
$arg->{'basename'} || 'dump'
$arg->{'basename'}
Truth table50%1/2
A
A= $arg->{'basename'}
Aresult
11
00
27  
28 my ($dump, $error) = try {
29 6 ▶ (YAML::XS::Dump($value), undef);
Subroutine __ANON__: called CC=1 SCAR=0.0
30 } catch {
31 0 ▶ (undef, $_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 6 };
33  
34 6 ▶ if (defined $dump) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dump) { } 6 0 6
35 5 ▶ my $ident = ref $value ? (try { "$value" } catch { "<unknown>" })
Subroutine __ANON__: called CC=1 SCAR=1.2
36 6 ▶ : defined $value ? "$value" # quotes in case of glob, vstr, etc.
Branch: 2 branches
BranchTrueFalseTotal
ref $value ? : 5 1 6
defined $value ? : 1 0 1
37 : "(undef)";
38  
39 6 $ident = $self->_ident_from($ident);
40  
41 return {
42 6 filename => "$basename.yaml",
43 mimetype => 'text/plain',
44 body => $dump,
45 ident => $ident,
46 };
47 } else {
48 0 ▶ my $string = try { "$value" } catch { "value could not stringify: $_" };
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 my $ident = $self->_ident_from($string);
50  
51 return {
52 0 filename => "$basename.txt",
53 mimetype => 'text/plain',
54 body => <<EOB,
55 __DATA__
« Reporter/Sender/Dir.pm ↑ Summary Reporter/Summarizer/MooseException.pm »