Zonalizer/DB/Memory.pm

filter: Statementstmt 12.4% 33 / 265 Branchbran 0.8% 0 / 118 (1 uncoverable) Conditioncond 0.0% 0 / 39 MC/DCmcdc 0.0% 0 / 26 Subroutinesub 52.6% 10 / 19 Podpod 100% 9 / 9 totaltotal 11.1% 52 / 476 (1 uncoverable) CC 76 SCAR 64.8
CC
76
Cov
8%
ReadAnalysis
1482.0
UpdateAnalyze
240.0
CreateAnalyze
67.9
CRAP 654.4
« Zonalizer/DB/CouchDB.pm ↑ Summary Zonalizer.pm »
1 package Lim::Plugin::Zonalizer::DB::Memory;
2  
3 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Data::UUID ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Lim::Plugin::Zonalizer qw(:err);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use URI::Escape::XS qw(uri_escape);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Lim ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use base qw(Lim::Plugin::Zonalizer::DB);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 our %FIELD = ( analysis => { map { $_ => 1 } ( qw(created updated) ) } );
18  
19 =encoding utf8
20  
21 =head1 NAME
22  
23 Lim::Plugin::Zonalizer::DB::Memory - The in memory database for Zonalizer
24  
25 =head1 METHODS
26  
27 =over 4
28  
29 =item Init
30  
31 =cut
32  
33 0 ▶sub Init {
Subroutine Init: not called CC=1 SCAR=6.9
Pod documented
34 0 my ( $self ) = @_;
35  
36 0 $self->{space}->{''}->{analysis} = [];
37 0 $self->{space}->{''}->{analyze} = {};
38 0 $self->{space}->{''}->{analyze_fqdn} = {};
39 0 $self->{space}->{''}->{analyze_rfqdn} = {};
40  
41 0 return;
42 }
43  
44 =item Destroy
45  
46 =cut
47  
48 0 ▶sub Destroy {
Subroutine Destroy: not called CC=1 SCAR=0.0
Pod documented
49 }
50  
51 =item Name
52  
53 =cut
54  
55 0 ▶sub Name {
Subroutine Name: not called CC=1 SCAR=6.9
Pod documented
56 0 return 'Memory';
57 }
58  
59 =item ReadAnalysis
60  
61 =cut
62  
63 0 ▶sub ReadAnalysis {
Subroutine ReadAnalysis: not called CC=38 SCAR=73.0
Pod documented
64 0 my ( $self, %args ) = @_;
65  
66 0 ▶ unless ( ref( $args{cb} ) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args{"cb"} eq "CODE") 0 0 0
67 0 confess 'cb is not CODE';
68 }
69 0 undef $@;
70  
71 0 ▶ my $limit = defined $args{limit} ? $args{limit} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'limit'} ? : 0 0 0
72 0 ▶ if ( $limit == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($limit == 0) 0 0 0
73 0 $args{cb}->();
74 0 return;
75 }
76 0 ▶ unless ( $limit > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($limit > 0) 0 0 0
77 0 $@ = ERR_INVALID_LIMIT;
78 0 $args{cb}->();
79 0 return;
80 }
81  
82 0 my $search_fqdn;
83 my $search_fqdn2;
84 0 ▶ if ( defined $args{search} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"search"}) 0 0 0
85 0 ▶ if ( $args{search} =~ /^\../o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'search'} =~ /^\../ou) { } 0 0 0
86 0 $search_fqdn2 = $args{search};
87 0 $search_fqdn2 =~ s/^\.//o;
88 0 ▶ unless ( $search_fqdn2 =~ /\.$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($search_fqdn2 =~ /\.$/ou) 0 0 0
89 0 $search_fqdn2 .= '.';
90 }
91 0 $search_fqdn2 = join( '.', reverse( split( /\./o, $search_fqdn2 ) ) );
92 }
93 else {
94 0 $search_fqdn = $args{search};
95 0 ▶ unless ( $search_fqdn =~ /\.$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($search_fqdn =~ /\.$/ou) 0 0 0
96 0 $search_fqdn .= '.';
97 }
98 }
99 }
100  
101 0 ▶ my $space = $args{space} ? $args{space} : '';
Branch: 1 branch
BranchTrueFalseTotal
$args{'space'} ? : 0 0 0
102 0 ▶ if ( $space and !exists $self->{space}->{$space} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($space and not exists $self->{"space"}{$space}) 0 0 0
Condition0%0/3
$space and not exists $self->{"space"}{$space}
!ll&&!rl&&r
000
MC/DC0%0/2
$space and not exists $self->{"space"}{$space}
$space not exists $self->{"space"}{$space}
Truth table0%0/3
A and not(B)
A= $spaceB= not exists $self->{"space"}{$space}
ABresult
0X0
100
111
103 0 $self->{space}->{''}->{analysis} = [];
104 0 $self->{space}->{''}->{analyze} = {};
105 0 $self->{space}->{''}->{analyze_fqdn} = {};
106 0 $self->{space}->{''}->{analyze_rfqdn} = {};
107 }
108  
109 0 my @analysis;
110 0 my ( $paging, $previous, $next ) = ( 0, 0, 0 );
111 0 my $analysis = $self->{space}->{$space}->{analysis};
112  
113 0 ▶ if ( defined $search_fqdn ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $search_fqdn) { } 0 0 0
elsif (defined $search_fqdn2) { } 0 0 0
114 0 ▶ unless ( exists $self->{space}->{$space}->{analyze_fqdn}->{$search_fqdn} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"space"}{$space}{"analyze_fqdn"}{$search_fqdn}) 0 0 0
115 0 $args{cb}->( undef );
116 0 return;
117 }
118  
119 0 $analysis = $self->{space}->{$space}->{analyze_fqdn}->{$search_fqdn};
120 }
121 elsif ( defined $search_fqdn2 ) {
122 0 ▶ unless ( exists $self->{space}->{$space}->{analyze_rfqdn}->{$search_fqdn2} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"space"}{$space}{"analyze_rfqdn"}{$search_fqdn2}) 0 0 0
123 0 $args{cb}->( undef );
124 0 return;
125 }
126  
127 0 $analysis = $self->{space}->{$space}->{analyze_rfqdn}->{$search_fqdn2};
128 }
129  
130 0 ▶ if ( scalar @{$analysis} and defined $args{sort} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$analysis;} and defined $args{"sort"}) 0 0 0
Condition0%0/3
scalar @{$analysis;} and defined $args{"sort"}
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @{$analysis;} and defined $args{"sort"}
scalar @{$analysis;} defined $args{"sort"}
Truth table0%0/3
A and B
A= scalar @{$analysis;}B= defined $args{"sort"}
ABresult
0X0
100
111
131 0 ▶ unless ( exists $analysis->[0]->{ $args{sort} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $analysis->[0]{$args{"sort"}}) 0 0 0
132 0 $@ = ERR_INVALID_SORT_FIELD;
133 0 $args{cb}->();
134 0 return;
135 }
136 0 ▶ if ( $args{direction} eq 'descending' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'direction'} eq 'descending') { } 0 0 0
137 0 my @sort;
138 0 ▶ if ( exists $FIELD{analysis}->{ $args{sort} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Lim::Plugin::Zonalizer::DB::Memory::FIELD{'analysis'}{$args{'sort'}}) { } 0 0 0
139 0 @sort = sort { $b->{ $args{sort} } <=> $a->{ $args{sort} } } @{$analysis};
140 }
141 else {
142 0 @sort = sort { $b->{ $args{sort} } cmp $a->{ $args{sort} } } @{$analysis};
143 }
144 0 $analysis = \@sort;
145 }
146 else {
147 0 my @sort;
148 0 ▶ if ( exists $FIELD{analysis}->{ $args{sort} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Lim::Plugin::Zonalizer::DB::Memory::FIELD{'analysis'}{$args{'sort'}}) { } 0 0 0
149 0 @sort = sort { $a->{ $args{sort} } <=> $b->{ $args{sort} } } @{$analysis};
150 }
151 else {
152 0 @sort = sort { $a->{ $args{sort} } cmp $b->{ $args{sort} } } @{$analysis};
153 }
154 0 $analysis = \@sort;
155 }
156 }
157  
158 0 foreach my $analyze ( @$analysis ) {
159 0 ▶ if ( $paging ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($paging) 0 0 0
160 0 $next = 1;
161 0 last;
162 }
163 0 ▶ if ( defined $args{after} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"after"}) 0 0 0
164 0 ▶ if ( $analyze->{id} eq $args{after} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($analyze->{"id"} eq $args{"after"}) 0 0 0
165 0 delete $args{after};
166 }
167 0 $previous = 1;
168 0 next;
169 }
170 0 ▶ if ( defined $args{before} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"before"}) 0 0 0
171 0 ▶ if ( $analyze->{id} eq $args{before} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($analyze->{"id"} eq $args{"before"}) 0 0 0
172 0 $next = 1;
173 0 last;
174 }
175 0 ▶ if ( scalar @analysis == $limit ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @analysis == $limit) 0 0 0
176 0 $previous = 1;
177 0 shift( @analysis );
178 }
179 }
180  
181 0 push( @analysis, clone $analyze );
182  
183 0 ▶ if ( scalar @analysis == $limit && !defined $args{before} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @analysis == $limit and not defined $args{"before"}) 0 0 0
Condition0%0/3
scalar @analysis == $limit and not defined $args{"before"}
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @analysis == $limit and not defined $args{"before"}
scalar @analysis == $limit not defined $args{"before"}
Truth table0%0/3
A and not(B)
A= scalar @analysis == $limitB= not defined $args{"before"}
ABresult
0X0
100
111
184 0 $paging = 1;
185 }
186 }
187 0 ▶ if ( $previous or $next ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($previous or $next) { } 0 0 0
Condition0%0/3
$previous or $next
l!l&&r!l&&!r
000
MC/DC0%0/2
$previous or $next
$previous $next
Truth table0%0/3
A or B
A= $previousB= $next
ABresult
1X1
011
000
188 0 $paging = 1;
189 }
190 else {
191 0 $paging = 0;
192 }
193 0 ▶ unless ( scalar @analysis ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @analysis) 0 0 0
194 0 $paging = 0;
195 }
196  
197 $args{cb}->(
198 $paging
199 ? {
200 before => $analysis[0]->{id},
201 after => $analysis[-1]->{id},
202 0 ▶ previous => $previous,
Branch: 3 branches
BranchTrueFalseTotal
$paging ? : 0 0 0
defined $search_fqdn || defined $search_fqdn2 ? : 0 0 0
defined $search_fqdn ? : 0 0 0
Condition0%0/3
defined $search_fqdn or defined $search_fqdn2
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $search_fqdn or defined $search_fqdn2
defined $search_fqdn defined $search_fqdn2
Truth table0%0/3
A or B
A= defined $search_fqdnB= defined $search_fqdn2
ABresult
1X1
011
000
203 next => $next,
204 defined $search_fqdn || defined $search_fqdn2 ? ( extra => 'search=' . uri_escape( defined $search_fqdn ? $search_fqdn : ( '.' . $search_fqdn2 ) ) ) : ()
205 }
206 : undef,
207 @analysis
208 );
209 0 return;
210 }
211  
212 =item DeleteAnalysis
213  
214 =cut
215  
216 0 ▶sub DeleteAnalysis {
Subroutine DeleteAnalysis: not called CC=6 SCAR=37.4
Pod documented
217 0 my ( $self, %args ) = @_;
218  
219 0 ▶ unless ( ref( $args{cb} ) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args{"cb"} eq "CODE") 0 0 0
220 0 confess 'cb is not CODE';
221 }
222 0 undef $@;
223  
224 0 ▶ my $space = $args{space} ? $args{space} : '';
Branch: 1 branch
BranchTrueFalseTotal
$args{'space'} ? : 0 0 0
225 0 ▶ if ( $space and !exists $self->{space}->{$space} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($space and not exists $self->{"space"}{$space}) 0 0 0
Condition0%0/3
$space and not exists $self->{"space"}{$space}
!ll&&!rl&&r
000
MC/DC0%0/2
$space and not exists $self->{"space"}{$space}
$space not exists $self->{"space"}{$space}
Truth table0%0/3
A and not(B)
A= $spaceB= not exists $self->{"space"}{$space}
ABresult
0X0
100
111
226 0 $self->{space}->{''}->{analysis} = [];
227 0 $self->{space}->{''}->{analyze} = {};
228 0 $self->{space}->{''}->{analyze_fqdn} = {};
229 0 $self->{space}->{''}->{analyze_rfqdn} = {};
230 }
231  
232 0 my $deleted_analysis = scalar @{ $self->{space}->{$space}->{analysis} };
233  
234 0 ▶ if ( $space ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($space) { } 0 0 0
235 0 delete $self->{space}->{$space};
236 }
237 else {
238 0 $self->Init;
239 }
240  
241 0 $args{cb}->( $deleted_analysis );
242 0 return;
243 }
244  
245 =item CreateAnalyze
246  
247 =cut
248  
249 0 ▶sub CreateAnalyze {
Subroutine CreateAnalyze: not called CC=8 SCAR=42.2
Pod documented
250 0 my ( $self, %args ) = @_;
251  
252 0 ▶ unless ( ref( $args{cb} ) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args{"cb"} eq "CODE") 0 0 0
253 0 confess 'cb is not CODE';
254 }
255 0 $self->ValidateAnalyze( $args{analyze} );
256 0 undef $@;
257  
258 0 ▶ if ( exists $args{analyze}->{_rev} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"analyze"}{"_rev"}) 0 0 0
259  
260 # uncoverable branch false
261 0 ▶ Lim::ERR and $self->{logger}->error( 'Memory specific fields _rev existed during create' );
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error("Memory specific fields _rev existed during create") 0 0 0
262 0 $@ = ERR_INTERNAL_DATABASE;
263 0 $args{cb}->();
264 0 return;
265 }
266  
267 0 ▶ my $space = $args{space} ? $args{space} : '';
Branch: 1 branch
BranchTrueFalseTotal
$args{'space'} ? : 0 0 0
268 0 ▶ if ( $space and !exists $self->{space}->{$space} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($space and not exists $self->{"space"}{$space}) 0 0 0
Condition0%0/3
$space and not exists $self->{"space"}{$space}
!ll&&!rl&&r
000
MC/DC0%0/2
$space and not exists $self->{"space"}{$space}
$space not exists $self->{"space"}{$space}
Truth table0%0/3
A and not(B)
A= $spaceB= not exists $self->{"space"}{$space}
ABresult
0X0
100
111
269 0 $self->{space}->{''}->{analysis} = [];
270 0 $self->{space}->{''}->{analyze} = {};
271 0 $self->{space}->{''}->{analyze_fqdn} = {};
272 0 $self->{space}->{''}->{analyze_rfqdn} = {};
273 }
274  
275 0 ▶ if ( exists $self->{space}->{$space}->{analyze}->{ $args{analyze}->{id} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"space"}{$space}{"analyze"}{$args{"analyze"}{"id"}}) 0 0 0
276 0 $@ = ERR_DUPLICATE_ID;
277 0 $args{cb}->();
278 0 return;
279 }
280  
281 0 my $analyze = clone $args{analyze};
282 0 $analyze->{_rev} = Data::UUID->new->create_str;
283  
284 0 push( @{ $self->{space}->{$space}->{analysis} }, $analyze );
285 0 $self->{space}->{$space}->{analyze}->{ $args{analyze}->{id} } = $analyze;
286 0 push( @{ $self->{space}->{$space}->{analyze_fqdn}->{ $args{analyze}->{fqdn} } }, $analyze );
287 0 push( @{ $self->{space}->{$space}->{analyze_rfqdn}->{ join( '.', reverse( split( /\./o, $args{analyze}->{fqdn} ) ) ) } }, $analyze );
288  
289 0 $args{cb}->( clone $analyze );
290 0 return;
291 }
292  
293 =item ReadAnalyze
294  
295 =cut
296  
297 0 ▶sub ReadAnalyze {
Subroutine ReadAnalyze: not called CC=7 SCAR=40.3
Pod documented
298 0 my ( $self, %args ) = @_;
299  
300 0 ▶ unless ( ref( $args{cb} ) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args{"cb"} eq "CODE") 0 0 0
301 0 confess 'cb is not CODE';
302 }
303 0 ▶ unless ( defined $args{id} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"id"}) 0 0 0
304 0 confess 'id is not defined';
305 }
306 0 undef $@;
307  
308 0 ▶ my $space = $args{space} ? $args{space} : '';
Branch: 1 branch
BranchTrueFalseTotal
$args{'space'} ? : 0 0 0
309 0 ▶ if ( $space and !exists $self->{space}->{$space} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($space and not exists $self->{"space"}{$space}) 0 0 0
Condition0%0/3
$space and not exists $self->{"space"}{$space}
!ll&&!rl&&r
000
MC/DC0%0/2
$space and not exists $self->{"space"}{$space}
$space not exists $self->{"space"}{$space}
Truth table0%0/3
A and not(B)
A= $spaceB= not exists $self->{"space"}{$space}
ABresult
0X0
100
111
310 0 $self->{space}->{''}->{analysis} = [];
311 0 $self->{space}->{''}->{analyze} = {};
312 0 $self->{space}->{''}->{analyze_fqdn} = {};
313 0 $self->{space}->{''}->{analyze_rfqdn} = {};
314 }
315  
316 0 ▶ unless ( exists $self->{space}->{$space}->{analyze}->{ $args{id} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"space"}{$space}{"analyze"}{$args{"id"}}) 0 0 0
317 0 $@ = ERR_ID_NOT_FOUND;
318 0 $args{cb}->();
319 0 return;
320 }
321  
322 0 $args{cb}->( clone $self->{space}->{$space}->{analyze}->{ $args{id} } );
323 0 return;
324 }
325  
326 =item UpdateAnalyze
327  
328 =cut
329  
330 0 ▶sub UpdateAnalyze {
Subroutine UpdateAnalyze: not called CC=15 SCAR=54.8
Pod documented
331 0 my ( $self, %args ) = @_;
332  
333 0 ▶ unless ( ref( $args{cb} ) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args{"cb"} eq "CODE") 0 0 0
334 0 confess 'cb is not CODE';
335 }
336 0 $self->ValidateAnalyze( $args{analyze} );
337 0 undef $@;
338  
339 0 ▶ my $space = $args{space} ? $args{space} : '';
Branch: 1 branch
BranchTrueFalseTotal
$args{'space'} ? : 0 0 0
340 0 ▶ if ( $space and !exists $self->{space}->{$space} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($space and not exists $self->{"space"}{$space}) 0 0 0
Condition0%0/3
$space and not exists $self->{"space"}{$space}
!ll&&!rl&&r
000
MC/DC0%0/2
$space and not exists $self->{"space"}{$space}
$space not exists $self->{"space"}{$space}
Truth table0%0/3
A and not(B)
A= $spaceB= not exists $self->{"space"}{$space}
ABresult
0X0
100
111
341 0 $self->{space}->{''}->{analysis} = [];
342 0 $self->{space}->{''}->{analyze} = {};
343 0 $self->{space}->{''}->{analyze_fqdn} = {};
344 0 $self->{space}->{''}->{analyze_rfqdn} = {};
345 }
346  
347 0 ▶ if ( defined $args{space} and $args{space} ne $args{analyze}->{space} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"space"} and $args{"space"} ne $args{"analyze"}{"space"}) 0 0 0
Condition0%0/3
defined $args{"space"} and $args{"space"} ne $args{"analyze"}{"space"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"space"} and $args{"space"} ne $args{"analyze"}{"space"}
defined $args{"space"} $args{"space"} ne $args{"analyze"}{"space"}
Truth table0%0/3
A and B
A= defined $args{"space"}B= $args{"space"} ne $args{"analyze"}{"space"}
ABresult
0X0
100
111
348 0 $@ = ERR_SPACE_MISSMATCH;
349 0 $args{cb}->();
350 0 return;
351 }
352 0 ▶ if ( !defined $args{space} and $args{analyze}->{space} ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $args{"space"} and $args{"analyze"}{"space"} ne "") 0 0 0
Condition0%0/3
not defined $args{"space"} and $args{"analyze"}{"space"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $args{"space"} and $args{"analyze"}{"space"} ne ""
not defined $args{"space"} $args{"analyze"}{"space"} ne ""
Truth table0%0/3
not(A) and B
A= not defined $args{"space"}B= $args{"analyze"}{"space"} ne ""
ABresult
0X0
100
111
353 0 $@ = ERR_SPACE_MISSMATCH;
354 0 $args{cb}->();
355 0 return;
356 }
357 0 ▶ unless ( exists $self->{space}->{$space}->{analyze}->{ $args{analyze}->{id} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"space"}{$space}{"analyze"}{$args{"analyze"}{"id"}}) 0 0 0
358 0 $@ = ERR_ID_NOT_FOUND;
359 0 $args{cb}->();
360 0 return;
361 }
362 0 ▶ unless ( defined $args{analyze}->{_rev} and $self->{space}->{$space}->{analyze}->{ $args{analyze}->{id} }->{_rev} eq $args{analyze}->{_rev} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"analyze"}{"_rev"} and $self->{"space"}{$space}{"analyze"}{$args{"analyze"}{"id"}}{"_rev"} eq $args{"analyze"}{"_rev"}) 0 0 0
Condition0%0/3
defined $args{"analyze"}{"_rev"} and $self->{"space"}{$space}{"analyze"}{$args{"analyze"}{"id"}}{"_rev"} eq $args{"analyze"}{"_rev"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"analyze"}{"_rev"} and $self->{"space"}{$space}{"analyze"}{$args{"analyze"}{"id"}}{"_rev"} eq $args{"analyze"}{"_rev"}
defined $args{"analyze"}{"_rev"} $self->{"space"}{$space}{"analyze"}{$args{"analyze"}{"id"}}{"_rev"} eq $args{"analyze"}{"_rev"}
Truth table0%0/3
A and B
A= defined $args{"analyze"}{"_rev"}B= $self->{"space"}{$space}{"analyze"}{$args{"analyze"}{"id"}}{"_rev"} eq $args{"analyze"}{"_rev"}
ABresult
0X0
100
111
363 0 $@ = ERR_REVISION_MISSMATCH;
364 0 $args{cb}->();
365 0 return;
366 }
367  
368 0 my $analyze = $self->{space}->{$space}->{analyze}->{ $args{analyze}->{id} };
369 0 foreach ( keys %$analyze ) {
370 0 ▶ unless ( exists $args{analyze}->{$_} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"analyze"}{$_}) 0 0 0
371 0 delete $analyze->{$_};
372 }
373 }
374 0 foreach ( keys %{ $args{analyze} } ) {
375 0 $analyze->{$_} = $args{analyze}->{$_};
376 }
377 0 $analyze->{_rev} = Data::UUID->new->create_str;
378  
379 0 $args{cb}->( clone $analyze );
380 0 return;
381 }
382  
383 =item DeleteAnalyze
384  
385 =cut
386  
387 0 ▶sub DeleteAnalyze {
Subroutine DeleteAnalyze: not called CC=7 SCAR=40.3
Pod documented
388 0 my ( $self, %args ) = @_;
389  
390 0 ▶ unless ( ref( $args{cb} ) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $args{"cb"} eq "CODE") 0 0 0
391 0 confess 'cb is not CODE';
392 }
393 0 ▶ unless ( defined $args{id} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"id"}) 0 0 0
394 0 confess 'id is not defined';
395 }
396 0 undef $@;
397  
398 0 ▶ my $space = $args{space} ? $args{space} : '';
Branch: 1 branch
BranchTrueFalseTotal
$args{'space'} ? : 0 0 0
399 0 ▶ if ( $space and !exists $self->{space}->{$space} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($space and not exists $self->{"space"}{$space}) 0 0 0
Condition0%0/3
$space and not exists $self->{"space"}{$space}
!ll&&!rl&&r
000
MC/DC0%0/2
$space and not exists $self->{"space"}{$space}
$space not exists $self->{"space"}{$space}
Truth table0%0/3
A and not(B)
A= $spaceB= not exists $self->{"space"}{$space}
ABresult
0X0
100
111
400 0 $self->{space}->{''}->{analysis} = [];
401 0 $self->{space}->{''}->{analyze} = {};
402 0 $self->{space}->{''}->{analyze_fqdn} = {};
403 0 $self->{space}->{''}->{analyze_rfqdn} = {};
404 }
405  
406 0 ▶ unless ( exists $self->{space}->{$space}->{analyze}->{ $args{id} } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"space"}{$space}{"analyze"}{$args{"id"}}) 0 0 0
407 0 $@ = ERR_ID_NOT_FOUND;
408 0 $args{cb}->();
409 0 return;
410 }
411  
412 0 @{ $self->{space}->{$space}->{analyzes} } = grep { $_->{id} ne $args{id} } @{ $self->{space}->{$space}->{analyzes} };
413 0 @{ $self->{space}->{$space}->{analyze_fqdn}->{ $self->{space}->{$space}->{analyze}->{ $args{id} }->{fqdn} } } = grep { $_->{id} ne $args{id} } @{ $self->{space}->{$space}->{analyze_fqdn}->{ $self->{space}->{$space}->{analyze}->{ $args{id} }->{fqdn} } };
414 0 @{ $self->{space}->{$space}->{analyze_rfqdn}->{ join( '.', reverse( split( /\./o, $self->{space}->{$space}->{analyze}->{ $args{id} }->{fqdn} ) ) ) } } = grep { $_->{id} ne $args{id} } @{ $self->{space}->{$space}->{analyze_rfqdn}->{ join( '.', reverse( split( /\./o, $self->{space}->{$space}->{analyze}->{ $args{id} }->{fqdn} ) ) ) } };
415  
416 0 $args{cb}->();
417 0 return;
418 }
419  
420 =back
421  
422 =head1 AUTHOR
423  
424 Jerry Lundström, C<< <lundstrom.jerry@gmail.com> >>
425  
426 =head1 BUGS
427  
428 Please report any bugs or feature requests to L<https://github.com/jelu/lim-plugin-zonalizer/issues>.
429  
430 =head1 SUPPORT
431  
432 You can find documentation for this module with the perldoc command.
433  
434 perldoc Lim::Plugin::Zonalizer::DB::Memory
435  
436 You can also look for information at:
437  
438 =over 4
439  
440 =item * Lim issue tracker (report bugs here)
441  
442 L<https://github.com/jelu/lim-plugin-zonalizer/issues>
443  
444 =back
445  
446 =head1 ACKNOWLEDGEMENTS
447  
448 =head1 LICENSE AND COPYRIGHT
449  
450 Copyright 2015-2016 Jerry Lundström
451 Copyright 2015-2016 IIS (The Internet Foundation in Sweden)
452  
453 This program is free software; you can redistribute it and/or modify it
454 under the terms of either: the GNU General Public License as published
455 by the Free Software Foundation; or the Artistic License.
456  
457 See http://dev.perl.org/licenses/ for more information.
458  
459  
460 =cut
461  
462 1 1; # End of Lim::Plugin::Zonalizer::DB::Memory
« Zonalizer/DB/CouchDB.pm ↑ Summary Zonalizer.pm »