Old.pm

filter: Statementstmt 96.1% 75 / 78 Branchbran 62.5% 10 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 19 / 19 Podpod 75.0% 6 / 8 totaltotal 88.1% 111 / 126 SCAR 23.2
CC
10
Cov
89%
DumpFile
4.2
init_action_object
3.1
LoadFile
3.0
CRAP 10.1
« Old/Node.pm ↑ Summary Old/Error.pm »
1 35 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package YAML::Old;
3 35 our $VERSION = '1.07';
4  
5 35 ▶use YAML::Old::Mo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 35 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 35 push @YAML::Old::ISA, 'Exporter';
9 35 our @EXPORT = qw{ Dump Load };
10 35 our @EXPORT_OK = qw{ freeze thaw DumpFile LoadFile Bless Blessed };
11  
12 35 ▶use YAML::Old::Node; # XXX This is a temp fix for Module::Build
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # XXX This VALUE nonsense needs to go.
15 {
16 package
17 YAML;
18 35 ▶ use constant VALUE => "\x07YAML\x07VALUE\x07";
Subroutine BEGIN: called CC=1 SCAR=0.0
19 }
20  
21 # YAML Object Properties
22 138 ▶has dumper_class => default => sub {'YAML::Old::Dumper'};
Subroutine __ANON__: called CC=1 SCAR=0.0
23 260 ▶has loader_class => default => sub {'YAML::Old::Loader'};
Subroutine __ANON__: called CC=1 SCAR=0.0
24 138 ▶has dumper_object => default => sub {$_[0]->init_action_object("dumper")};
Subroutine __ANON__: called CC=1 SCAR=0.0
25 260 ▶has loader_object => default => sub {$_[0]->init_action_object("loader")};
Subroutine __ANON__: called CC=1 SCAR=0.0
26  
27 sub Dump {
28 138 ▶ my $yaml = YAML::Old->new;
Subroutine Dump: called CC=2 SCAR=7.1
Pod documented
29 138 ▶ $yaml->dumper_class($YAML::Old::DumperClass)
Branch: 1 branch
BranchTrueFalseTotal
if $YAML::Old::DumperClass 0 138 138
30 if $YAML::Old::DumperClass;
31 138 return $yaml->dumper_object->dump(@_);
32 }
33  
34 sub Load {
35 260 ▶ my $yaml = YAML::Old->new;
Subroutine Load: called CC=2 SCAR=7.1
Pod documented
36 260 ▶ $yaml->loader_class($YAML::Old::LoaderClass)
Branch: 1 branch
BranchTrueFalseTotal
if $YAML::Old::LoaderClass 0 260 260
37 if $YAML::Old::LoaderClass;
38 260 return $yaml->loader_object->load(@_);
39 }
40  
41 {
42 35 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
43 # freeze/thaw is the API for Storable string serialization. Some
44 # modules make use of serializing packages on if they use freeze/thaw.
45 35 *freeze = \ &Dump;
46 35 *thaw = \ &Load;
47 }
48  
49 sub DumpFile {
50 3 ▶ my $OUT;
Subroutine DumpFile: called CC=4 SCAR=14.4
Pod documented
51 3 my $filename = shift;
52 3 ▶ if (ref $filename eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $filename eq 'GLOB') { } 0 3 3
53 0 $OUT = $filename;
54 }
55 else {
56 3 my $mode = '>';
57 3 ▶ if ($filename =~ /^\s*(>{1,2})\s*(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename =~ /^\s*(>{1,2})\s*(.*)$/) 0 3 3
58 0 ($mode, $filename) = ($1, $2);
59 }
60 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, $!) 1 2 3
61 or YAML::Old::Mo::Object->die('YAML_DUMP_ERR_FILE_OUTPUT', $filename, $!);
62 }
63 2 binmode $OUT, ':utf8'; # if $Config{useperlio} eq 'define';
64 2 local $/ = "\n"; # reset special to "sane"
65 2 print $OUT Dump(@_);
66 }
67  
68 sub LoadFile {
69 3 ▶ my $IN;
Subroutine LoadFile: called CC=3 SCAR=11.1
Pod documented
70 3 my $filename = shift;
71 3 ▶ if (ref $filename eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $filename eq 'GLOB') { } 0 3 3
72 0 $IN = $filename;
73 }
74 else {
75 3 ▶ open $IN, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open $IN, "<", $filename or "YAML::Old::Mo::Object"->die("YAML_LOAD_ERR_FILE_INPUT", $filename, $!) 1 2 3
76 or YAML::Old::Mo::Object->die('YAML_LOAD_ERR_FILE_INPUT', $filename, $!);
77 }
78 2 binmode $IN, ':utf8'; # if $Config{useperlio} eq 'define';
79 2 return Load(do { local $/; <$IN> });
80 }
81  
82 sub init_action_object {
83 398 ▶ my $self = shift;
Subroutine init_action_object: called CC=3 SCAR=11.3
Pod undocumented
84 398 my $object_class = (shift) . '_class';
85 398 my $module_name = $self->$object_class;
86 398 eval "require $module_name";
87 398 ▶ $self->die("Error in require $module_name - $@")
Branch: 1 branch
BranchTrueFalseTotal
if $@ and not "$@" =~ /Can't locate/ 0 398 398
Condition33%1/3
$@ and not "$@" =~ /Can't locate/
!ll&&!rl&&r
39800
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
88 if $@ and "$@" !~ /Can't locate/;
89 398 my $object = $self->$object_class->new;
90 398 $object->set_global_options;
91 398 return $object;
92 }
93  
94 35 my $global = {};
95 sub Bless {
96 4 ▶ require YAML::Old::Dumper::Base;
Subroutine Bless: called CC=1 SCAR=0.0
Pod documented
97 4 YAML::Old::Dumper::Base::bless($global, @_)
98 }
99 sub Blessed {
100 1 ▶ require YAML::Old::Dumper::Base;
Subroutine Blessed: called CC=1 SCAR=0.0
Pod documented
101 1 YAML::Old::Dumper::Base::blessed($global, @_)
102 }
103 484 ▶sub global_object { $global }
Subroutine global_object: called CC=1 SCAR=0.0
Pod undocumented
104  
105 35 1;
« Old/Node.pm ↑ Summary Old/Error.pm »