Serialize/Encode/yaml.pm

filter: Statementstmt 88.3% 38 / 43 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 1 / 1 totaltotal 84.1% 53 / 63 CC 4 SCAR 5.0
CC
4
Cov
82%
BEGIN
3.4
to_bool
2.1
__ANON__
2.0
CRAP 1.7
« Serialize/Error.pm ↑ Summary Serialize/Encode/ddump.pm »
1 package Data::Record::Serialize::Encode::yaml;
2  
3 # ABSTRACT: encode a record as YAML
4  
5 2 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Data::Record::Serialize::Error { errors => ['yaml_backend'] }, -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Types::Standard qw[ Enum ];
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use JSON::PP; # needed for JSON::PP::true/false
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our $VERSION = '2.05';
16  
17 2 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=12.2
18 2 my $YAML_XS_VERSION = 0.67;
19  
20 2 ▶ if ( eval { require YAML::XS; YAML::XS->VERSION( $YAML_XS_VERSION ); 1; } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { require YAML::XS; 'YAML::XS'->VERSION($YAML_XS_VERSION); 1 } }) { } 2 0 2
elsif (eval { do { require YAML::PP } }) { } 0 0 0
21 2 ▶ *encode = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
22 ## no critic (Variables::ProhibitPackageVars)
23 2 local $YAML::XS::Boolean = 'JSON::PP';
24 2 ▶ YAML::XS::Dump( $_[1] );
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 };
26 }
27 0 elsif ( eval { require YAML::PP } ) {
28 0 my $processor = YAML::PP->new( boolean => 'JSON::PP' );
29 0 ▶ *encode = sub { $processor->dump_string( $_[1] ) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 }
31 else {
32 0 error( 'yaml_backend',
33 "can't find either YAML::XS (>= $YAML_XS_VERSION) or YAML::PP. Please install one of them" );
34 }
35 }
36  
37 2 has '+numify' => ( is => 'ro', default => 1 );
38 2 has '+stringify' => ( is => 'ro', default => 1 );
39  
40 2 ▶sub _needs_eol { 1 }
Subroutine _needs_eol: called CC=1 SCAR=0.0
41  
42  
43  
44  
45  
46  
47  
48  
49  
50 1 ▶sub to_bool { $_[1] ? JSON::PP::true : JSON::PP::false }
Subroutine to_bool: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 1 0 1
51  
52  
53  
54  
55  
56  
57 2 with 'Data::Record::Serialize::Role::Encode';
58  
59 2 1;
60  
61 #
62 # This file is part of Data-Record-Serialize
63 #
64 # This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
65 #
66 # This is free software, licensed under:
67 #
68 # The GNU General Public License, Version 3, June 2007
69 #
70  
71 __END__
« Serialize/Error.pm ↑ Summary Serialize/Encode/ddump.pm »