| 1 | package File::DataClass::Functions; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Exporter 5.57 qw( import ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use File::DataClass::Constants qw( CYGWIN EXCEPTION_CLASS MSOFT STORAGE_BASE | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | STORAGE_EXCEPTIONS ); | |||||||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use Hash::Merge qw( merge ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use List::Util qw( first ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use Module::Pluggable::Object; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use Module::Runtime qw( require_module ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 17 | 7 | ▶ | use Unexpected::Functions qw( is_class_loaded Unspecified ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||
| 19 | 7 | our @EXPORT_OK = qw( ensure_class_loaded extension_map first_char | |||||||||||||||||||||||||||||||||||||||
| 20 | is_arrayref is_coderef is_hashref is_member is_mswin | ||||||||||||||||||||||||||||||||||||||||
| 21 | is_ntfs is_stale qualify_storage_class | ||||||||||||||||||||||||||||||||||||||||
| 22 | map_extension2class merge_attributes merge_file_data | ||||||||||||||||||||||||||||||||||||||||
| 23 | merge_for_update supported_extensions thread_id throw ); | ||||||||||||||||||||||||||||||||||||||||
| 24 | 7 | our %EXPORT_TAGS = ( all => [ @EXPORT_OK ], ); | |||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||
| 26 | 7 | my $LC_OSNAME = lc $OSNAME; | |||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||
| 28 | # Private functions | ||||||||||||||||||||||||||||||||||||||||
| 29 | 7 | my $_merge_attr; | |||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | my $_merge_attr_arrays = sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | my ($to, $from) = @_; my $updated = 0; | |||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | for (0 .. $#{ $to }) { | |||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | if (defined $from->[ $_ ]) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my $res = $_merge_attr->( \$to->[ $_ ], $from->[ $_ ] ); | |||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | ▶ | $updated ||= $res; | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$updated ||= $res
MC/DC0%0/2
$updated ||= $res
$updated
$res
Truth table33%1/3
A ||= B
A= $updatedB= $res
| |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | elsif ($to->[ $_ ]) { splice @{ $to }, $_; $updated = 1; last } | |||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | if (@{ $from } > @{ $to }) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | push @{ $to }, (splice @{ $from }, $#{ $to } + 1); $updated = 1; | |||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | return $updated; | |||||||||||||||||||||||||||||||||||||||
| 48 | 7 | }; | |||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | my $_merge_attr_hashes = sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | my ($to, $from) = @_; my $updated = 0; | |||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | for (grep { exists $from->{ $_ } } keys %{ $to }) { | |||||||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | if (defined $from->{ $_ }) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my $res = $_merge_attr->( \$to->{ $_ }, $from->{ $_ } ); | |||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | $updated ||= $res; | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$updated ||= $res
MC/DC0%0/2
$updated ||= $res
$updated
$res
Truth table33%1/3
A ||= B
A= $updatedB= $res
| |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | else { delete $to->{ $_ }; delete $from->{ $_ }; $updated = 1 } | |||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | for (grep { not exists $to->{ $_ } } keys %{ $from }) { | |||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if (defined $from->{ $_ }) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $to->{ $_ } = $from->{ $_ }; $updated = 1; | |||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | return $updated; | |||||||||||||||||||||||||||||||||||||||
| 69 | 7 | }; | |||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||
| 71 | 25 | ▶ | $_merge_attr = sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=26.9
| |||||||||||||||||||||||||||||||||||||||||
| 72 | 25 | my ($to_ref, $from) = @_; my $to = ${ $to_ref }; my $updated = 0; | |||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||
| 74 | 25 | ▶ | if ($to and ref $to eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
$to and ref $to eq "HASH"
MC/DC100%2/2
$to and ref $to eq "HASH"
$to
ref $to eq "HASH"
Truth table100%3/3
A and B
A= $toB= ref $to eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | $updated = $_merge_attr_hashes->( $to, $from ); | |||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||
| 77 | ▶ | elsif ($to and ref $to eq 'ARRAY') { | |||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$to and ref $to eq "ARRAY"
MC/DC100%2/2
$to and ref $to eq "ARRAY"
$to
ref $to eq "ARRAY"
Truth table100%3/3
A and B
A= $toB= ref $to eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | $updated = $_merge_attr_arrays->( $to, $from ); | |||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||
| 80 | ▶ | elsif (defined $to and $to ne $from) { | |||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $to and $to ne $from
MC/DC100%2/2
defined $to and $to ne $from
defined $to
$to ne $from
Truth table100%3/3
A and B
A= defined $toB= $to ne $from
| |||||||||||||||||||||||||||||||||||||||||
| 81 | 7 | $updated = 1; ${ $to_ref } = $from; | |||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||
| 83 | elsif (not defined $to) { | ||||||||||||||||||||||||||||||||||||||||
| 84 | 7 | ▶ | if (ref $from eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | scalar keys %{ $from } > 0 and $updated = 1 | |||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | and ${ $to_ref } = $from; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
scalar keys %{$from;} > 0 and $updated = 1
MC/DC100%1/1
scalar keys %{$from;} > 0 and $updated = 1
scalar keys %{$from;} > 0
Truth table100%2/2
A
A= scalar keys %{$from;} > 0
| |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||
| 88 | elsif (ref $from eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | scalar @{ $from } > 0 and $updated = 1 and ${ $to_ref } = $from; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
scalar @{$from;} > 0 and $updated = 1
MC/DC0%0/1
scalar @{$from;} > 0 and $updated = 1
scalar @{$from;} > 0
Truth table0%0/2
A
A= scalar @{$from;} > 0
| |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | else { $updated = 1; ${ $to_ref } = $from } | |||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||
| 94 | 25 | return $updated; | |||||||||||||||||||||||||||||||||||||||
| 95 | 7 | }; | |||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||
| 97 | # Public functions | ||||||||||||||||||||||||||||||||||||||||
| 98 | 42 | ▶ | sub ensure_class_loaded ($;$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_class_loaded: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 99 | 42 | ▶ | my ($class, $opts) = @_; $opts //= {}; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts //= {}
MC/DC100%1/1
$opts //= {}
$opts
Truth table100%2/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||
| 101 | 42 | ▶ | not $opts->{ignore_loaded} and is_class_loaded( $class ) and return 1; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $opts->{"ignore_loaded"} and &is_class_loaded($class)
MC/DC100%2/2
not $opts->{"ignore_loaded"} and &is_class_loaded($class)
not $opts->{"ignore_loaded"}
&is_class_loaded($class)
Truth table100%3/3
not(A) and B
A= not $opts->{"ignore_loaded"}B= &is_class_loaded($class)
| |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||
| 103 | 9 | ▶ | try { require_module( $class ) } catch { throw( $_ ) }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||
| 105 | 8 | ▶ | is_class_loaded( $class ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 106 | or throw( 'Class [_1] loaded but package undefined', [ $class ] ); | ||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | return 1; | |||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||
| 111 | 7 | { my $_extension_map = { '_map_loaded' => 0 }; | |||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||
| 113 | 17 | ▶ | sub extension_map (;$$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
extension_map: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 114 | 17 | my ($class, $extensions) = @_; | |||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||
| 116 | 17 | ▶ | if (defined $class) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 117 | 5 | ▶ | if (defined $extensions) { # uncoverable branch false | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 118 | 5 | ▶ | is_arrayref( $extensions ) or $extensions = [ $extensions ]; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | for my $extn (@{ $extensions }) { | |||||||||||||||||||||||||||||||||||||||
| 121 | 6 | ▶ | $_extension_map->{ $extn } //= []; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_extension_map->{$extn} //= []
MC/DC100%1/1
$_extension_map->{$extn} //= []
$_extension_map->{$extn}
Truth table100%2/2
A
A= $_extension_map->{$extn}
| |||||||||||||||||||||||||||||||||||||||||
| 122 | is_member( $class, $_extension_map->{ $extn } ) | ||||||||||||||||||||||||||||||||||||||||
| 123 | 6 | ▶ | or push @{ $_extension_map->{ $extn } }, $class; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | return; | |||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||
| 130 | 12 | ▶ | $_extension_map->{ '_map_loaded' } and return $_extension_map; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||
| 132 | 3 | my $base = STORAGE_BASE; | |||||||||||||||||||||||||||||||||||||||
| 133 | 3 | my $exceptions = STORAGE_EXCEPTIONS; | |||||||||||||||||||||||||||||||||||||||
| 134 | 3 | my $finder = Module::Pluggable::Object->new | |||||||||||||||||||||||||||||||||||||||
| 135 | ( except => [ $exceptions ], search_path => [ $base ], require => 1, ); | ||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | $finder->plugins; $_extension_map->{ '_map_loaded' } = 1; | |||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | return $_extension_map; | |||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | ▶ | sub first_char ($) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
first_char: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 144 | 1493 | return substr $_[ 0 ], 0, 1; | |||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||
| 147 | 737 | ▶ | sub is_arrayref (;$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_arrayref: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 148 | 737 | ▶ | return $_[ 0 ] && ref $_[ 0 ] eq 'ARRAY' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and ref $_[0] eq "ARRAY"
MC/DC100%2/2
$_[0] and ref $_[0] eq "ARRAY"
$_[0]
ref $_[0] eq "ARRAY"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||
| 151 | 647 | ▶ | sub is_coderef (;$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_coderef: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 152 | 647 | ▶ | return $_[ 0 ] && ref $_[ 0 ] eq 'CODE' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and ref $_[0] eq "CODE"
MC/DC100%2/2
$_[0] and ref $_[0] eq "CODE"
$_[0]
ref $_[0] eq "CODE"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||
| 155 | 1025 | ▶ | sub is_hashref (;$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_hashref: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 156 | 1025 | ▶ | return $_[ 0 ] && ref $_[ 0 ] eq 'HASH' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and ref $_[0] eq "HASH"
MC/DC100%2/2
$_[0] and ref $_[0] eq "HASH"
$_[0]
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||
| 159 | 34 | ▶ | sub is_member (;@) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_member: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 160 | 34 | ▶ | my ($candidate, @args) = @_; $candidate or return; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||
| 162 | 33 | ▶ | is_arrayref $args[ 0 ] and @args = @{ $args[ 0 ] }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||
| 164 | 33 | ▶ | return (first { $_ eq $candidate } @args) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||
| 167 | 545 | ▶ | sub is_mswin () { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_mswin: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 168 | 545 | ▶ | return $LC_OSNAME eq MSOFT ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||
| 171 | 506 | ▶ | sub is_ntfs () { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ntfs: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 172 | 506 | ▶ | return is_mswin || $LC_OSNAME eq CYGWIN ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&is_mswin() or $LC_OSNAME eq "cygwin"
MC/DC0%0/2
&is_mswin() or $LC_OSNAME eq "cygwin"
&is_mswin()
$LC_OSNAME eq "cygwin"
Truth table33%1/3
A or B
A= &is_mswin()B= $LC_OSNAME eq "cygwin"
| |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||
| 175 | 86 | ▶ | sub is_stale (;$$$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_stale: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 176 | 86 | my ($data, $cache_mtime, $path_mtime) = @_; | |||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||
| 178 | # Assume NTFS does not support mtime | ||||||||||||||||||||||||||||||||||||||||
| 179 | 86 | ▶ | is_ntfs() and return 1; # uncoverable branch true | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||
| 181 | 86 | ▶ | my $is_def = defined $data && defined $path_mtime && defined $cache_mtime; | ||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
defined $data && defined $path_mtime && defined $cache_mtime
defined $data and defined $path_mtime
MC/DC66%2/3
defined $data && defined $path_mtime && defined $cache_mtime
defined $data
defined $path_mtime
defined $cache_mtime
Truth table75%3/4
A and B && C
A= defined $dataB= defined $path_mtimeC= defined $cache_mtime
| |||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||
| 183 | 86 | ▶ | return (!$is_def || ($path_mtime > $cache_mtime)) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $is_def or $path_mtime > $cache_mtime
MC/DC100%2/2
not $is_def or $path_mtime > $cache_mtime
not $is_def
$path_mtime > $cache_mtime
Truth table100%3/3
not(A) or B
A= not $is_defB= $path_mtime > $cache_mtime
| |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | ▶ | sub map_extension2class ($) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_extension2class: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | my $map = extension_map(); | |||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||
| 189 | 8 | ▶ | return exists $map->{ $_[ 0 ] } ? $map->{ $_[ 0 ] } : undef; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | ▶ | sub merge_attributes ($$;$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_attributes: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | my ($dest, $src, $attrs) = @_; my $class = blessed $src; | |||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | ▶ | for (grep { not exists $dest->{ $_ } or not defined $dest->{ $_ } } | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
exists $dest->{$_} && defined $dest->{$_}
MC/DC50%1/2
exists $dest->{$_} && defined $dest->{$_}
exists $dest->{$_}
defined $dest->{$_}
Truth table66%2/3
A && B
A= exists $dest->{$_}B= defined $dest->{$_}
| |||||||||||||||||||||||||||||||||||||||||
| 196 | 7 | ▶ | @{ $attrs || [] }) { | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$attrs || []
MC/DC100%1/1
$attrs || []
$attrs
Truth table100%2/2
A
A= $attrs
| |||||||||||||||||||||||||||||||||||||||||
| 197 | 13 | ▶ | my $v = $class ? ($src->can( $_ ) ? $src->$_() : undef) : $src->{ $_ }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||
| 199 | 13 | ▶ | defined $v and $dest->{ $_ } = $v; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||
| 202 | 7 | return $dest; | |||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | ▶ | sub merge_file_data ($$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_file_data: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 206 | 5 | my ($existing, $new) = @_; | |||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||
| 208 | 5 | for (keys %{ $new }) { | |||||||||||||||||||||||||||||||||||||||
| 209 | $existing->{ $_ } = exists $existing->{ $_ } | ||||||||||||||||||||||||||||||||||||||||
| 210 | ? merge( $existing->{ $_ }, $new->{ $_ } ) | ||||||||||||||||||||||||||||||||||||||||
| 211 | 11 | ▶ | : $new->{ $_ }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | return; | |||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||
| 217 | 21 | ▶ | sub merge_for_update (;$$$) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_for_update: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 218 | 21 | my ($dest_ref, $src, $filter) = @_; my $updated = 0; | |||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||
| 220 | 21 | ▶ | $dest_ref or throw( Unspecified, [ 'destination reference' ] ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||
| 222 | 20 | ▶ | ${ $dest_ref } //= {}; $src //= {}; $filter //= sub { keys %{ $_[ 0 ] } }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition85%6/7
${$dest_ref;} //= {}
$src //= {}
$filter //= sub {
keys %{$_[0];};
}
MC/DC100%1/1
${$dest_ref;} //= {}
${$dest_ref;}
MC/DC100%1/1
$src //= {}
$src
MC/DC0%0/2
$filter //= sub {
keys %{$_[0];};
}
$filter
sub {
keys %{$_[0];};
}
Truth table100%2/2
A
A= ${$dest_ref;}
Truth table100%2/2
A
A= $src
Truth table66%2/3
A //= B
A= $filterB= sub {
keys %{$_[0];};
}
| |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||
| 224 | 20 | for my $k ($filter->( $src )) { | |||||||||||||||||||||||||||||||||||||||
| 225 | 24 | ▶ | if (defined $src->{ $k }) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 226 | 22 | my $res = $_merge_attr->( \${ $dest_ref }->{ $k }, $src->{ $k } ); | |||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||
| 228 | 22 | ▶ | $updated ||= $res; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$updated ||= $res
MC/DC100%2/2
$updated ||= $res
$updated
$res
Truth table100%3/3
A ||= B
A= $updatedB= $res
| |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | elsif (exists ${ $dest_ref }->{ $k }) { | |||||||||||||||||||||||||||||||||||||||
| 231 | 1 | delete ${ $dest_ref }->{ $k }; $updated = 1; | |||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||
| 235 | 20 | return $updated; | |||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||
| 238 | 21 | ▶ | sub qualify_storage_class ($) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
qualify_storage_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 239 | 21 | return STORAGE_BASE.'::'.$_[ 0 ]; | |||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | sub supported_extensions () { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
supported_extensions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | return grep { not m{ \A _ }mx } keys %{ extension_map() }; | |||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||
| 246 | 111 | ▶ | sub thread_id () { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
thread_id: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 247 | # uncoverable branch true | ||||||||||||||||||||||||||||||||||||||||
| 248 | 111 | ▶ | return exists $INC{ 'threads.pm' } ? threads->tid() : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||
| 251 | 48 | ▶ | sub throw (;@) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 252 | 48 | EXCEPTION_CLASS->throw( @_ ); | |||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||
| 255 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||
| 257 | __END__ | ||||||||||||||||||||||||||||||||||||||||