| 1 | package Data::Shared::Storage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 39 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 39 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 39 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 39 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 39 | ▶ | use Data::Shared::Manifest (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 39 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 39 | our @CARP_NOT = qw(Data::Shared Data::Shared::Manifest Data::Shared::Storage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | Data::Shared::Composite); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 39 | my %LOADED; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 24493 | ▶ | sub plan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plan: called CC=52 SCAR=39.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 24493 | my ($root, $resolved, $name, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 24493 | my $class = $resolved->{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 24493 | my @args = @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 24493 | my $plan = { resolved => $resolved, name => $name, args => \@args, paths => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 24493 | my @explicit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 24493 | $plan->{kind} = $resolved->{convention}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 24493 | ▶ | if ($plan->{kind} eq 'handle') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 20 | ▶ | if (@args == 1 && defined $args[0] && !ref $args[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
@args == 1 and defined $args[0] and not ref $args[0]
@args == 1 and defined $args[0]
MC/DC66%2/3
@args == 1 and defined $args[0] and not ref $args[0]
@args == 1
defined $args[0]
not ref $args[0]
Truth table75%3/4
A and B and not(C)
A= @args == 1B= defined $args[0]C= not ref $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | $plan->{file} = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | push @explicit, $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ▶ | } elsif (@args == 1 && ref $args[0] eq 'HASH') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
@args == 1 and ref $args[0] eq "HASH"
MC/DC50%1/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1
ref $args[0] eq "HASH"
Truth table66%2/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 17 | my $opt = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 17 | $plan->{file} = $opt->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 17 | ▶ | push @explicit, $opt->{path} if defined $opt->{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 17 | ▶ | $plan->{file} = $root->_file_for($name) if !defined $plan->{file} && defined $root->{dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $plan->{"file"} and defined $root->{"dir"}
MC/DC50%1/2
not defined $plan->{"file"} and defined $root->{"dir"}
not defined $plan->{"file"}
defined $root->{"dir"}
Truth table66%2/3
not(A) and B
A= not defined $plan->{"file"}B= defined $root->{"dir"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 17 | ▶ | $plan->{build} = exists $opt->{build_int} ? 'build_int' : exists $opt->{build_str} ? 'build_str' : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 17 | ▶ | $plan->{keys} = $opt->{ $plan->{build} } if $plan->{build}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | Carp::croak('Data::Shared: perfecthash build keys must be an ARRAY reference') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 17 | ▶ | if $plan->{build} && ref $plan->{keys} ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$plan->{"build"} and ref $plan->{"keys"} ne "ARRAY"
MC/DC0%0/2
$plan->{"build"} and ref $plan->{"keys"} ne "ARRAY"
$plan->{"build"}
ref $plan->{"keys"} ne "ARRAY"
Truth table66%2/3
A and B
A= $plan->{"build"}B= ref $plan->{"keys"} ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | Carp::croak('Data::Shared: a perfecthash spec takes a built file path or a' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | . ' {build_int|build_str, path} hashref; pass a factory or a loaded' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | . ' handle as the spec itself instead'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 19 | ▶ | Carp::croak('Data::Shared: perfecthash mount requires a path') unless defined $plan->{file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } elsif ($plan->{kind} eq 'options') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 42 | ▶ | Carp::croak("Data::Shared: sortedset:strings takes options, not a path" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
@args and !defined($args[0]) || !ref($args[0]) && $args[0] eq ":file"
not defined $args[0] or not ref $args[0] and $args[0] eq ":file"
not ref $args[0] and $args[0] eq ":file"
MC/DC75%3/4
@args and !defined($args[0]) || !ref($args[0]) && $args[0] eq ":file"
@args
not defined $args[0]
not ref $args[0]
$args[0] eq ":file"
Truth table80%4/5
A and not(B) or not(C) and D
A= @argsB= not defined $args[0]C= not ref $args[0]D= $args[0] eq ":file"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | . " placeholder: pass max => N (and optionally set/keys)") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | if @args && (!defined $args[0] || (!ref $args[0] && $args[0] eq ':file')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 40 | ▶ | Carp::croak('Data::Shared: sortedset:strings options must be a hashref or key/value pairs') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not @args == 1 && ref $args[0] eq "HASH" and @args % 2
@args == 1 && ref $args[0] eq 'HASH'
MC/DC66%2/3
not @args == 1 && ref $args[0] eq "HASH" and @args % 2
@args == 1
ref $args[0] eq 'HASH'
@args % 2
Truth table60%3/5
not(A && B) and C
A= @args == 1B= ref $args[0] eq 'HASH'C= @args % 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | if !(@args == 1 && ref $args[0] eq 'HASH') && @args % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 39 | ▶ | my %opt = @args == 1 && ref $args[0] eq 'HASH' ? %{ $args[0] } : @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@args == 1 and ref $args[0] eq "HASH"
MC/DC50%1/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1
ref $args[0] eq "HASH"
Truth table66%2/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 39 | ▶ | Carp::croak("Data::Shared: sortedset:strings mount requires 'max'") unless defined $opt{max}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 36 | push @explicit, grep { defined $_ } @opt{qw(set keys)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 36 | ▶ | if (defined $root->{dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 25 | ▶ | $opt{set} = $root->_file_for($name) unless defined $opt{set}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 25 | ▶ | $opt{keys} = $root->_file_for($name . '__keys') unless defined $opt{keys}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 36 | $plan->{options} = \%opt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 36 | $plan->{file} = $opt{set}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 36 | $plan->{paths} = [grep { defined $_ } @opt{qw(set keys)}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 24431 | ▶ | if (defined $root->{dir} && (!@args || !defined $args[0] || (!ref $args[0] && $args[0] eq ':file'))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition75%9/12
defined $root->{"dir"} and !(@args && defined $args[0]) || !ref($args[0]) && $args[0] eq ":file"
not @args && defined $args[0] or not ref $args[0] and $args[0] eq ":file"
@args && defined $args[0]
not ref $args[0] and $args[0] eq ":file"
MC/DC40%2/5
defined $root->{"dir"} and !(@args && defined $args[0]) || !ref($args[0]) && $args[0] eq ":file"
defined $root->{"dir"}
@args
defined $args[0]
not ref $args[0]
$args[0] eq ":file"
Truth table66%4/6
A and not(B && C) or not(D) and E
A= defined $root->{"dir"}B= @argsC= defined $args[0]D= not ref $args[0]E= $args[0] eq ":file"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 3557 | ▶ | shift @args if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3557 | unshift @args, $root->_file_for($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ▶ | elsif (@args && defined $args[0] && !ref $args[0]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
@args and defined $args[0] and not ref $args[0]
@args and defined $args[0]
MC/DC100%3/3
@args and defined $args[0] and not ref $args[0]
@args
defined $args[0]
not ref $args[0]
Truth table100%4/4
A and B and not(C)
A= @argsB= defined $args[0]C= not ref $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 26 | push @explicit, $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # Slot 0 is the backing file; a reference there is refused below. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 24431 | ▶ | $plan->{file} = $args[0] if @args && defined $args[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@args and defined $args[0]
MC/DC100%2/2
@args and defined $args[0]
@args
defined $args[0]
Truth table100%3/3
A and B
A= @argsB= defined $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # construct uses load() or new() for these kinds and would ignore a named ctor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | Carp::croak("Data::Shared: a $class spec does not take a ctor;" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | . ' it is constructed by ' . ($plan->{kind} eq 'handle' ? 'load' : 'new')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 24486 | ▶ | if $resolved->{ctor_named} && $plan->{kind} ne 'leading'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$resolved->{"ctor_named"} and $plan->{"kind"} ne "leading"
MC/DC100%2/2
$resolved->{"ctor_named"} and $plan->{"kind"} ne "leading"
$resolved->{"ctor_named"}
$plan->{"kind"} ne "leading"
Truth table100%3/3
A and B
A= $resolved->{"ctor_named"}B= $plan->{"kind"} ne "leading"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 24484 | ▶ | $plan->{paths} = [$plan->{file}] if $plan->{kind} ne 'options' && defined $plan->{file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$plan->{"kind"} ne "options" and defined $plan->{"file"}
MC/DC100%2/2
$plan->{"kind"} ne "options" and defined $plan->{"file"}
$plan->{"kind"} ne "options"
defined $plan->{"file"}
Truth table100%3/3
A and B
A= $plan->{"kind"} ne "options"B= defined $plan->{"file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # SortedSet::Strings may mix one explicit backing path with one derived path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 24484 | my %explicit = map { $_ => 1 } grep { !ref $_ } @explicit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 24484 | for my $path (@{ $plan->{paths} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 3651 | ▶ | Carp::croak("Data::Shared: invalid backing path for '$name'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
ref $path or not length $path or index($path, "\0") != -1
ref $path or not length $path
MC/DC33%1/3
ref $path or not length $path or index($path, "\0") != -1
ref $path
not length $path
index($path, "\0") != -1
Truth table50%2/4
A or not(B) or C
A= ref $pathB= not length $pathC= index($path, "\0") != -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | if ref $path || !length($path) || index($path, "\0") >= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # Explicit paths must be absolute; derived paths follow the root's directory spelling. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | Carp::croak("Data::Shared: backing path for '$name' must be absolute," | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | . " since every process that opens this store resolves it again" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | . " (got '$path')") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3648 | ▶ | if $explicit{$path} && $path !~ m{\A/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$explicit{$path} and not $path =~ m[\A/]
MC/DC100%2/2
$explicit{$path} and not $path =~ m[\A/]
$explicit{$path}
not $path =~ m[\A/]
Truth table100%3/3
A and not(B)
A= $explicit{$path}B= not $path =~ m[\A/]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 24478 | return $plan; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1735 | ▶ | sub require_files { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_files: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1735 | my ($plan) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1735 | ▶ | Carp::croak("Data::Shared: mount '$plan->{name}' has no backing file to reopen") unless @{ $plan->{paths} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1735 | for my $path (@{ $plan->{paths} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1736 | ▶ | Carp::croak("Data::Shared: missing backing file '$path' for '$plan->{name}'; refusing to recreate storage") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | unless -f $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1729 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 29236 | ▶ | sub _load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 29236 | my ($resolved) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 29236 | ▶ | my $load = $resolved->{load} || $resolved->{class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$resolved->{'load'} || $resolved->{'class'}
MC/DC0%0/2
$resolved->{'load'} || $resolved->{'class'}
$resolved->{'load'}
$resolved->{'class'}
Truth table33%1/3
A || B
A= $resolved->{'load'}B= $resolved->{'class'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 29236 | ▶ | my $minimum = $resolved->{entry} && $resolved->{entry}{min_version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$resolved->{'entry'} && $resolved->{'entry'}{'min_version'}
MC/DC50%1/2
$resolved->{'entry'} && $resolved->{'entry'}{'min_version'}
$resolved->{'entry'}
$resolved->{'entry'}{'min_version'}
Truth table66%2/3
A && B
A= $resolved->{'entry'}B= $resolved->{'entry'}{'min_version'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 29236 | ▶ | my $key = $load . "\0" . ($minimum // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$minimum // ""
MC/DC100%1/1
$minimum // ""
$minimum
Truth table100%2/2
A
A= $minimum
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 29236 | ▶ | return if $LOADED{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Variant module names do not determine the distribution that provides them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 284 | ▶ | Data::Shared::_require_class($load, $resolved->{entry} && $resolved->{entry}{dist}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$resolved->{'entry'} && $resolved->{'entry'}{'dist'}
MC/DC50%1/2
$resolved->{'entry'} && $resolved->{'entry'}{'dist'}
$resolved->{'entry'}
$resolved->{'entry'}{'dist'}
Truth table66%2/3
A && B
A= $resolved->{'entry'}B= $resolved->{'entry'}{'dist'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # Too old reads as absent: the remedy is the same install, and callers that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # tolerate a missing backend must tolerate this too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 279 | ▶ | if ($minimum && !eval { $load->VERSION($minimum); 1 }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$minimum and not eval {
do {
$load->VERSION($minimum);
1
}
}
MC/DC100%2/2
$minimum and not eval {
do {
$load->VERSION($minimum);
1
}
}
$minimum
not eval {
do {
$load->VERSION($minimum);
1
}
}
Truth table100%3/3
A and not(B)
A= $minimumB= not eval {
do {
$load->VERSION($minimum);
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | (my $e = $@) =~ s/ at \S+ line \d+\.?\s*\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | Carp::croak("Data::Shared: backend $load is not available; install the" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | . " $resolved->{entry}{dist} dist $minimum or newer: $e"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 278 | $LOADED{$key} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 264 | ▶ | sub readonly_capable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readonly_capable: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 264 | my ($resolved) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 264 | _load($resolved); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 264 | ▶ | return 1 if $resolved->{entry} && $resolved->{entry}{immutable}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$resolved->{"entry"} and $resolved->{"entry"}{"immutable"}
MC/DC50%1/2
$resolved->{"entry"} and $resolved->{"entry"}{"immutable"}
$resolved->{"entry"}
$resolved->{"entry"}{"immutable"}
Truth table66%2/3
A and B
A= $resolved->{"entry"}B= $resolved->{"entry"}{"immutable"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 262 | ▶ | return $resolved->{class}->can('new_readonly') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 47 | ▶ | sub check_readonly { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_readonly: called CC=4 SCAR=14.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 47 | my ($resolved, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 47 | ▶ | return if readonly_capable($resolved); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | Carp::croak("Data::Shared: strict read-only access is not supported by $resolved->{class}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and length $name
MC/DC0%0/2
defined $name and length $name
defined $name
length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | . (defined $name && length $name ? " at mount '$name'" : '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 19407 | ▶ | sub construct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
construct: called CC=24 SCAR=31.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 19407 | my ($root, $plan) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 19407 | my $resolved = $plan->{resolved}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 19407 | my $class = $resolved->{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 19407 | ▶ | my $ctor = $resolved->{ctor} || 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$resolved->{'ctor'} || 'new'
MC/DC0%0/1
$resolved->{'ctor'} || 'new'
$resolved->{'ctor'}
Truth table50%1/2
A
A= $resolved->{'ctor'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 19407 | ▶ | my $opening = $root->{_opening} || $root->{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$root->{'_opening'} || $root->{'readonly'}
MC/DC50%1/2
$root->{'_opening'} || $root->{'readonly'}
$root->{'_opening'}
$root->{'readonly'}
Truth table66%2/3
A || B
A= $root->{'_opening'}B= $root->{'readonly'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 19407 | ▶ | require_files($plan) if $opening; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 19406 | ▶ | check_readonly($resolved, $plan->{name}) if $root->{strict_readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 19406 | _load($resolved); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 19402 | my $handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 19402 | ▶ | if ($plan->{kind} eq 'handle') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 15 | ▶ | if (!-e $plan->{file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | Carp::croak("Data::Shared: perfecthash file '$plan->{file}' does not exist;" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | . " build it first or mount a loaded handle") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 9 | ▶ | unless $plan->{build} && !$opening; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$plan->{"build"} and not $opening
MC/DC50%1/2
$plan->{"build"} and not $opening
$plan->{"build"}
not $opening
Truth table66%2/3
A and not(B)
A= $plan->{"build"}B= not $opening
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 8 | my $build = $plan->{build}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 8 | my ($keys) = Data::Shared::Manifest::snapshot($plan->{keys}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 8 | $class->$build($plan->{file}, $keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 14 | $handle = $class->load($plan->{file}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } elsif ($plan->{kind} eq 'options') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 21 | my ($options) = Data::Shared::Manifest::snapshot($plan->{options}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 21 | $handle = $class->new(%$options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ▶ | } elsif ($root->{readonly} && $class->can('new_readonly')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$root->{"readonly"} and $class->can("new_readonly")
MC/DC100%2/2
$root->{"readonly"} and $class->can("new_readonly")
$root->{"readonly"}
$class->can("new_readonly")
Truth table100%3/3
A and B
A= $root->{"readonly"}B= $class->can("new_readonly")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 453 | $handle = $class->new_readonly($plan->{file}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 18913 | my ($args) = Data::Shared::Manifest::snapshot($plan->{args}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # Frozen files refuse writable constructors, including during a subtree walk. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 18913 | ▶ | if (($root->{_cleanup} || $root->{_frozen_ok}) && $class->can('new_readonly')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
$root->{"_cleanup"} || $root->{"_frozen_ok"} and $class->can("new_readonly")
$root->{"_cleanup"} or $root->{"_frozen_ok"}
MC/DC66%2/3
$root->{"_cleanup"} || $root->{"_frozen_ok"} and $class->can("new_readonly")
$root->{"_cleanup"}
$root->{"_frozen_ok"}
$class->can("new_readonly")
Truth table60%3/5
A or B and C
A= $root->{"_cleanup"}B= $root->{"_frozen_ok"}C= $class->can("new_readonly")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 343 | $handle = eval { $class->$ctor(@$args) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 343 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 343 | ▶ | if (!$handle) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 17 | $handle = eval { $class->new_readonly($plan->{file}) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 17 | ▶ | die $error unless $handle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ▶ | } elsif (!defined $root->{dir} && @$args && !defined $args->[0] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition88%8/9
not defined $root->{"dir"} and @$args and not defined $args->[0] and $class->can("new_anon")
not defined $root->{"dir"} and @$args and not defined $args->[0]
not defined $root->{"dir"} and @$args
MC/DC75%3/4
not defined $root->{"dir"} and @$args and not defined $args->[0] and $class->can("new_anon")
not defined $root->{"dir"}
@$args
not defined $args->[0]
$class->can("new_anon")
Truth table80%4/5
not(A) and B and not(C) and D
A= not defined $root->{"dir"}B= @$argsC= not defined $args->[0]D= $class->can("new_anon")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | && $class->can('new_anon')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # Buffer's new(undef, ...) fails with EFAULT; new_anon only after the ordinary ctor fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2057 | $handle = eval { $class->$ctor(@$args) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2057 | ▶ | if (!$handle) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 2057 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2057 | $handle = eval { $class->new_anon(@{$args}[1 .. $#$args]) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2057 | ▶ | die $error unless $handle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 16513 | $handle = $class->$ctor(@$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 19397 | ▶ | Carp::croak("Data::Shared: constructor for '$plan->{name}' did not return a handle") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | unless Scalar::Util::blessed($handle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 19397 | return ($handle, $plan->{file}, $plan->{paths}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 39 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||