lib/DBIx/QuickDB/Util/HashBase.pm

filter: Statementstmt 91.9% 91 / 99 Branchbran 85.2% 29 / 34 Conditioncond 47.3% 9 / 19 MC/DCmcdc 9.0% 1 / 11 Subroutinesub 87.5% 14 / 16 Podpod 100% 1 / 1 totaltotal 80.5% 145 / 180 CC 28 SCAR 20.9
CC
28
Cov
85%
import
15.7
_new
8.0
BEGIN
4.9
CRAP 8.1
« lib/DBIx/QuickDB/Util.pm ↑ Summary t/lib/QDB/FakeDriver.pm »
1 package DBIx::QuickDB::Util::HashBase;
2 64 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 64 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 64 our $VERSION = '0.000066';
6  
7 #################################################################
8 # #
9 # This is a generated file! Do not modify this file directly! #
10 # Use hashbase_inc.pl script to regenerate this file. #
11 # The script is part of the Object::HashBase distribution. #
12 # Note: You can modify the version number above this comment #
13 # if needed, that is fine. #
14 # #
15 #################################################################
16  
17 {
18 64 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 64 $DBIx::QuickDB::Util::HashBase::HB_VERSION = '0.009';
20 64 *DBIx::QuickDB::Util::HashBase::ATTR_SUBS = \%Object::HashBase::ATTR_SUBS;
21 64 *DBIx::QuickDB::Util::HashBase::ATTR_LIST = \%Object::HashBase::ATTR_LIST;
22 64 *DBIx::QuickDB::Util::HashBase::VERSION = \%Object::HashBase::VERSION;
23 64 *DBIx::QuickDB::Util::HashBase::CAN_CACHE = \%Object::HashBase::CAN_CACHE;
24 }
25  
26  
27 64 require Carp;
28 {
29 64 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 64 $Carp::Internal{+__PACKAGE__} = 1;
31 }
32  
33 64 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=16.0
34 # these are not strictly equivalent, but for out use we don't care
35 # about order
36 0 ▶ *_isa = ($] >= 5.010 && require mro) ? \&mro::get_linear_isa : sub {
Subroutine __ANON__: not called CC=2 SCAR=11.6
37 64 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
38 0 my @packages = ($_[0]);
39 0 my %seen;
40 0 for my $package (@packages) {
41 0 push @packages, grep !$seen{$_}++, @{"$package\::ISA"};
42 }
43 0 return \@packages;
44 }
45 64 ▶}
Branch: 1 branch
BranchTrueFalseTotal
$] >= 5.01 && require mro ? : 64 0 64
Condition33%1/3
$] >= "5.01" and require mro
!ll&&!rl&&r
0064
MC/DC0%0/2
$] >= "5.01" and require mro
$] >= "5.01" require mro
Truth table33%1/3
A and B
A= $] >= "5.01"B= require mro
ABresult
0X0
100
111
46  
47 64 my %SPEC = (
48 '^' => {reader => 1, writer => 0, dep_writer => 1, read_only => 0, strip => 1},
49 '-' => {reader => 1, writer => 0, dep_writer => 0, read_only => 1, strip => 1},
50 '>' => {reader => 0, writer => 1, dep_writer => 0, read_only => 0, strip => 1},
51 '<' => {reader => 1, writer => 0, dep_writer => 0, read_only => 0, strip => 1},
52 '+' => {reader => 0, writer => 0, dep_writer => 0, read_only => 0, strip => 1},
53 );
54  
55 239 ▶sub import {
Subroutine import: called CC=15 SCAR=27.5
56 239 my $class = shift;
57 239 my $into = caller;
58  
59 # Make sure we list the OLDEST version used to create this class.
60 239 ▶ my $ver = $DBIx::QuickDB::Util::HashBase::HB_VERSION || $DBIx::QuickDB::Util::HashBase::VERSION;
Condition33%1/3
$DBIx::QuickDB::Util::HashBase::HB_VERSION || $DBIx::QuickDB::Util::HashBase::VERSION
l!l&&r!l&&!r
23900
MC/DC0%0/2
$DBIx::QuickDB::Util::HashBase::HB_VERSION || $DBIx::QuickDB::Util::HashBase::VERSION
$DBIx::QuickDB::Util::HashBase::HB_VERSION $DBIx::QuickDB::Util::HashBase::VERSION
Truth table33%1/3
A || B
A= $DBIx::QuickDB::Util::HashBase::HB_VERSIONB= $DBIx::QuickDB::Util::HashBase::VERSION
ABresult
1X1
011
000
61 239 ▶ $DBIx::QuickDB::Util::HashBase::VERSION{$into} = $ver if !$DBIx::QuickDB::Util::HashBase::VERSION{$into} || $DBIx::QuickDB::Util::HashBase::VERSION{$into} > $ver;
Branch: 1 branch
BranchTrueFalseTotal
if not $DBIx::QuickDB::Util::HashBase::VERSION{$into} or $DBIx::QuickDB::Util::HashBase::VERSION{$into} > $ver 239 0 239
Condition33%1/3
not $DBIx::QuickDB::Util::HashBase::VERSION{$into} or $DBIx::QuickDB::Util::HashBase::VERSION{$into} > $ver
l!l&&r!l&&!r
23900
MC/DC0%0/2
not $DBIx::QuickDB::Util::HashBase::VERSION{$into} or $DBIx::QuickDB::Util::HashBase::VERSION{$into} > $ver
not $DBIx::QuickDB::Util::HashBase::VERSION{$into} $DBIx::QuickDB::Util::HashBase::VERSION{$into} > $ver
Truth table33%1/3
not(A) or B
A= not $DBIx::QuickDB::Util::HashBase::VERSION{$into}B= $DBIx::QuickDB::Util::HashBase::VERSION{$into} > $ver
ABresult
1X1
011
000
62  
63 239 my $isa = _isa($into);
64 239 ▶ my $attr_list = $DBIx::QuickDB::Util::HashBase::ATTR_LIST{$into} ||= [];
Condition50%1/2
$DBIx::QuickDB::Util::HashBase::ATTR_LIST{$into} ||= []
l!l
0239
MC/DC0%0/1
$DBIx::QuickDB::Util::HashBase::ATTR_LIST{$into} ||= []
$DBIx::QuickDB::Util::HashBase::ATTR_LIST{$into}
Truth table50%1/2
A
A= $DBIx::QuickDB::Util::HashBase::ATTR_LIST{$into}
Aresult
11
00
65 239 ▶ my $attr_subs = $DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$into} ||= {};
Condition50%1/2
$DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$into} ||= {}
l!l
0239
MC/DC0%0/1
$DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$into} ||= {}
$DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$into}
Truth table50%1/2
A
A= $DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$into}
Aresult
11
00
66  
67 my %subs = (
68 ($into->can('new') ? () : (new => \&_new)),
69 157 ▶ (map %{$DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$_} || {}}, @{$isa}[1 .. $#$isa]),
Condition50%1/2
$DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$_} || {}
l!l
1570
MC/DC0%0/1
$DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$_} || {}
$DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$_}
Truth table50%1/2
A
A= $DBIx::QuickDB::Util::HashBase::ATTR_SUBS{$_}
Aresult
11
00
70 (
71 map {
72 239 ▶ my $p = substr($_, 0, 1);
Branch: 1 branch
BranchTrueFalseTotal
$into->can('new') ? : 108 131 239
73 2143 my $x = $_;
74  
75 2143 ▶ my $spec = $SPEC{$p} || {reader => 1, writer => 1};
Condition100%2/2
$SPEC{$p} || {'reader', 1, 'writer', 1}
l!l
1874269
MC/DC100%1/1
$SPEC{$p} || {'reader', 1, 'writer', 1}
$SPEC{$p}
Truth table100%2/2
A
A= $SPEC{$p}
Aresult
11
00
76  
77 2143 ▶ substr($x, 0, 1) = '' if $spec->{strip};
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"strip"} 1874 269 2143
78 2143 push @$attr_list => $x;
79 2143 my ($sub, $attr) = (uc $x, $x);
80  
81 0 ▶ $attr_subs->{$sub} = sub() { $attr };
Subroutine __ANON__: not called CC=1 SCAR=1.2
82 2143 my %out = ($sub => $attr_subs->{$sub});
83  
84 2143 ▶ $out{$attr} = sub { $_[0]->{$attr} } if $spec->{reader};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"reader"} 2115 28 2143
85 2143 ▶ $out{"set_$attr"} = sub { $_[0]->{$attr} = $_[1] } if $spec->{writer};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"writer"} 270 1873 2143
86 2143 ▶ $out{"set_$attr"} = sub { Carp::croak("'$attr' is read-only") } if $spec->{read_only};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"read_only"} 629 1514 2143
87 2143 ▶ $out{"set_$attr"} = sub { Carp::carp("set_$attr() is deprecated"); $_[0]->{$attr} = $_[1] } if $spec->{dep_writer};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"dep_writer"} 1 2142 2143
88  
89 2143 %out;
90 } @_
91 ),
92 );
93  
94 64 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
95 239 *{"$into\::$_"} = $subs{$_} for keys %subs;
96 }
97  
98 3 ▶sub attr_list {
Subroutine attr_list: called CC=4 SCAR=14.3
Pod documented
99 3 my $class = shift;
100  
101 3 my $isa = _isa($class);
102  
103 3 my %seen;
104 15 my @list = grep { !$seen{$_}++ } map {
105 3 my @out;
106  
107 6 ▶ if (0.004 > ($DBIx::QuickDB::Util::HashBase::VERSION{$_} || 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (0.004 > ($DBIx::QuickDB::Util::HashBase::VERSION{$_} || 0)) { } 0 6 6
Condition50%1/2
$DBIx::QuickDB::Util::HashBase::VERSION{$_} || 0
l!l
60
MC/DC0%0/1
$DBIx::QuickDB::Util::HashBase::VERSION{$_} || 0
$DBIx::QuickDB::Util::HashBase::VERSION{$_}
Truth table50%1/2
A
A= $DBIx::QuickDB::Util::HashBase::VERSION{$_}
Aresult
11
00
108 0 Carp::carp("$_ uses an inlined version of DBIx::QuickDB::Util::HashBase too old to support attr_list()");
109 }
110 else {
111 6 my $list = $DBIx::QuickDB::Util::HashBase::ATTR_LIST{$_};
112 6 ▶ @out = $list ? @$list : ()
Branch: 1 branch
BranchTrueFalseTotal
$list ? : 6 0 6
113 }
114  
115 6 @out;
116 } reverse @$isa;
117  
118 3 return @list;
119 }
120  
121 154 ▶sub _new {
Subroutine _new: called CC=8 SCAR=20.8
122 154 my $class = shift;
123  
124 154 my $self;
125  
126 154 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 3 151 154
127 3 my $arg = shift;
128 3 my $type = ref($arg);
129  
130 3 ▶ if ($type eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'HASH') { } 1 2 3
131 1 $self = bless({%$arg}, $class)
132 }
133 else {
134 2 ▶ Carp::croak("Not sure what to do with '$type' in $class constructor")
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "ARRAY" 0 2 2
135 unless $type eq 'ARRAY';
136  
137 2 my %proto;
138 2 my @attributes = attr_list($class);
139 2 ▶ while (@$arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$arg) 9 1 10
140 9 my $val = shift @$arg;
141 9 ▶ my $key = shift @attributes or Carp::croak("Too many arguments for $class constructor");
Branch: 1 branch
BranchTrueFalseTotal
my $key = shift @attributes or Carp::croak("Too many arguments for $class constructor") 8 1 9
142 8 $proto{$key} = $val;
143 }
144  
145 1 $self = bless(\%proto, $class);
146 }
147 }
148 else {
149 151 $self = bless({@_}, $class);
150 }
151  
152 $DBIx::QuickDB::Util::HashBase::CAN_CACHE{$class} = $self->can('init')
153 153 ▶ unless exists $DBIx::QuickDB::Util::HashBase::CAN_CACHE{$class};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $DBIx::QuickDB::Util::HashBase::CAN_CACHE{$class} 49 104 153
154  
155 153 ▶ $self->init if $DBIx::QuickDB::Util::HashBase::CAN_CACHE{$class};
Branch: 1 branch
BranchTrueFalseTotal
if $DBIx::QuickDB::Util::HashBase::CAN_CACHE{$class} 145 8 153
156  
157 135 $self;
158 }
159  
160 64 1;
161  
162 __END__
« lib/DBIx/QuickDB/Util.pm ↑ Summary t/lib/QDB/FakeDriver.pm »