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