lib/DBIx/Deployer.pm

filter: Statementstmt 93.1% 435 / 467 Branchbran 47.9% 94 / 196 Conditioncond 47.6% 10 / 21 MC/DCmcdc 23.0% 3 / 13 Subroutinesub 98.9% 95 / 96 Podpod n/a totaltotal 80.3% 637 / 793 CC 113 SCAR 21.8
CC
113
Cov
79%
_signature
52.2
deploy
22.7
_signature
13.8
CRAP 8.9
↑ Summary
1 1 ▶use 5.14.2;
Subroutine __ANON__: called CC=1 SCAR=0.0
2 1 ▶use Modern::Perl;
Subroutine __ANON__: called CC=1 SCAR=0.0
3 1 ▶use Moops;
Subroutine __ANON__: called CC=1 SCAR=0.0
4  
5 1  
6 1 ▶class DBIx::Deployer::Patch 1.2.3 {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.2
7 1 ▶ use Digest::MD5;
Subroutine __ANON__: called CC=1 SCAR=0.0
8 1 ▶ use Term::ANSIColor qw(colored);
Subroutine __ANON__: called CC=1 SCAR=0.0
9 1 ▶ use Data::Printer colored => 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
10  
11 1 has deployed => ( is => 'rw', isa => Bool, default => 0 );
12 1 has verified => ( is => 'rw', isa => Bool, default => 0 );
13 1 has name => ( is => 'ro', isa => Str, required => true );
14 1 has supports_transactions => ( is => 'ro', isa => Bool, default => true );
15 1 has dependencies => ( is => 'ro', isa => Maybe[ArrayRef] );
16 1 has deploy_sql => ( is => 'ro', isa => Maybe[Str] );
17 1 has deploy_sql_args => ( is => 'rw', isa => Maybe[ArrayRef] );
18 1 has deploy_script => ( is => 'ro', isa => Maybe[Str] );
19 1 has deploy_script_args => ( is => 'rw', isa => Maybe[ArrayRef] );
20 1 has no_verify => ( is => 'ro', isa => Bool, default => false );
21 1 has verify_sql => ( is => 'ro', isa => Str );
22 1 has verify_sql_args => ( is => 'rw', isa => ArrayRef );
23 1 has verify_expects => ( is => 'ro', isa => ArrayRef );
24 1 has db => ( is => 'ro', isa => InstanceOf['DBI::db'], required => true );
25  
26 1 ▶ method deploy {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine deploy: called CC=11 SCAR=31.2
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 13 0 13
27 13 ▶ if($self->deploy_sql && $self->deploy_script) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->deploy_sql and $self->deploy_script) { } 0 13 13
elsif ($self->deploy_sql) { } 13 0 13
elsif ($self->deploy_script) { } 0 0 0
Condition33%1/3
$self->deploy_sql and $self->deploy_script
!ll&&!rl&&r
0130
MC/DC0%0/2
$self->deploy_sql and $self->deploy_script
$self->deploy_sql $self->deploy_script
Truth table33%1/3
A and B
A= $self->deploy_sqlB= $self->deploy_script
ABresult
0X0
100
111
28 0 $self->handle_error('Patch cannot have both deploy_sql and deploy_script.');
29 }
30 elsif($self->deploy_sql) {
31 13 ▶ if($self->deploy_sql_args){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->deploy_sql_args) { } 1 12 13
32 1 ▶ $self->db->do($self->deploy_sql, {}, @{ $self->deploy_sql_args })
Branch: 1 branch
BranchTrueFalseTotal
$self->db->do($self->deploy_sql, {}, @{$self->deploy_sql_args;}) or $self->handle_error($self->db->errstr) 1 0 1
33 or $self->handle_error($self->db->errstr);
34 }
35 else{
36 12 ▶ $self->db->do($self->deploy_sql) or $self->handle_error($self->db->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$self->db->do($self->deploy_sql) or $self->handle_error($self->db->errstr) 11 1 12
37 }
38 }
39 elsif($self->deploy_script) {
40 0 ▶ if( my $status = system $self->deploy_script, @{ $self->deploy_script_args || [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $status = system($self->deploy_script, @{$self->deploy_script_args or [];})) 0 0 0
Condition0%0/2
$self->deploy_script_args || []
l!l
00
MC/DC0%0/1
$self->deploy_script_args || []
$self->deploy_script_args
Truth table0%0/2
A
A= $self->deploy_script_args
Aresult
11
00
41 0 $self->handle_error("Exited with status $status.");
42 }
43 }
44 else {
45 0 $self->handle_error('Patch has neither deploy_sql nor deploy_script.');
46 }
47 }
48  
49 1 ▶ before deploy {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine deploy: called CC=5 SCAR=17.1
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 13 0 13
50 13 ▶ die colored(['red'], 'Patch "' . $self->name . '" is already deployed') if $self->deployed;
Branch: 1 branch
BranchTrueFalseTotal
if $self->deployed 0 13 13
51 13 ▶ if($self->supports_transactions && !$self->deploy_script){ $self->db->begin_work; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->supports_transactions and not $self->deploy_script) 13 0 13
Condition33%1/3
$self->supports_transactions and not $self->deploy_script
!ll&&!rl&&r
0013
MC/DC0%0/2
$self->supports_transactions and not $self->deploy_script
$self->supports_transactions not $self->deploy_script
Truth table33%1/3
A and not(B)
A= $self->supports_transactionsB= not $self->deploy_script
ABresult
0X0
100
111
52 }
53  
54 1 ▶ after deploy {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine deploy: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 12 0 12
55 12 $self->deployed(1);
56 12 $self->verify;
57 }
58  
59 1 ▶ method verify {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine verify: called CC=9 SCAR=22.1
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 12 0 12
60 12 ▶ if($self->no_verify){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->no_verify) 1 11 12
61 1 $self->verified(1);
62 1 return;
63 }
64  
65 11 ▶ unless($self->verify_sql && @{ $self->verify_expects || [] }){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->verify_sql and @{$self->verify_expects or [];}) 1 10 11
Condition80%4/5
$self->verify_sql and @{$self->verify_expects or [];}
!ll&&!rl&&r
0110
$self->verify_expects || []
l!l
101
MC/DC50%1/2
$self->verify_sql and @{$self->verify_expects or [];}
$self->verify_sql @{$self->verify_expects or [];}
MC/DC100%1/1
$self->verify_expects || []
$self->verify_expects
Truth table66%2/3
A and B
A= $self->verify_sqlB= @{$self->verify_expects or [];}
ABresult
0X0
100
111
Truth table100%2/2
A
A= $self->verify_expects
Aresult
11
00
66 1 $self->handle_error('Patch is missing verification attributes');
67 }
68  
69 10 my $result;
70  
71 10 ▶ if($self->verify_sql_args){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verify_sql_args) { } 1 9 10
72 1 ▶ $result = $self->db->selectall_arrayref($self->verify_sql, {}, @{ $self->verify_sql_args })
Branch: 1 branch
BranchTrueFalseTotal
$result = $self->db->selectall_arrayref($self->verify_sql, {}, @{$self->verify_sql_args;}) or $self->handle_error($self->db->errstr) 1 0 1
73 or $self->handle_error($self->db->errstr);
74 }
75 else{
76 9 ▶ $result = $self->db->selectall_arrayref($self->verify_sql)
Branch: 1 branch
BranchTrueFalseTotal
$result = $self->db->selectall_arrayref($self->verify_sql) or $self->handle_error($self->db->errstr) 9 0 9
77 or $self->handle_error($self->db->errstr);
78 }
79  
80 10 $self->verified($self->_check_signature($result));
81 }
82  
83 1 ▶ after verify {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine verify: called CC=5 SCAR=16.5
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 11 0 11
84 11 ▶ if($self->verified){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verified) { } 10 1 11
85 10 ▶ if($self->supports_transactions && !$self->deploy_script){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->supports_transactions and not $self->deploy_script) 10 0 10
Condition33%1/3
$self->supports_transactions and not $self->deploy_script
!ll&&!rl&&r
0010
MC/DC0%0/2
$self->supports_transactions and not $self->deploy_script
$self->supports_transactions not $self->deploy_script
Truth table33%1/3
A and not(B)
A= $self->supports_transactionsB= not $self->deploy_script
ABresult
0X0
100
111
86 10 $self->db->commit;
87 }
88 10 say colored(['green'], 'Patch "' . $self->name . '" completed successfully');
89 }
90 else{
91 1 $self->handle_error('Failed verification');
92 }
93 }
94  
95 1 ▶ method handle_error ( Str $error ){
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine handle_error: called CC=9 SCAR=23.3
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 3 0 3
if @_ != 1 0 3 3
$#_ >= 0 ? : 3 0 3
if ($#_ >= 0) 3 0 3
Type::Tiny::XS::Str($error) or _failed_check(9, "Str", $error, "exception_class", "Error::TypeTiny::Assertion") 3 0 3
96 3 ▶ if($self->supports_transactions && !$self->deploy_script){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->supports_transactions and not $self->deploy_script) 3 0 3
Condition33%1/3
$self->supports_transactions and not $self->deploy_script
!ll&&!rl&&r
003
MC/DC0%0/2
$self->supports_transactions and not $self->deploy_script
$self->supports_transactions not $self->deploy_script
Truth table33%1/3
A and not(B)
A= $self->supports_transactionsB= not $self->deploy_script
ABresult
0X0
100
111
97 3 $self->deployed(0);
98 3 ▶ $self->db->rollback or die $self->name . ': ' . $self->db->errstr;
Branch: 1 branch
BranchTrueFalseTotal
$self->db->rollback or die $self->name . ': ' . $self->db->errstr 3 0 3
99 }
100 3 die colored(['red'], 'Patch "' . $self->name . '" failed: ' . $error);
101 }
102
103 1 ▶ method _check_signature ( ArrayRef $result ){
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine _check_signature: called CC=7 SCAR=19.7
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 10 0 10
if @_ != 1 0 10 10
$#_ >= 0 ? : 10 0 10
if ($#_ >= 0) 10 0 10
Ref::Util::XS::is_plain_arrayref($result) or _failed_check(21, "ArrayRef", $result, "exception_class", "Error::TypeTiny::Assertion") 10 0 10
104 10 my $is_equal = $self->_signature($result) eq $self->_signature($self->verify_expects);
105 10 ▶ unless ( $is_equal ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_equal) 1 9 10
106 1 say 'Expected:';
107 1 say p( $self->verify_expects );
108 1 say "\nReceived:";
109 1 say p( $result );
110 }
111 10 return $is_equal;
112 }
113  
114 0 ▶ multi method _signature( HashRef $params ) {
Subroutine __ANON__: called CC=1 SCAR=4.1
Subroutine __ANON__: called CC=1 SCAR=4.1
Subroutine _signature: not called CC=9 SCAR=39.5
Branch: 8 branches
BranchTrueFalseTotal
ref $_[0] eq 'Kavorka::Signature::NOBBLE' ? : 0 0 0
@_ ? : 0 0 0
unless ($____nobble_checks) 0 0 0
if @_ != 1 0 0 0
$#_ >= 0 ? : 0 0 0
unless ($____nobble_checks) 0 0 0
if ($#_ >= 0) 0 0 0
Ref::Util::XS::is_plain_hashref($params) or _failed_check(22, "HashRef", $params, "exception_class", "Error::TypeTiny::Assertion") 0 0 0
115 return Digest::MD5::md5_base64(
116 join(
117 '',
118 map {
119 0 $self->_signature($_)
120 0 . $self->_signature( $params->{$_} )
121 } sort keys %$params
122 )
123 );
124 }
125  
126 0 ▶ multi method _signature( ArrayRef $params ) {
Subroutine __ANON__: called CC=1 SCAR=0.6
Subroutine __ANON__: called CC=1 SCAR=0.6
Subroutine _signature: called CC=9 SCAR=25.9
Branch: 8 branches
BranchTrueFalseTotal
ref $_[0] eq 'Kavorka::Signature::NOBBLE' ? : 53 0 53
@_ ? : 53 0 53
unless ($____nobble_checks) 0 53 53
if @_ != 1 0 53 53
$#_ >= 0 ? : 53 0 53
unless ($____nobble_checks) 0 53 53
if ($#_ >= 0) 0 0 0
Ref::Util::XS::is_plain_arrayref($params) or _failed_check(21, "ArrayRef", $params, "exception_class", "Error::TypeTiny::Assertion") 0 0 0
127 return Digest::MD5::md5_base64(
128 53 join( '', map { $self->_signature($_) } @$params )
129 );
130 }
131  
132 0 ▶ multi method _signature( Str $params ) {
Subroutine __ANON__: called CC=1 SCAR=0.6
Subroutine __ANON__: called CC=1 SCAR=0.6
Subroutine _signature: called CC=9 SCAR=26.2
Branch: 8 branches
BranchTrueFalseTotal
ref $_[0] eq 'Kavorka::Signature::NOBBLE' ? : 147 0 147
@_ ? : 147 0 147
unless ($____nobble_checks) 0 147 147
if @_ != 1 0 147 147
$#_ >= 0 ? : 147 0 147
unless ($____nobble_checks) 0 147 147
if ($#_ >= 0) 0 0 0
Type::Tiny::XS::Str($params) or _failed_check(9, "Str", $params, "exception_class", "Error::TypeTiny::Assertion") 0 0 0
133 147 return Digest::MD5::md5_base64($params);
134 };
135  
136 0 ▶ multi method _signature ( Undef $params ) {
Subroutine __ANON__: called CC=1 SCAR=0.6
Subroutine __ANON__: called CC=1 SCAR=0.6
Subroutine _signature: called CC=9 SCAR=26.2
Branch: 8 branches
BranchTrueFalseTotal
ref $_[0] eq 'Kavorka::Signature::NOBBLE' ? : 28 0 28
@_ ? : 28 0 28
unless ($____nobble_checks) 0 28 28
if @_ != 1 0 28 28
$#_ >= 0 ? : 28 0 28
unless ($____nobble_checks) 0 28 28
if ($#_ >= 0) 0 0 0
defined $params and _failed_check(6, "Undef", $params, "exception_class", "Error::TypeTiny::Assertion") 0 0 0
137 28 return;
138 }
139 }
140  
141 1 ▶class DBIx::Deployer 1.2.3 {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
142 1 ▶ use DBI;
Subroutine __ANON__: called CC=1 SCAR=0.0
143 1 ▶ use DBD::SQLite;
Subroutine __ANON__: called CC=1 SCAR=0.0
144 1 ▶ use JSON::XS;
Subroutine __ANON__: called CC=1 SCAR=0.0
145 1 ▶ use Term::ANSIColor;
Subroutine __ANON__: called CC=1 SCAR=0.0
146 1 ▶ use autodie;
Subroutine __ANON__: called CC=1 SCAR=0.0
147  
148 has target_db => ( is => 'lazy', isa => InstanceOf['DBI::db'],
149 builder => method {
150 die 'Missing attribute target_dsn. Optionally, you may pass a DBI::db as target_db' unless $self->target_dsn;
151 DBI->connect(
152 $self->target_dsn,
153 $self->target_username,
154 $self->target_password
155 ) or die $@;
156 1 }
157 );
158  
159 1 has target_dsn => ( is => 'ro', isa => Str );
160 1 has target_username => ( is => 'ro', isa => Str );
161 1 has target_password => ( is => 'ro', isa => Str );
162  
163 1 has patch_path => ( is => 'ro', isa => Str, required => true );
164 1 has deployer_db_file => ( is => 'ro', isa => Str );
165  
166 has deployer_db => ( is => 'lazy', isa => InstanceOf['DBI::db'],
167 builder => method {
168 die 'Missing attribute deployer_db_file if using SQLite for patch management' unless $self->deployer_db_file;
169 my $db = DBI->connect('dbi:SQLite:dbname=' . $self->deployer_db_file) or die $@;
170 my $tables = $db->selectall_arrayref('SELECT name FROM sqlite_master WHERE type = "table"') || [];
171  
172 unless(@$tables){
173 $self->_init($db);
174 }
175 return $db;
176 1 }
177 );
178  
179 1 has deployer_patch_table => ( is => 'ro', isa => Str, default => 'patches' );
180  
181 has _patches_hashref => (
182 is => 'rw',
183 isa => HashRef,
184 12 ▶ default => sub{ {} }
Subroutine __ANON__: called CC=1 SCAR=0.0
185 1 );
186
187 1 has supports_transactions => ( is => 'ro', isa => Bool, default => true );
188 1 has keep_newlines => ( is => 'ro', isa => Bool, default => false );
189  
190 1 ▶ method patches {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine patches: called CC=9 SCAR=22.1
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 18 0 18
191 18 ▶ return $self->_patches_hashref if %{ $self->_patches_hashref };
Branch: 1 branch
BranchTrueFalseTotal
if %{$self->_patches_hashref;} 8 10 18
192  
193 10 my $patches = $self->_patches_hashref;
194  
195 10 opendir(my $dh, $self->patch_path);
196 10 my @patch_files = sort readdir($dh);
197 10 closedir($dh);
198  
199 10 shift @patch_files for 1..2; # Throw away "." and ".."
200  
201 10 foreach my $file (@patch_files){
202 12 my $json;
203 {
204 12 local $/ = undef;
205 12 open(my $fh, '<', $self->patch_path . '/' . $file);
206 12 $json = <$fh>;
207 12 close($fh);
208 }
209 12 ▶ $json=~s/\n|\r\n/ /gm unless $self->keep_newlines;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->keep_newlines 12 0 12
210 12 my $patch_array = JSON::XS::decode_json($json);
211 12 foreach my $patch (@$patch_array) {
212  
213 my $status = $self->deployer_db->selectrow_hashref(
214 13 (sprintf q|SELECT * FROM %s WHERE name = ?|, $self->deployer_patch_table),{},$patch->{name});
215  
216 13 ▶ $self->record_patch($patch->{name}) unless $status;
Branch: 1 branch
BranchTrueFalseTotal
unless $status 13 0 13
217  
218 13 foreach (keys %$status) {
219 0 $patch->{$_} = $status->{$_};
220 }
221 13 $patch->{db} = $self->target_db;
222 13 $patch->{supports_transactions} = $self->supports_transactions;
223 13 $patches->{ $patch->{name} } = DBIx::Deployer::Patch->new( %$patch );
224 }
225 }
226 10 $self->_patches_hashref($patches);
227 10 return $self->_patches_hashref;
228 }
229  
230 1 ▶ method record_patch (Str $name) {
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine record_patch: called CC=7 SCAR=20.1
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 13 0 13
if @_ != 1 0 13 13
$#_ >= 0 ? : 13 0 13
if ($#_ >= 0) 13 0 13
Type::Tiny::XS::Str($name) or _failed_check(9, "Str", $name, "exception_class", "Error::TypeTiny::Assertion") 13 0 13
231 13 ▶ $self->deployer_db->do(
Branch: 1 branch
BranchTrueFalseTotal
$self->deployer_db->do(sprintf("INSERT INTO %s (name, deployed, verified) VALUES (?, ?, ?)", $self->deployer_patch_table), {}, $name, 0, 0) or die $@ 13 0 13
232 (sprintf q|INSERT INTO %s (name, deployed, verified) VALUES (?, ?, ?)|, $self->deployer_patch_table),
233 {}, $name, 0, 0) or die $@;
234 }
235  
236 1 ▶ method update_patch (InstanceOf['DBIx::Deployer::Patch'] $patch) {
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine update_patch: called CC=7 SCAR=20.1
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 10 0 10
if @_ != 1 0 10 10
$#_ >= 0 ? : 10 0 10
if ($#_ >= 0) 10 0 10
Type::Tiny::XS::AUTO::TC6($patch) or _failed_check(85, "InstanceOf[\"DBIx::Deployer::Patch\"]", $patch, "exception_class", "Error::TypeTiny::Assertion") 10 0 10
237 $self->deployer_db->do(
238 (sprintf q|UPDATE %s SET deployed = ?, verified = ? WHERE name = ?|, $self->deployer_patch_table),
239 10 ▶ {}, map{ $patch->$_ } qw(deployed verified name)
Branch: 1 branch
BranchTrueFalseTotal
$self->deployer_db->do(sprintf("UPDATE %s SET deployed = ?, verified = ? WHERE name = ?", $self->deployer_patch_table), {}, map({$patch->$_;} "deployed", "verified", "name")) or die $@ 10 0 10
240 ) or die $@;
241 }
242  
243 1 ▶ method deploy_all {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine deploy_all: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 8 0 8
244 8 my $patches = $self->patches;
245 8 foreach my $name (keys %$patches){
246 9 $self->deploy($patches->{$name});
247 }
248 7 return true;
249 }
250  
251 1 ▶ method deploy (InstanceOf['DBIx::Deployer::Patch'] $patch) {
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine deploy: called CC=12 SCAR=25.0
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 13 0 13
if @_ != 1 0 13 13
$#_ >= 0 ? : 13 0 13
if ($#_ >= 0) 13 0 13
Type::Tiny::XS::AUTO::TC6($patch) or _failed_check(85, "InstanceOf[\"DBIx::Deployer::Patch\"]", $patch, "exception_class", "Error::TypeTiny::Assertion") 13 0 13
252 13 ▶ return if $patch->deployed;
Branch: 1 branch
BranchTrueFalseTotal
if $patch->deployed 2 11 13
253  
254 11 ▶ my @dependencies = @{ $patch->dependencies || [] };
Condition100%2/2
$patch->dependencies || []
l!l
38
MC/DC100%1/1
$patch->dependencies || []
$patch->dependencies
Truth table100%2/2
A
A= $patch->dependencies
Aresult
11
00
255  
256 11 ▶ if(@dependencies){
Branch: 1 branch
BranchTrueFalseTotal
if (@dependencies) 3 8 11
257 3 my $patches = $self->patches;
258 3 foreach my $name (@dependencies){
259 3 ▶ if($patches->{$name}){
Branch: 1 branch
BranchTrueFalseTotal
if ($patches->{$name}) { } 2 1 3
260 2 $self->deploy($patches->{$name});
261 }
262 else{
263 1 die colored(['red'], q|Patch "| . $patch->name . qq|" failed: Patch dependency "$name" is not defined.|);
264 }
265 }
266 }
267  
268 10 eval{ $patch->deploy };
269 10 my $error = $@;
270 10 $self->update_patch($patch);
271 10 ▶ if($error){ die $error; }
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 1 9 10
272 }
273  
274 1 ▶ method _init (InstanceOf['DBI::db'] $db){
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine _init: called CC=7 SCAR=20.1
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 10 0 10
if @_ != 1 0 10 10
$#_ >= 0 ? : 10 0 10
if ($#_ >= 0) 10 0 10
Type::Tiny::XS::AUTO::TC4($db) or _failed_check(83, "InstanceOf[\"DBI::db\"]", $db, "exception_class", "Error::TypeTiny::Assertion") 10 0 10
275 10 ▶ $db->do(
Branch: 1 branch
BranchTrueFalseTotal
$db->do(sprintf("CREATE TABLE %s (name VARCHAR UNIQUE, deployed INT, verified INT)", $self->deployer_patch_table)) or die $@ 10 0 10
276 (sprintf q|CREATE TABLE %s (name VARCHAR UNIQUE, deployed INT, verified INT)|, $self->deployer_patch_table)
277 ) or die $@;
278 }
279 }
280  
281 # ABSTRACT: Light-weight database patch utility
282 # PODNAME: DBIx::Deployer
283  
284 __END__
↑ Summary