Zing/Store.pm

filter: Statementstmt 44.0% 22 / 50 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 33.3% 7 / 21 Podpod 100% 14 / 14 totaltotal 47.7% 43 / 90 CC 3 SCAR 11.0
CC
3
Cov
41%
args
12.0
drop
2.0
dump
2.0
CRAP 3.0
« Zing/Flow.pm ↑ Summary Zing/Channel.pm »
1 package Zing::Store;
2  
3 49 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 49 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 49 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 49 ▶use registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 49 ▶use routines;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 49 ▶use Data::Object::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 49 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 49 our $VERSION = '0.11'; # VERSION
16  
17 # METHODS
18  
19 sub args {
20 0 ▶ map +($$_[0], $#{$$_[1]} ? $$_[1] : $$_[1][0]),
Subroutine args: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$#{$$_[1];} ? : 0 0 0
Condition0%0/2
$_[1] || ''
l!l
00
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
21 map [$$_[0], [split /\|/, $$_[1]]],
22 map [split /=/], split /,\s*/,
23 $_[1] || ''
24 }
25  
26 sub drop {
27 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "drop" not implemented);
Subroutine drop: not called CC=1 SCAR=6.9
Pod documented
28 }
29  
30 sub dump {
31 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "dump" not implemented);
Subroutine dump: not called CC=1 SCAR=6.9
Pod documented
32 }
33  
34 sub keys {
35 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "keys" not implemented);
Subroutine keys: not called CC=1 SCAR=6.9
Pod documented
36 }
37  
38 sub pop {
39 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "pop" not implemented);
Subroutine pop: not called CC=1 SCAR=6.9
Pod documented
40 }
41  
42 sub pull {
43 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "pull" not implemented);
Subroutine pull: not called CC=1 SCAR=6.9
Pod documented
44 }
45  
46 sub push {
47 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "push" not implemented);
Subroutine push: not called CC=1 SCAR=6.9
Pod documented
48 }
49  
50 sub load {
51 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "load" not implemented);
Subroutine load: not called CC=1 SCAR=6.9
Pod documented
52 }
53  
54 sub recv {
55 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "recv" not implemented);
Subroutine recv: not called CC=1 SCAR=6.9
Pod documented
56 }
57  
58 sub send {
59 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "send" not implemented);
Subroutine send: not called CC=1 SCAR=6.9
Pod documented
60 }
61  
62 sub size {
63 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "size" not implemented);
Subroutine size: not called CC=1 SCAR=6.9
Pod documented
64 }
65  
66 sub slot {
67 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "slot" not implemented);
Subroutine slot: not called CC=1 SCAR=6.9
Pod documented
68 }
69  
70 sub term {
71 0 ▶ shift; return join(':', @_);
Subroutine term: not called CC=1 SCAR=6.9
Pod documented
72 }
73  
74  
75 sub test {
76 0 ▶ Carp::croak qq(Error in Store: (@{[ref$_[0]]}) method "test" not implemented);
Subroutine test: not called CC=1 SCAR=6.9
Pod documented
77 }
78  
79 49 1;
80  
81 =encoding utf8
82  
83 =head1 NAME
84  
85 Zing::Store - Storage Interface
86  
87 =cut
88  
89 =head1 ABSTRACT
90  
91 Data Storage Interface
92  
93 =cut
94  
95 =head1 SYNOPSIS
96  
97 use Zing::Store;
98  
99 my $store = Zing::Store->new;
100  
101 # $store->drop;
102  
103 =cut
104  
105 =head1 DESCRIPTION
106  
107 This package provides a data persistence interface to be implemented by data
108 storage abstractions.
109  
110 =cut
111  
112 =head1 LIBRARIES
113  
114 This package uses type constraints from:
115  
116 L<Zing::Types>
117  
118 =cut
119  
120 =head1 METHODS
121  
122 This package implements the following methods:
123  
124 =cut
125  
126 =head2 args
127  
128 args(Str $env) : (Any)
129  
130 The args method parses strings with key/value data (typically from an
131 environment variable) meant to be used in object construction.
132  
133 =over 4
134  
135 =item args example #1
136  
137 # given: synopsis
138  
139 [$store->args('port=0001,debug=0')]
140  
141 =back
142  
143 =over 4
144  
145 =item args example #2
146  
147 # given: synopsis
148  
149 [$store->args('ports=0001|0002,debug=0')]
150  
151 =back
152  
153 =cut
154  
155 =head2 drop
156  
157 drop(Str $key) : Int
158  
159 The drop method should remove items from the datastore by key.
160  
161 =over 4
162  
163 =item drop example #1
164  
165 # given: synopsis
166  
167 $store->drop('model');
168  
169 =back
170  
171 =cut
172  
173 =head2 dump
174  
175 dump(HashRef $data) : Str
176  
177 The dump method should encode and return the data provided in a format suitable
178 for the underlying storage mechanism.
179  
180 =over 4
181  
182 =item dump example #1
183  
184 # given: synopsis
185  
186 $store->dump({ status => 'ok' });
187  
188 =back
189  
190 =cut
191  
192 =head2 keys
193  
194 keys(Str @keys) : ArrayRef[Str]
195  
196 The keys method should return a list of keys under the namespace provided
197 including itself.
198  
199 =over 4
200  
201 =item keys example #1
202  
203 # given: synopsis
204  
205 my $keys = $store->keys('nodel');
206  
207 =back
208  
209 =over 4
210  
211 =item keys example #2
212  
213 # given: synopsis
214  
215 # $store->send('model', { status => 'ok' });
216  
217 my $keys = $store->keys('model');
218  
219 =back
220  
221 =cut
222  
223 =head2 load
224  
225 load(Str $data) : HashRef
226  
227 The load method should decode the data provided and returns the data as a
228 hashref.
229  
230 =over 4
231  
232 =item load example #1
233  
234 # given: synopsis
235  
236 $store->load('{"status":"ok"}');
237  
238 =back
239  
240 =cut
241  
242 =head2 pop
243  
244 pop(Str $key) : Maybe[HashRef]
245  
246 The pop method should pop data off of the bottom of a list in the datastore.
247  
248 =over 4
249  
250 =item pop example #1
251  
252 # given: synopsis
253  
254 $store->pop('collection');
255  
256 =back
257  
258 =over 4
259  
260 =item pop example #2
261  
262 # given: synopsis
263  
264 # $store->push('collection', { status => 1 });
265 # $store->push('collection', { status => 2 });
266  
267 $store->pop('collection');
268  
269 =back
270  
271 =cut
272  
273 =head2 pull
274  
275 pull(Str $key) : Maybe[HashRef]
276  
277 The pull method should pop data off of the top of a list in the datastore.
278  
279 =over 4
280  
281 =item pull example #1
282  
283 # given: synopsis
284  
285 $store->pull('collection');
286  
287 =back
288  
289 =over 4
290  
291 =item pull example #2
292  
293 # given: synopsis
294  
295 # $store->push('collection', { status => 'ok' });
296  
297 $store->pull('collection');
298  
299 =back
300  
301 =cut
302  
303 =head2 push
304  
305 push(Str $key, HashRef $val) : Int
306  
307 The push method should push data onto the bottom of a list in the datastore.
308  
309 =over 4
310  
311 =item push example #1
312  
313 # given: synopsis
314  
315 $store->push('collection', { status => 'ok' });
316  
317 =back
318  
319 =cut
320  
321 =head2 recv
322  
323 recv(Str $key) : Maybe[HashRef]
324  
325 The recv method should fetch and return data from the datastore by its key.
326  
327 =over 4
328  
329 =item recv example #1
330  
331 # given: synopsis
332  
333 $store->recv('model');
334  
335 =back
336  
337 =over 4
338  
339 =item recv example #2
340  
341 # given: synopsis
342  
343 # $store->send('model', { status => 'ok' });
344  
345 $store->recv('model');
346  
347 =back
348  
349 =cut
350  
351 =head2 send
352  
353 send(Str $key, HashRef $val) : Str
354  
355 The send method should commit data to the datastore with its key and return
356 truthy (or falsy if not).
357  
358 =over 4
359  
360 =item send example #1
361  
362 # given: synopsis
363  
364 $store->send('model', { status => 'ok' });
365  
366 =back
367  
368 =cut
369  
370 =head2 size
371  
372 size(Str $key) : Int
373  
374 The size method should return the size of a list in the datastore.
375  
376 =over 4
377  
378 =item size example #1
379  
380 # given: synopsis
381  
382 my $size = $store->size('collection');
383  
384 =back
385  
386 =over 4
387  
388 =item size example #2
389  
390 # given: synopsis
391  
392 # $store->push('collection', { status => 'ok' });
393  
394 my $size = $store->size('collection');
395  
396 =back
397  
398 =cut
399  
400 =head2 slot
401  
402 slot(Str $key, Int $pos) : Maybe[HashRef]
403  
404 The slot method should return the data from a list in the datastore by its
405 position in the list.
406  
407 =over 4
408  
409 =item slot example #1
410  
411 # given: synopsis
412  
413 my $model = $store->slot('collection', 0);
414  
415 =back
416  
417 =over 4
418  
419 =item slot example #2
420  
421 # given: synopsis
422  
423 # $store->push('collection', { status => 'ok' });
424  
425 my $model = $store->slot('collection', 0);
426  
427 =back
428  
429 =cut
430  
431 =head2 term
432  
433 term(Str @keys) : Str
434  
435 The term method generates a term (safe string) for the datastore. This method
436 doesn't need to be implemented.
437  
438 =over 4
439  
440 =item term example #1
441  
442 # given: synopsis
443  
444 $store->term('model');
445  
446 =back
447  
448 =cut
449  
450 =head2 test
451  
452 test(Str $key) : Int
453  
454 The test method should return truthy if the specific key exists in the
455 datastore.
456  
457 =over 4
458  
459 =item test example #1
460  
461 # given: synopsis
462  
463 # $store->push('collection', { status => 'ok' });
464  
465 $store->test('collection');
466  
467 =back
468  
469 =over 4
470  
471 =item test example #2
472  
473 # given: synopsis
474  
475 # $store->drop('collection');
476  
477 $store->test('collection');
478  
479 =back
480  
481 =cut
482  
483 =head1 AUTHOR
484  
485 Al Newkirk, C<awncorp@cpan.org>
486  
487 =head1 LICENSE
488  
489 Copyright (C) 2011-2019, Al Newkirk, et al.
490  
491 This is free software; you can redistribute it and/or modify it under the terms
492 of the The Apache License, Version 2.0, as elucidated in the L<"license
493 file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>.
494  
495 =head1 PROJECT
496  
497 L<Wiki|https://github.com/iamalnewkirk/zing/wiki>
498  
499 L<Project|https://github.com/iamalnewkirk/zing>
500  
501 L<Initiatives|https://github.com/iamalnewkirk/zing/projects>
502  
503 L<Milestones|https://github.com/iamalnewkirk/zing/milestones>
504  
505 L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md>
506  
507 L<Issues|https://github.com/iamalnewkirk/zing/issues>
508  
509 =cut
« Zing/Flow.pm ↑ Summary Zing/Channel.pm »