FStore/Base.pm

filter: Statementstmt 89.7% 35 / 39 Branchbran 50.0% 3 / 6 Conditioncond 21.4% 3 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 84.6% 11 / 13 Podpod 100% 7 / 7 totaltotal 67.0% 59 / 88 CC 9 SCAR 10.7
CC
9
Cov
69%
db
6.0
extractor
6.0
contentise
4.3
CRAP 2.9
« FStore/Adder.pm ↑ Summary
1 # Copyright (c) 2025-2026 Philipp Schafft
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: Module for interacting with file stores
6  
7  
8 package File::FStore::Base;
9  
10 4 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 ▶use parent qw(Data::Identifier::Interface::Userdata Data::Identifier::Interface::Subobjects);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 4 our $VERSION = v0.08;
19  
20  
21 5 ▶sub contentise {
Subroutine contentise: called CC=4 SCAR=14.6
Pod documented
22 5 my ($self, %opts) = @_;
23 5 ▶ my $as = delete($opts{as}) // 'uuid';
Condition50%1/2
delete $opts{"as"} // "uuid"
l!l
05
MC/DC0%0/1
delete $opts{"as"} // "uuid"
delete $opts{"as"}
Truth table50%1/2
A
A= delete $opts{"as"}
Aresult
11
00
24  
25 5 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 5 5
26 5 ▶ confess 'No contentise known for this file' unless defined $self->{contentise};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"contentise"} 0 5 5
27  
28 5 return $self->{contentise}->as($as,
29 db => $self->so_get('db', default => undef, no_defaults => 1),
30 extractor => $self->so_get('extractor', default => undef, no_defaults => 1),
31 );
32 }
33  
34  
35 1 ▶sub ise {
Subroutine ise: called CC=1 SCAR=0.0
Pod documented
36 1 my ($self, @args) = @_;
37 1 return $self->contentise(@args);
38 }
39  
40  
41 1 ▶sub as {
Subroutine as: called CC=2 SCAR=7.6
Pod documented
42 1 my ($self, $as, %opts) = @_;
43 1 ▶ $opts{store} //= $self->{store};
Condition33%1/3
$opts{"store"} //= $self->{"store"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$opts{"store"} //= $self->{"store"}
$opts{"store"} $self->{"store"}
Truth table33%1/3
A //= B
A= $opts{"store"}B= $self->{"store"}
ABresult
1X1
011
000
44 1 return $self->Data::Identifier::as($as, %opts);
45 }
46  
47  
48 #@returns File::FStore
49 49 ▶sub store {
Subroutine store: called CC=1 SCAR=0.0
Pod documented
50 49 my ($self) = @_;
51 49 return $self->{store};
52 }
53  
54  
55 #@deprecated
56 0 ▶sub db {
Subroutine db: not called CC=2 SCAR=17.9
Pod documented
57 0 my ($self, %opts) = @_;
58 0 ▶ return $self->{db} //= $self->store->db(%opts);
Condition0%0/3
$self->{"db"} //= $self->store->db(%opts)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"db"} //= $self->store->db(%opts)
$self->{"db"} $self->store->db(%opts)
Truth table0%0/3
A //= B
A= $self->{"db"}B= $self->store->db(%opts)
ABresult
1X1
011
000
59 }
60  
61  
62 #@deprecated
63 0 ▶sub extractor {
Subroutine extractor: not called CC=2 SCAR=17.9
Pod documented
64 0 my ($self, %opts) = @_;
65 0 ▶ return $self->{extractor} //= $self->store->extractor(%opts);
Condition0%0/3
$self->{"extractor"} //= $self->store->extractor(%opts)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"extractor"} //= $self->store->extractor(%opts)
$self->{"extractor"} $self->store->extractor(%opts)
Truth table0%0/3
A //= B
A= $self->{"extractor"}B= $self->store->extractor(%opts)
ABresult
1X1
011
000
66 }
67  
68  
69 4 ▶sub fii {
Subroutine fii: called CC=2 SCAR=8.1
Pod documented
70 4 my ($self) = @_;
71 4 ▶ return $self->{fii} //= $self->store->fii;
Condition33%1/3
$self->{"fii"} //= $self->store->fii
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->{"fii"} //= $self->store->fii
$self->{"fii"} $self->store->fii
Truth table33%1/3
A //= B
A= $self->{"fii"}B= $self->store->fii
ABresult
1X1
011
000
72 }
73  
74 # ---- Private helpers ----
75  
76 16 ▶sub _new {
Subroutine _new: called CC=2 SCAR=7.0
77 16 my ($pkg, %opts) = @_;
78 16 my $self = bless \%opts, $pkg;
79  
80 16 ▶ croak 'No store is given' unless defined $self->{store};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"store"} 0 16 16
81  
82 16 $self->so_attach(parent => $self->{store});
83  
84 16 return $self;
85 }
86  
87 4 1;
88  
89 __END__
« FStore/Adder.pm ↑ Summary