Geoffrey/Role/Converter.pm

filter: Statementstmt 99.0% 101 / 102 Branchbran 78.5% 22 / 28 Conditioncond 100% 5 / 5 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 33 / 33 Podpod 100% 27 / 27 totaltotal 96.4% 191 / 198 CC 17 SCAR 10.9
CC
17
Cov
95%
check_version
7.0
type
6.0
_get_table_hashref
5.6
CRAP 3.0
« Geoffrey/Role/Core.pm ↑ Summary Geoffrey/Action/Entry.pm »
1 package Geoffrey::Role::Converter;
2  
3 19 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use Perl::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 19 $Geoffrey::Role::Converter::VERSION = '0.000204';
10  
11 sub new {
12 33 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
13 33 my $self = {@_};
14 33 return bless $self, $class;
15 }
16  
17 sub changelog_table {
18 26 ▶ $_[0]->{changelog_table} //= 'geoffrey_changelogs';
Subroutine changelog_table: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
$_[0]{"changelog_table"} //= "geoffrey_changelogs"
l!l
224
MC/DC100%1/1
$_[0]{"changelog_table"} //= "geoffrey_changelogs"
$_[0]{"changelog_table"}
Truth table100%2/2
A
A= $_[0]{"changelog_table"}
Aresult
11
00
19 26 return $_[0]->{changelog_table};
20 }
21  
22 sub changelog_columns {
23 return [{
24 3 ▶ name => 'id',
Subroutine changelog_columns: called CC=1 SCAR=0.0
Pod documented
25 type => 'varchar',
26 lenght => 64,
27 primarykey => 1,
28 notnull => 1,
29 default => '\'\''
30 },
31 {name => 'created_by', type => 'varchar', lenght => 128, notnull => 1, default => '\'\'',},
32 {name => 'filename', type => 'varchar', lenght => 255,},
33 {name => 'md5sum', type => 'varchar', lenght => 64,},
34 {name => 'description', type => 'varchar', lenght => 255,},
35 {name => 'comment', type => 'varchar', lenght => 128,},
36 {
37 name => 'geoffrey_version',
38 type => 'varchar',
39 lenght => 16,
40 notnull => 1,
41 default => '\'\''
42 },
43 {name => 'created', type => 'timestamp', default => 'current_timestamp', notnull => 1,},
44 ];
45 }
46  
47 sub origin_types {
48 return [
49 83 ▶ 'abstime', 'aclitem', #Al
Subroutine origin_types: called CC=1 SCAR=0.0
Pod documented
50 'bigint', 'bigserial', 'bit', 'varbit', 'blob', 'bool', 'box', 'bytea', #B
51 'char', 'character', 'varchar', 'cid', 'cidr', 'circle', #C
52 'date', 'daterange', 'double', 'double_precision', 'decimal', #D
53 #E
54 #F
55 'gtsvector', #G
56 #H
57 'inet', 'int2vector', 'int4range', 'int8range', 'integer', 'interval', #I
58 'json', #J
59 #K
60 'line', 'lseg', #L
61 'macaddr', 'money', #M
62 'name', 'numeric', 'numrange', #N
63 'oid', 'oidvector', #O
64 'path', 'pg_node_tree', 'point', 'polygon', #P
65 #Q
66 'real', 'refcursor', 'regclass', 'regconfig', 'regdictionary', 'regoper', 'regoperator',
67 'regproc', 'regprocedure', 'regtype', 'reltime', #R
68 'serial', 'smallint', 'smallserial', 'smgr', #S
69 'text', 'tid', 'timestamp', 'timestamp_tz', 'time', 'time_tz', 'tinterval', 'tsquery',
70 'tsrange', 'tstzrange', 'tsvector', 'txid_snapshot', #T
71 'uuid', #U
72 #V
73 #W
74 'xid', #X
75 #Y
76 #Z
77 ];
78 }
79  
80 9 ▶sub min_version { return shift->{min_version} }
Subroutine min_version: called CC=1 SCAR=0.0
Pod documented
81  
82 9 ▶sub max_version { return shift->{max_version} }
Subroutine max_version: called CC=1 SCAR=0.0
Pod documented
83  
84 sub can_create_empty_table;
85  
86 sub check_version {
87 9 ▶ my ($self, $s_version) = @_;
Subroutine check_version: called CC=7 SCAR=19.5
Pod documented
88 9 $s_version = Perl::Version->new($s_version);
89 9 my ($s_max_version, $s_min_version) = undef;
90 9 ▶ eval { $s_min_version = $self->min_version; } or do { };
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $s_min_version = $self->min_version } } or do { () } 0 9 9
91 9 ▶ eval { $s_max_version = $self->max_version; } or do { };
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $s_max_version = $self->max_version } } or do { () } 6 3 9
92 9 $s_min_version = Perl::Version->new($s_min_version);
93 9 ▶ if ($s_max_version) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s_max_version) { } 3 6 9
elsif ($s_min_version <= $s_version) { } 5 1 6
94 3 $s_max_version = Perl::Version->new($s_max_version);
95 3 ▶ return 1 if ($s_min_version <= $s_version && $s_version <= $s_max_version);
Branch: 1 branch
BranchTrueFalseTotal
if $s_min_version <= $s_version and $s_version <= $s_max_version 1 2 3
Condition100%3/3
$s_min_version <= $s_version and $s_version <= $s_max_version
!ll&&!rl&&r
111
MC/DC100%2/2
$s_min_version <= $s_version and $s_version <= $s_max_version
$s_min_version <= $s_version $s_version <= $s_max_version
Truth table100%3/3
A and B
A= $s_min_version <= $s_versionB= $s_version <= $s_max_version
ABresult
0X0
100
111
96 2 require Geoffrey::Exception::NotSupportedException;
97 2 Geoffrey::Exception::NotSupportedException::throw_version($self, $s_min_version,
98 $s_version, $s_max_version);
99 }
100 elsif ($s_min_version <= $s_version) {
101 5 return 1;
102 }
103 1 require Geoffrey::Exception::NotSupportedException;
104 1 return Geoffrey::Exception::NotSupportedException::throw_version($self, $s_min_version,
105 $s_version);
106 }
107  
108 sub type {
109 85 ▶ my ($self, $hr_column_params) = @_;
Subroutine type: called CC=6 SCAR=17.9
Pod documented
110 85 ▶ if (!$hr_column_params->{type}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hr_column_params->{"type"}) 2 83 85
111 2 require Geoffrey::Exception::RequiredValue;
112 2 Geoffrey::Exception::RequiredValue::throw_column_type($self);
113 }
114 my $s_column_type
115 5893 = (grep {/^$hr_column_params->{type}$/sxm} @{$self->origin_types()})
116 ? $self->types()->{$hr_column_params->{type}}
117 83 ▶ : undef;
Branch: 1 branch
BranchTrueFalseTotal
grep({/^$hr_column_params->{'type'}$/msx;} @{$self->origin_types;}) ? : 82 1 83
118 83 ▶ if (!$s_column_type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s_column_type) 1 82 83
119 1 require Geoffrey::Exception::NotSupportedException;
120 Geoffrey::Exception::NotSupportedException::throw_column_type($hr_column_params->{type},
121 1 $self);
122 }
123 82 ▶ $s_column_type .= $hr_column_params->{strict} ? '(strict)' : q//;
Branch: 1 branch
BranchTrueFalseTotal
$hr_column_params->{'strict'} ? : 0 82 82
124 $s_column_type
125 82 ▶ .= defined $hr_column_params->{lenght} ? qq~($hr_column_params->{lenght})~ : q//;
Branch: 1 branch
BranchTrueFalseTotal
defined $hr_column_params->{'lenght'} ? : 19 63 82
126 82 return $s_column_type;
127 }
128  
129 sub _get_table_hashref {
130 3 ▶ my ($self, $dbh, $s_name, $ar_columns, $s_schema) = @_;
Subroutine _get_table_hashref: called CC=5 SCAR=17.3
131 3 my $s_select_get_table = $self->select_get_table;
132 3 my $sth = $dbh->prepare($s_select_get_table);
133 3 ▶ if ($s_schema) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s_schema) { } 0 3 3
134 0 ▶ $sth->execute($s_schema, $s_name) or Carp::confess $!;
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($s_schema, $s_name) or Carp::confess($!) 0 0 0
135 }
136 else {
137 3 ▶ $sth->execute($s_name) or Carp::confess $!;
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($s_name) or Carp::confess($!) 0 3 3
138 }
139 3 my $hr_table = $sth->fetchrow_hashref();
140 3 ▶ return if defined $hr_table;
Branch: 1 branch
BranchTrueFalseTotal
if defined $hr_table 1 2 3
141 2 return {name => $s_name, columns => $ar_columns,};
142 }
143  
144 sub get_changelog_table_hashref {
145 3 ▶ my ($self, $o_dbh, $s_schema) = @_;
Subroutine get_changelog_table_hashref: called CC=1 SCAR=0.0
Pod documented
146 3 return $self->_get_table_hashref(
147 $o_dbh,
148 $self->changelog_table(),
149 $self->changelog_columns(), $s_schema
150 );
151 }
152  
153 sub constraints {
154 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine constraints: called CC=1 SCAR=0.0
Pod documented
155 1 return Geoffrey::Exception::NotSupportedException::throw_converter();
156 }
157  
158 sub index {
159 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine index: called CC=1 SCAR=0.0
Pod documented
160 1 return Geoffrey::Exception::NotSupportedException::throw_converter();
161 }
162  
163 sub table {
164 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine table: called CC=1 SCAR=0.0
Pod documented
165 1 return Geoffrey::Exception::NotSupportedException::throw_converter();
166 }
167  
168 sub view {
169 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine view: called CC=1 SCAR=0.0
Pod documented
170 1 return Geoffrey::Exception::NotSupportedException::throw_converter();
171 }
172  
173 sub foreign_key {
174 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine foreign_key: called CC=1 SCAR=0.0
Pod documented
175 1 return Geoffrey::Exception::NotSupportedException::throw_converter();
176 }
177  
178 sub trigger {
179 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine trigger: called CC=1 SCAR=0.0
Pod documented
180 1 return Geoffrey::Exception::NotSupportedException::throw_converter();
181 }
182  
183 sub primary_key {
184 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine primary_key: called CC=1 SCAR=0.0
Pod documented
185 1 return Geoffrey::Exception::NotSupportedException::throw_converter();
186 }
187  
188 sub sequence {
189 7 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine sequence: called CC=1 SCAR=0.0
Pod documented
190 7 return Geoffrey::Exception::NotSupportedException::throw_converter();
191 }
192  
193 sub function {
194 6 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine function: called CC=1 SCAR=0.0
Pod documented
195 6 return Geoffrey::Exception::NotSupportedException::throw_converter();
196 }
197  
198 sub unique {
199 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine unique: called CC=1 SCAR=0.0
Pod documented
200 1 return Geoffrey::Exception::NotSupportedException::throw_converter();
201 }
202  
203 sub colums_information {
204 2 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine colums_information: called CC=1 SCAR=0.0
Pod documented
205 2 return Geoffrey::Exception::NotSupportedException::throw_list_information('colums_information',
206 shift);
207 }
208  
209 sub index_information {
210 2 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine index_information: called CC=1 SCAR=0.0
Pod documented
211 2 return Geoffrey::Exception::NotSupportedException::throw_list_information('index_information',
212 shift);
213 }
214  
215 sub view_information {
216 2 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine view_information: called CC=1 SCAR=0.0
Pod documented
217 2 return Geoffrey::Exception::NotSupportedException::throw_list_information('view_information',
218 shift);
219 }
220  
221 sub sequence_information {
222 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine sequence_information: called CC=1 SCAR=0.0
Pod documented
223 1 return Geoffrey::Exception::NotSupportedException::throw_list_information(
224 'sequence_information', shift);
225 }
226  
227 sub primary_key_information {
228 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine primary_key_information: called CC=1 SCAR=0.0
Pod documented
229 1 return Geoffrey::Exception::NotSupportedException::throw_list_information(
230 'primary_key_information', shift);
231 }
232  
233 sub function_information {
234 2 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine function_information: called CC=1 SCAR=0.0
Pod documented
235 2 return Geoffrey::Exception::NotSupportedException::throw_list_information(
236 'function_information', shift);
237 }
238  
239 sub unique_information {
240 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine unique_information: called CC=1 SCAR=0.0
Pod documented
241 1 return Geoffrey::Exception::NotSupportedException::throw_list_information('unique_information',
242 shift);
243 }
244  
245 sub trigger_information {
246 1 ▶ require Geoffrey::Exception::NotSupportedException;
Subroutine trigger_information: called CC=1 SCAR=0.0
Pod documented
247 1 return Geoffrey::Exception::NotSupportedException::throw_list_information(
248 'trigger_information', shift);
249 }
250  
251 19 1; # End of Geoffrey::converter
252  
253 __END__
« Geoffrey/Role/Core.pm ↑ Summary Geoffrey/Action/Entry.pm »