YAML.pm

filter: Statementstmt 96.2% 76 / 79 Branchbran 70.0% 14 / 20 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 18 / 18 Podpod 75.0% 6 / 8 totaltotal 88.4% 115 / 130 CC 12 SCAR 10.0
CC
12
Cov
89%
DumpFile
6.5
init_action_object
3.1
LoadFile
3.0
CRAP 2.7
« YAML/Node.pm ↑ Summary YAML/Loader/Base.pm »
1 package YAML;
2 48 our $VERSION = '1.321';
3  
4 48 ▶use YAML::Mo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 48 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 48 push @YAML::ISA, 'Exporter';
8 48 our @EXPORT = qw{ Dump Load };
9 48 our @EXPORT_OK = qw{ freeze thaw DumpFile LoadFile Bless Blessed };
10 our (
11 48 $UseCode, $DumpCode, $LoadCode,
12 $SpecVersion,
13 $UseHeader, $UseVersion, $UseBlock, $UseFold, $UseAliases,
14 $Indent, $SortKeys, $Preserve,
15 $AnchorPrefix, $CompressSeries, $InlineSeries, $Purity,
16 $Stringify, $Numify, $LoadBlessed, $QuoteNumericStrings,
17 $DumperClass, $LoaderClass
18 );
19  
20 48 ▶use YAML::Node; # XXX This is a temp fix for Module::Build
Subroutine BEGIN: called CC=1 SCAR=0.0
21 48 ▶use Scalar::Util qw/ openhandle /;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # XXX This VALUE nonsense needs to go.
24 48 ▶use constant VALUE => "\x07YAML\x07VALUE\x07";
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # YAML Object Properties
27 158 ▶has dumper_class => default => sub {'YAML::Dumper'};
Subroutine __ANON__: called CC=1 SCAR=0.0
28 321 ▶has loader_class => default => sub {'YAML::Loader'};
Subroutine __ANON__: called CC=1 SCAR=0.0
29 158 ▶has dumper_object => default => sub {$_[0]->init_action_object("dumper")};
Subroutine __ANON__: called CC=1 SCAR=0.0
30 321 ▶has loader_object => default => sub {$_[0]->init_action_object("loader")};
Subroutine __ANON__: called CC=1 SCAR=0.0
31  
32 158 ▶sub Dump {
Subroutine Dump: called CC=2 SCAR=7.1
Pod documented
33 158 my $yaml = YAML->new;
34 158 ▶ $yaml->dumper_class($YAML::DumperClass)
Branch: 1 branch
BranchTrueFalseTotal
if $YAML::DumperClass 0 158 158
35 if $YAML::DumperClass;
36 158 return $yaml->dumper_object->dump(@_);
37 }
38  
39 321 ▶sub Load {
Subroutine Load: called CC=2 SCAR=7.1
Pod documented
40 321 my $yaml = YAML->new;
41 321 ▶ $yaml->loader_class($YAML::LoaderClass)
Branch: 1 branch
BranchTrueFalseTotal
if $YAML::LoaderClass 0 321 321
42 if $YAML::LoaderClass;
43 321 return $yaml->loader_object->load(@_);
44 }
45  
46 {
47 48 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
48 # freeze/thaw is the API for Storable string serialization. Some
49 # modules make use of serializing packages on if they use freeze/thaw.
50 48 *freeze = \ &Dump;
51 48 *thaw = \ &Load;
52 }
53  
54 5 ▶sub DumpFile {
Subroutine DumpFile: called CC=6 SCAR=18.7
Pod documented
55 5 my $OUT;
56 5 my $filename = shift;
57 5 ▶ if (openhandle $filename) {
Branch: 1 branch
BranchTrueFalseTotal
if (&openhandle($filename)) { } 2 3 5
58 2 $OUT = $filename;
59 }
60 else {
61 3 my $mode = '>';
62 3 ▶ if ($filename =~ /^\s*(>{1,2})\s*(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename =~ /^\s*(>{1,2})\s*(.*)$/) 0 3 3
63 0 ($mode, $filename) = ($1, $2);
64 }
65 3 ▶ open $OUT, $mode, $filename
Branch: 1 branch
BranchTrueFalseTotal
open $OUT, $mode, $filename or "YAML::Mo::Object"->die("YAML_DUMP_ERR_FILE_OUTPUT", $filename, "$!") 2 1 3
66 or YAML::Mo::Object->die('YAML_DUMP_ERR_FILE_OUTPUT', $filename, "$!");
67 }
68 4 binmode $OUT, ':utf8'; # if $Config{useperlio} eq 'define';
69 4 local $/ = "\n"; # reset special to "sane"
70 4 print $OUT Dump(@_);
71 4 ▶ unless (ref $filename eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $filename eq "GLOB") 4 0 4
72 close $OUT
73 4 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
close $OUT or do { my $errsav = $!; "YAML::Mo::Object"->die("YAML_DUMP_ERR_FILE_OUTPUT_CLOSE", $filename, $errsav) } 4 0 4
74 0 my $errsav = $!;
75 0 YAML::Mo::Object->die('YAML_DUMP_ERR_FILE_OUTPUT_CLOSE', $filename, $errsav);
76 }
77 }
78 }
79  
80 5 ▶sub LoadFile {
Subroutine LoadFile: called CC=3 SCAR=11.0
Pod documented
81 5 my $IN;
82 5 my $filename = shift;
83 5 ▶ if (openhandle $filename) {
Branch: 1 branch
BranchTrueFalseTotal
if (&openhandle($filename)) { } 2 3 5
84 2 $IN = $filename;
85 }
86 else {
87 3 ▶ open $IN, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $IN, "<", $filename or "YAML::Mo::Object"->die("YAML_LOAD_ERR_FILE_INPUT", $filename, "$!") 2 1 3
88 or YAML::Mo::Object->die('YAML_LOAD_ERR_FILE_INPUT', $filename, "$!");
89 }
90 4 binmode $IN, ':utf8'; # if $Config{useperlio} eq 'define';
91 4 return Load(do { local $/; <$IN> });
92 }
93  
94 479 ▶sub init_action_object {
Subroutine init_action_object: called CC=3 SCAR=11.3
Pod undocumented
95 479 my $self = shift;
96 479 my $object_class = (shift) . '_class';
97 479 my $module_name = $self->$object_class;
98 479 eval "require $module_name";
99 479 ▶ $self->die("Error in require $module_name - $@")
Branch: 1 branch
BranchTrueFalseTotal
if $@ and not "$@" =~ /Can't locate/ 0 479 479
Condition33%1/3
$@ and not "$@" =~ /Can't locate/
!ll&&!rl&&r
47900
MC/DC0%0/2
$@ and not "$@" =~ /Can't locate/
$@ not "$@" =~ /Can't locate/
Truth table33%1/3
A and not(B)
A= $@B= not "$@" =~ /Can't locate/
ABresult
0X0
100
111
100 if $@ and "$@" !~ /Can't locate/;
101 479 my $object = $self->$object_class->new;
102 479 $object->set_global_options;
103 479 return $object;
104 }
105  
106 48 my $global = {};
107 4 ▶sub Bless {
Subroutine Bless: called CC=1 SCAR=0.0
Pod documented
108 4 require YAML::Dumper::Base;
109 4 YAML::Dumper::Base::bless($global, @_)
110 }
111 1 ▶sub Blessed {
Subroutine Blessed: called CC=1 SCAR=0.0
Pod documented
112 1 require YAML::Dumper::Base;
113 1 YAML::Dumper::Base::blessed($global, @_)
114 }
115 509 ▶sub global_object { $global }
Subroutine global_object: called CC=1 SCAR=0.0
Pod undocumented
116  
117 48 1;
« YAML/Node.pm ↑ Summary YAML/Loader/Base.pm »