DB/Registry/Entry.pm

filter: Statementstmt 98.3% 60 / 61 Branchbran 90.9% 20 / 22 Conditioncond 66.6% 6 / 9 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 93.3% 14 / 15 Podpod 87.5% 7 / 8 totaltotal 90.9% 110 / 121 CC 19 SCAR 15.2
CC
19
Cov
93%
_attrs
7.1
dump
7.0
_attr_method_specs
6.1
CRAP 4.6
« DB/Registry.pm ↑ Summary DB/Generic.pm »
1 package Rose::DB::Registry::Entry;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 17 ▶use Clone::PP();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 ▶use Rose::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 our @ISA = qw(Rose::Object);
9  
10 17 our $VERSION = '0.784';
11  
12 17 our $Debug = 0;
13  
14 #
15 # Object data
16 #
17  
18 17 our %Attrs;
19  
20 BEGIN
21 17 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
22 17 our %Attrs =
23 (
24 # Generic
25 catalog => { type => 'scalar' },
26 database => { type => 'scalar' },
27 dbi_driver => { type => 'scalar' },
28 description => { type => 'scalar' },
29 domain => { type => 'scalar' },
30 driver => { type => 'scalar', make_method => 0 },
31 dsn => { type => 'scalar' },
32 host => { type => 'scalar' },
33 password => { type => 'scalar' },
34 port => { type => 'scalar' },
35 schema => { type => 'scalar' },
36 server_time_zone => { type => 'scalar' },
37 type => { type => 'scalar' },
38 username => { type => 'scalar' },
39  
40 connect_options => { type => 'hash', method_spec => { interface => 'get_set_init' } },
41  
42 pre_disconnect_sql => { type => 'array' },
43 post_connect_sql => { type => 'array' },
44  
45 # Oracle
46 service => { type => 'scalar' },
47  
48 # Pg
49 european_dates => { type => 'boolean', method_spec => { default => 0 } },
50 pg_enable_utf8 => { type => 'boolean' },
51 options => { type => 'scalar' },
52 service => { type => 'scalar' },
53 sslmode => { type => 'scalar' },
54  
55 # SQLite
56 auto_create => { type => 'boolean', method_spec => { default => 1 } },
57 sqlite_unicode => { type => 'boolean' },
58  
59 # MySQL
60 mysql_auto_reconnect => { type => 'boolean' },
61 mysql_client_found_rows => { type => 'boolean' },
62 mysql_compression => { type => 'boolean' },
63 mysql_connect_timeout => { type => 'boolean' },
64 mysql_embedded_groups => { type => 'scalar' },
65 mysql_embedded_options => { type => 'scalar' },
66 mysql_enable_utf8 => { type => 'boolean' },
67 mysql_enable_utf8mb4 => { type => 'boolean' },
68 mysql_local_infile => { type => 'scalar' },
69 mysql_multi_statements => { type => 'boolean' },
70 mysql_read_default_file => { type => 'scalar' },
71 mysql_read_default_group => { type => 'scalar' },
72 mysql_socket => { type => 'scalar' },
73 mysql_ssl => { type => 'boolean' },
74 mysql_ssl_ca_file => { type => 'scalar' },
75 mysql_ssl_ca_path => { type => 'scalar' },
76 mysql_ssl_cipher => { type => 'scalar' },
77 mysql_ssl_client_cert => { type => 'scalar' },
78 mysql_ssl_client_key => { type => 'scalar' },
79 mysql_use_result => { type => 'boolean' },
80 mysql_bind_type_guessing => { type => 'boolean' },
81 );
82 }
83  
84 sub _attrs
85 256 ▶{
Subroutine _attrs: called CC=7 SCAR=19.6
86 256 my(%args) = @_;
87  
88 256 my $type = $args{'type'};
89  
90 # Type filter first
91 my @attrs =
92 256 ▶ $type ? (grep { $Attrs{$_}{'type'} eq $type } keys(%Attrs)) : keys(%Attrs);
Branch: 1 branch
BranchTrueFalseTotal
$type ? : 256 0 256
93  
94 256 ▶ if($args{'with_defaults'})
Branch: 2 branches
BranchTrueFalseTotal
if ($args{'with_defaults'}) { } 36 220 256
elsif ($args{'no_defaults'}) { } 36 184 220
95 {
96 @attrs = grep
97 {
98 36 $Attrs{$_}{'method_spec'} &&
99 504 ▶ defined $Attrs{$_}{'method_spec'}{'default'}
Condition66%2/3
$Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'} && defined $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}{'default'}
!ll&&!rl&&r
432072
MC/DC50%1/2
$Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'} && defined $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}{'default'}
$Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'} defined $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}{'default'}
Truth table66%2/3
A && B
A= $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}B= defined $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}{'default'}
ABresult
0X0
100
111
100 }
101 @attrs;
102 }
103 elsif($args{'no_defaults'})
104 {
105 @attrs = grep
106 {
107 36 !$Attrs{$_}{'method_spec'} ||
108 504 ▶ !defined $Attrs{$_}{'method_spec'}{'default'}
Condition66%2/3
$Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'} && defined $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}{'default'}
!ll&&!rl&&r
432072
MC/DC50%1/2
$Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'} && defined $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}{'default'}
$Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'} defined $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}{'default'}
Truth table66%2/3
A && B
A= $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}B= defined $Rose::DB::Registry::Entry::Attrs{$_}{'method_spec'}{'default'}
ABresult
0X0
100
111
109 }
110 @attrs;
111 }
112  
113 256 ▶ return wantarray ? @attrs : \@attrs;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 188 68 256
114 }
115  
116 sub _attr_method_specs
117 68 ▶{
Subroutine _attr_method_specs: called CC=6 SCAR=18.0
118 68 my $attrs = _attrs(@_);
119  
120 68 my @specs;
121  
122 68 foreach my $attr (@$attrs)
123 {
124 765 ▶ next if(exists $Attrs{$attr}{'make_method'} && !$Attrs{$attr}{'make_method'});
Branch: 1 branch
BranchTrueFalseTotal
if exists $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"} and not $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"} 17 748 765
Condition66%2/3
exists $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"} and not $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"}
!ll&&!rl&&r
748017
MC/DC50%1/2
exists $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"} and not $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"}
exists $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"} not $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"}
Truth table66%2/3
A and not(B)
A= exists $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"}B= not $Rose::DB::Registry::Entry::Attrs{$attr}{"make_method"}
ABresult
0X0
100
111
125  
126 748 ▶ if(my $spec = $Attrs{$attr}{'method_spec'})
Branch: 1 branch
BranchTrueFalseTotal
if (my $spec = $Rose::DB::Registry::Entry::Attrs{$attr}{'method_spec'}) { } 51 697 748
127 {
128 51 push(@specs, $attr => $spec);
129 }
130 else
131 {
132 697 push(@specs, $attr);
133 }
134 }
135  
136 68 ▶ return wantarray ? @specs : \@specs;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 68 0 68
137 }
138  
139 use Rose::Object::MakeMethods::Generic
140 17 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
141 17 'scalar' =>
142 [
143 _attr_method_specs(type => 'scalar'),
144 ],
145  
146 'boolean' =>
147 [
148 _attr_method_specs(type => 'boolean'),
149 ],
150  
151 'hash' =>
152 [
153 _attr_method_specs(type => 'hash'),
154 'connect_option' => { hash_key => 'connect_options' },
155 ],
156  
157 'array' =>
158 [
159 _attr_method_specs(type => 'array'),
160 ]
161 17 );
162  
163 28 ▶sub init_connect_options { {} }
Subroutine init_connect_options: called CC=1 SCAR=0.0
Pod undocumented
164  
165 4 ▶sub autocommit { shift->connect_option('AutoCommit', @_) }
Subroutine autocommit: called CC=1 SCAR=0.0
Pod documented
166 4 ▶sub print_error { shift->connect_option('PrintError', @_) }
Subroutine print_error: called CC=1 SCAR=0.0
Pod documented
167 4 ▶sub raise_error { shift->connect_option('RaiseError', @_) }
Subroutine raise_error: called CC=1 SCAR=0.0
Pod documented
168 4 ▶sub handle_error { shift->connect_option('HandleError', @_) }
Subroutine handle_error: called CC=1 SCAR=0.0
Pod documented
169  
170 sub driver
171 720 ▶{
Subroutine driver: called CC=2 SCAR=6.9
Pod documented
172 720 my($self) = shift;
173 720 ▶ return $self->{'driver'} unless(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 492 228 720
174 228 $self->{'dbi_driver'} = shift;
175 228 return $self->{'driver'} = lc $self->{'dbi_driver'};
176 }
177  
178 sub dump
179 36 ▶{
Subroutine dump: called CC=7 SCAR=19.5
Pod documented
180 36 my($self) = shift;
181  
182 36 my %dump;
183  
184 36 foreach my $attr (_attrs(type => 'scalar'),
185 _attrs(type => 'boolean', no_defaults => 1))
186 {
187 1440 my $value = $self->$attr();
188 1440 ▶ next unless(defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 1094 346 1440
189 346 $dump{$attr} = $value;
190 }
191  
192 36 foreach my $attr (_attrs(type => 'hash'), _attrs(type => 'array'))
193 {
194 108 my $value = $self->$attr();
195 108 ▶ next unless(defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 54 54 108
196 54 $dump{$attr} = Clone::PP::clone($value);
197 }
198  
199  
200 # These booleans have defaults, but we only want the ones
201 # where the values were explicitly set. Ugly...
202 36 foreach my $attr (_attrs(type => 'boolean', with_defaults => 1))
203 {
204 72 my $value = $self->{$attr};
205 72 ▶ next unless(defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 68 4 72
206 4 $dump{$attr} = Clone::PP::clone($value);
207 }
208  
209 36 return \%dump;
210 }
211  
212 0 ▶sub clone { Clone::PP::clone($_[0]) }
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
213  
214 17 1;
215  
216 __END__
« DB/Registry.pm ↑ Summary DB/Generic.pm »