Zing/Repo.pm

filter: Statementstmt 69.6% 39 / 56 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 10 / 15 Podpod 80.0% 4 / 5 totaltotal 67.9% 53 / 78 CC 3 SCAR 11.6
CC
3
Cov
67%
test
12.0
new_store
2.0
drop
2.0
CRAP 3.2
« Zing/Flow.pm ↑ Summary Zing/Queue.pm »
1 package Zing::Repo;
2  
3 56 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 56 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 56 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 56 ▶use registry 'Zing::Types';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 56 ▶use routines;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 56 ▶use Data::Object::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 56 ▶use Data::Object::ClassHas;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 56 ▶use Data::Object::Space;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 56 extends 'Zing::Entity';
16  
17 56 ▶use Zing::Store;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 56 ▶use Zing::Term;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 56 our $VERSION = '0.26'; # VERSION
21  
22 # ATTRIBUTES
23  
24 56 has 'name' => (
25 is => 'ro',
26 isa => 'Name',
27 req => 1,
28 );
29  
30 56 has 'store' => (
31 is => 'ro',
32 isa => 'Store',
33 new => 1,
34 );
35  
36 0 ▶fun new_store($self) {
Subroutine new_store: not called CC=1 SCAR=6.9
Pod undocumented
37 0 $self->app->store
38 56 }
39  
40 # METHODS
41  
42 0 ▶method drop() {
Subroutine drop: not called CC=1 SCAR=6.9
Pod documented
43 0 return $self->store->drop($self->term);
44 56 }
45  
46 0 ▶method search() {
Subroutine search: not called CC=1 SCAR=6.9
Pod documented
47 0 $self->app->search(store => $self->store)->using($self);
48 56 }
49  
50 0 ▶method term() {
Subroutine term: not called CC=1 SCAR=6.9
Pod documented
51 0 return $self->app->term($self)->repo;
52 56 }
53  
54 0 ▶method test(Str @keys) {
Subroutine test: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
Type::Tiny::XS::Str($_) or Function::Parameters::_croak('In method test: parameter 1 (@keys): ' . ${my $v = bless( {"_is_core" => 1,"_overload_coderef" => sub { package Sub::Defer; use warnings; use strict; $undeferred ||= undefer_sub($deferred_info->[4]); goto \&$undeferred;},"_overload_coderef_no_rebuild" => 1,"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Str","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; ref \$_ eq 'SCALAR' or ref \(my $val = $_) eq 'SCALAR';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 291,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Str","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","name" => "Str","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; defined $_[0] and not ref $_[0] or _failed_check(8, 'Value', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Value","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; not ref $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 276,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Value","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1]) and not ref($_[1])";},"library" => "Types::Standard","name" => "Value","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; defined $_[0] or _failed_check(7, 'Defined', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Defined","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; defined $_[0] and _failed_check(6, 'Undef', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Undef","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => {},"constraint" => sub { package Types::Standard; no warnings; use strict; not defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 254,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Undef","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "!defined($_[1])";},"library" => "Types::Standard","name" => "Undef","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Item","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 226,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Item","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Item","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_Any","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complement_name" => "None","constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 220,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Any","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Any","type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 1}, 'Type::Tiny' ),"uniq" => 2}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 6}, 'Type::Tiny' ),"constraint" => sub { package Types::Standard; no warnings; use strict; defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 262,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Defined","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1])";},"library" => "Types::Standard","name" => "Defined","parent" => {},"uniq" => 7}, 'Type::Tiny' ),"uniq" => 8}, 'Type::Tiny' ),"sorter" => sub { package Types::Standard; no warnings; use strict; $_[0] cmp $_[1];},"type_default" => sub { package Types::Standard; no warnings; use strict; return '';},"uniq" => 9}, 'Type::Tiny' );$v->{"coercion"}{"type_constraint"} = $v;$v->{"compiled_type_constraint"} = $v->{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"parent"};$v->{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"};$v->{"parent"}{"parent"}{"complementary_type"}{"compiled_type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"complementary_type"} = $v->{"parent"}{"parent"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"constraint"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}{"constraint"};$v->{"parent"}{"parent"}{"parent"} = $v->{"parent"}{"parent"}{"complementary_type"}{"parent"}; \$v}->get_message($_)) 0 0 0
55 0 return $self->store->test($self->term);
56 56 }
57  
58 56 1;
59  
60 =encoding utf8
61  
62 =head1 NAME
63  
64 Zing::Repo - Generic Store
65  
66 =cut
67  
68 =head1 ABSTRACT
69  
70 Generic Store Abstraction
71  
72 =cut
73  
74 =head1 SYNOPSIS
75  
76 use Zing::Repo;
77  
78 my $repo = Zing::Repo->new(name => 'text');
79  
80 # $repo->recv;
81  
82 =cut
83  
84 =head1 DESCRIPTION
85  
86 This package provides a general-purpose data storage abstraction.
87  
88 =cut
89  
90 =head1 LIBRARIES
91  
92 This package uses type constraints from:
93  
94 L<Zing::Types>
95  
96 =cut
97  
98 =head1 ATTRIBUTES
99  
100 This package has the following attributes:
101  
102 =cut
103  
104 =head2 name
105  
106 name(Str)
107  
108 This attribute is read-only, accepts C<(Str)> values, and is required.
109  
110 =cut
111  
112 =head2 store
113  
114 store(Store)
115  
116 This attribute is read-only, accepts C<(Store)> values, and is optional.
117  
118 =cut
119  
120 =head1 METHODS
121  
122 This package implements the following methods:
123  
124 =cut
125  
126 =head2 drop
127  
128 drop() : Int
129  
130 The drop method returns truthy if the data was removed from the store.
131  
132 =over 4
133  
134 =item drop example #1
135  
136 # given: synopsis
137  
138 $repo->drop('text-1');
139  
140 =back
141  
142 =cut
143  
144 =head2 search
145  
146 search() : Search
147  
148 The search method returns a L<Zing::Search> object based on the current repo or
149 L<Zing::Repo> derived object.
150  
151 =over 4
152  
153 =item search example #1
154  
155 # given: synopsis
156  
157 my $search = $repo->search;
158  
159 =back
160  
161 =cut
162  
163 =head2 term
164  
165 term() : Str
166  
167 The term method generates a term (safe string) for the datastore.
168  
169 =over 4
170  
171 =item term example #1
172  
173 # given: synopsis
174  
175 my $term = $repo->term;
176  
177 =back
178  
179 =cut
180  
181 =head2 test
182  
183 test() : Int
184  
185 The test method returns truthy if the specific key (or datastore) exists.
186  
187 =over 4
188  
189 =item test example #1
190  
191 # given: synopsis
192  
193 $repo->test;
194  
195 =back
196  
197 =over 4
198  
199 =item test example #2
200  
201 # given: synopsis
202  
203 $repo->store->send($repo->term, { test => time });
204  
205 $repo->test;
206  
207 =back
208  
209 =cut
210  
211 =head1 AUTHOR
212  
213 Al Newkirk, C<awncorp@cpan.org>
214  
215 =head1 LICENSE
216  
217 Copyright (C) 2011-2019, Al Newkirk, et al.
218  
219 This is free software; you can redistribute it and/or modify it under the terms
220 of the The Apache License, Version 2.0, as elucidated in the L<"license
221 file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>.
222  
223 =head1 PROJECT
224  
225 L<Wiki|https://github.com/iamalnewkirk/zing/wiki>
226  
227 L<Project|https://github.com/iamalnewkirk/zing>
228  
229 L<Initiatives|https://github.com/iamalnewkirk/zing/projects>
230  
231 L<Milestones|https://github.com/iamalnewkirk/zing/milestones>
232  
233 L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md>
234  
235 L<Issues|https://github.com/iamalnewkirk/zing/issues>
236  
237 =cut
« Zing/Flow.pm ↑ Summary Zing/Queue.pm »