Old.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
« Old/Node.pm ↑ Summary Old/Loader/Base.pm »
1 package YAML::Old;
2 44 our $VERSION = '1.23';
3  
4 44 ▶use YAML::Old::Mo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 44 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 44 push @YAML::Old::ISA, 'Exporter';
8 44 our @EXPORT = qw{ Dump Load };
9 44 our @EXPORT_OK = qw{ freeze thaw DumpFile LoadFile Bless Blessed };
10 our (
11 44 $UseCode, $DumpCode, $LoadCode,
12 $SpecVersion,
13 $UseHeader, $UseVersion, $UseBlock, $UseFold, $UseAliases,
14 $Indent, $SortKeys, $Preserve,
15 $AnchorPrefix, $CompressSeries, $InlineSeries, $Purity,
16 $Stringify, $Numify
17 );
18  
19  
20 44 ▶use YAML::Old::Node; # XXX This is a temp fix for Module::Build
Subroutine BEGIN: called CC=1 SCAR=0.0
21 44 ▶use Scalar::Util qw/ openhandle /;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # XXX This VALUE nonsense needs to go.
24 44 ▶use constant VALUE => "\x07YAML\x07VALUE\x07";
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # YAML Object Properties
27 149 ▶has dumper_class => default => sub {'YAML::Old::Dumper'};
Subroutine __ANON__: called CC=1 SCAR=0.0
28 279 ▶has loader_class => default => sub {'YAML::Old::Loader'};
Subroutine __ANON__: called CC=1 SCAR=0.0
29 149 ▶has dumper_object => default => sub {$_[0]->init_action_object("dumper")};
Subroutine __ANON__: called CC=1 SCAR=0.0
30 279 ▶has loader_object => default => sub {$_[0]->init_action_object("loader")};
Subroutine __ANON__: called CC=1 SCAR=0.0
31  
32 149 ▶sub Dump {
Subroutine Dump: called CC=2 SCAR=7.1
Pod documented
33 149 my $yaml = YAML::Old->new;
34 149 ▶ $yaml->dumper_class($YAML::DumperClass)
Branch: 1 branch
BranchTrueFalseTotal
if $YAML::DumperClass 0 149 149
35 if $YAML::DumperClass;
36 149 return $yaml->dumper_object->dump(@_);
37 }
38  
39 279 ▶sub Load {
Subroutine Load: called CC=2 SCAR=7.1
Pod documented
40 279 my $yaml = YAML::Old->new;
41 279 ▶ $yaml->loader_class($YAML::LoaderClass)
Branch: 1 branch
BranchTrueFalseTotal
if $YAML::LoaderClass 0 279 279
42 if $YAML::LoaderClass;
43 279 return $yaml->loader_object->load(@_);
44 }
45  
46 {
47 44 ▶ 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 44 *freeze = \ &Dump;
51 44 *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::Old::Mo::Object"->die("YAML_DUMP_ERR_FILE_OUTPUT", $filename, "$!") 2 1 3
66 or YAML::Old::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::Old::Mo::Object"->die("YAML_DUMP_ERR_FILE_OUTPUT_CLOSE", $filename, $errsav) } 4 0 4
74 0 my $errsav = $!;
75 0 YAML::Old::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::Old::Mo::Object"->die("YAML_LOAD_ERR_FILE_INPUT", $filename, "$!") 2 1 3
88 or YAML::Old::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 428 ▶sub init_action_object {
Subroutine init_action_object: called CC=3 SCAR=11.3
Pod undocumented
95 428 my $self = shift;
96 428 my $object_class = (shift) . '_class';
97 428 my $module_name = $self->$object_class;
98 428 eval "require $module_name";
99 428 ▶ $self->die("Error in require $module_name - $@")
Branch: 1 branch
BranchTrueFalseTotal
if $@ and not "$@" =~ /Can't locate/ 0 428 428
Condition33%1/3
$@ and not "$@" =~ /Can't locate/
!ll&&!rl&&r
42800
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 428 my $object = $self->$object_class->new;
102 428 $object->set_global_options;
103 428 return $object;
104 }
105  
106 44 my $global = {};
107 4 ▶sub Bless {
Subroutine Bless: called CC=1 SCAR=0.0
Pod documented
108 4 require YAML::Old::Dumper::Base;
109 4 YAML::Old::Dumper::Base::bless($global, @_)
110 }
111 1 ▶sub Blessed {
Subroutine Blessed: called CC=1 SCAR=0.0
Pod documented
112 1 require YAML::Old::Dumper::Base;
113 1 YAML::Old::Dumper::Base::blessed($global, @_)
114 }
115 502 ▶sub global_object { $global }
Subroutine global_object: called CC=1 SCAR=0.0
Pod undocumented
116  
117 44 1;
« Old/Node.pm ↑ Summary Old/Loader/Base.pm »