lib/File/Information/Base.pm

filter: Statementstmt 27.0% 143 / 529 Branchbran 16.0% 50 / 312 Conditioncond 25.8% 81 / 313 MC/DCmcdc 10.5% 18 / 171 Subroutinesub 34.8% 15 / 43 Podpod 81.8% 18 / 22 totaltotal 23.3% 325 / 1390 CC 305 SCAR 68.8
CC
305
Cov
24%
get
2044.5
link_stream
1482.0
digest
992.0
CRAP 973.8
« lib/File/Information/Link.pm ↑ Summary lib/File/Information/Tagpool.pm »
1 # Copyright (c) 2024-2026 Philipp Schafft <lion@cpan.org>
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: generic module for extracting information from filesystems
6  
7  
8 package File::Information::Base;
9  
10 3 ▶use v5.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 ▶use Data::Identifier v0.08;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶use File::Information;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 3 ▶use parent qw(Data::Identifier::Interface::Known Data::Identifier::Interface::Simple);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 3 ▶use constant { # Taken from Data::Identifier
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 RE_UUID => qr/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/,
24 RE_OID => qr/^[0-2](?:\.(?:0|[1-9][0-9]*))+$/,
25 RE_URI => qr/^[a-zA-Z][a-zA-Z0-9\+\.\-]+/,
26  
27 WK_WM_RANDOM_ACCESS => '4dc9fd07-7ef3-4215-8874-31d78ed55c22',
28 WK_WM_READ_ONLY => '3877b2ef-6c77-423f-b15f-76508fbd48ed',
29 WK_WM_NONE => '7b177183-083c-4387-abd3-8793eb647373',
30 WK_FINAL => 'f418cdb9-64a7-4f15-9a18-63f7755c5b47',
31 WK_ALSO_HAS_ROLE => 'd2750351-aed7-4ade-aa80-c32436cc6030',
32 WK_SPECIFIC_PROTO_FILE_STATE => '63da70a8-78a4-51b0-8b87-86872b474a5d',
33 WK_FINAL_FILE_ENCODING => '448c50a8-c847-4bc7-856e-0db5fea8f23b',
34 WK_FINAL_FILE_SIZE => '1cd4a6c6-0d7c-48d1-81e7-4e8d41fdb45d',
35 WK_FINAL_FILE_HASH => '79385945-0963-44aa-880a-bca4a42e9002',
36 WK_FETCH_FILE_URI => '96674c6c-cf5e-40cd-af1e-63b86e741f4f',
37 WK_PROTO_FILE => '52a516d0-25d8-47c7-a6ba-80983e576c54',
38 WK_TAGPOOL_FILE => '4e4bbe45-f783-442d-8804-ac729f5cdec5',
39 WK_ALSO_HAS_STATE => '4c426c3c-900e-4350-8443-e2149869fbc9',
40 WK_HAS_FINAL_STATE => '54d30193-2000-4d8a-8c28-3fa5af4cad6b',
41 WK_SEE_ALSO => 'a75f9010-9db3-4d78-bd78-0dd528d6b55d',
42 WK_ALSO_SHARES_IDENTIFIER => 'ddd60c5c-2934-404f-8f2d-fcb4da88b633',
43 WK_TAGNAME => 'bfae7574-3dae-425d-89b1-9c087c140c23',
44  
45 WK_NEEDSTAGGING => '92292a4e-b060-417e-a90c-a270331259e9',
46  
47 WK_TAGPOOL_TITLE => '361fda18-50ce-4421-b378-881179b0318a',
48 WK_TAGPOOL_DESCRIPTION => 'ca33b058-b4ce-4059-9f0b-61ca0fd39c35',
49 WK_TAGPOOL_COMMENT => '06706809-207b-4287-9775-6efa07f807dd',
50 WK_TAGPOOL_TAGGED_AS => '703cbb5d-eb4a-4718-9e60-adbef6f71869',
51  
52 WK_FILESYSTEM => '63c1da19-0dd6-4181-b3fa-742b9ceb2903',
53 WK_TAGPOOL_POOL => '1f30649d-eb55-48cb-93d7-6d6fcba23909',
54 3 };
55  
56 3 our $VERSION = v0.17;
57  
58 our %_digest_name_converter = ( # stolen from Data::URIID::Result
59 fc('md5') => 'md-5-128',
60 fc('sha1') => 'sha-1-160',
61 fc('sha-1') => 'sha-1-160',
62 fc('ripemd-160') => 'ripemd-1-160',
63 (map {
64 3 fc('sha'.$_) => 'sha-2-'.$_,
65 fc('sha-'.$_) => 'sha-2-'.$_,
66 fc('sha3-'.$_) => 'sha-3-'.$_,
67 } qw(224 256 384 512)),
68 );
69  
70 3 our %_digest_info_extra = (
71 'md-5-128' => {rfc9530 => 'md5', openpgp => 1},
72 'ripemd-1-160' => { openpgp => 3},
73 'sha-1-160' => {rfc9530 => 'sha', openpgp => 2, sni => 185},
74 'sha-2-224' => { openpgp => 11},
75 'sha-2-256' => {rfc9530 => 'sha-256', openpgp => 8},
76 'sha-2-384' => { openpgp => 9},
77 'sha-2-512' => {rfc9530 => 'sha-512', openpgp => 10},
78 'sha-3-256' => { openpgp => 12},
79 'sha-3-512' => { openpgp => 14, sni => 186},
80 );
81  
82 3 my %_important_digests = map {$_ => 1} qw(sha-1-160 sha-3-512);
83  
84 3 our %_mediatypes = ( # Copied from tags-universal
85 'application/gzip' => 'a8bb3d20-e983-5060-8c63-95b35e9ca56a',
86 'application/http' => '282ff2fd-0e1b-5b34-bda7-9c44b6ef7dc6',
87 'application/json' => 'c9e61b78-a0bd-5939-9aaa-8f0d08e5a4dc',
88 'application/ld+json' => '999e546d-8dfe-5961-aa5f-bf5cbd0a7037',
89 'application/octet-stream' => '4076d9f9-ca42-5976-b41b-e54aa912ccf3',
90 'application/ogg' => 'f4a4beee-e0f4-567a-ada4-a15d387a953c',
91 'application/pdf' => '03e6c035-e046-5b7e-a016-55b51c4836ea',
92 'application/postscript' => '85224b06-7548-5319-b635-4b37dc78880d',
93 'application/vnd.sirtx.vmv0' => 'f718f85b-6b41-53c0-9c66-8796df90c725',
94 'application/vnd.debian.binary-package' => '026b4c07-00ab-581d-a493-73e0b9b1cff9',
95 'application/vnd.oasis.opendocument.base' => '319de973-68e2-5a01-af87-6fe4a5b800c6',
96 'application/vnd.oasis.opendocument.chart' => '271d085d-1a51-5795-86f5-e6849166cbf6',
97 'application/vnd.oasis.opendocument.chart-template' => 'e8d5322b-0d40-5e3d-a754-4dd0ee6a4bb9',
98 'application/vnd.oasis.opendocument.formula' => 'e771c71d-f4b8-56a7-b299-1ede808b91d0',
99 'application/vnd.oasis.opendocument.formula-template' => '4b9eb9eb-786d-5831-89e1-edcba46a2bb6',
100 'application/vnd.oasis.opendocument.graphics' => '322c5088-84c9-59aa-a828-ffe183557457',
101 'application/vnd.oasis.opendocument.graphics-template' => '76d3335e-a49e-54ec-bec5-8e3bb46d8412',
102 'application/vnd.oasis.opendocument.image' => '869257aa-b61f-5210-af8a-d9a33c356629',
103 'application/vnd.oasis.opendocument.image-template' => '60d259d0-4d58-59c8-81f7-9725f960d415',
104 'application/vnd.oasis.opendocument.presentation' => '7a4abd3a-89ec-53e9-b29d-64c6e2dcdaf4',
105 'application/vnd.oasis.opendocument.presentation-template' => 'b16ebfdd-1b4f-5713-829b-5b35e7a06839',
106 'application/vnd.oasis.opendocument.spreadsheet' => '975706e1-44c3-55d1-b03a-978954a46f3e',
107 'application/vnd.oasis.opendocument.spreadsheet-template' => '52f3046b-e8e4-5c74-8860-b683f1554ad2',
108 'application/vnd.oasis.opendocument.text' => 'b03df4f0-3f52-5ce0-b3e0-42dd911d244a',
109 'application/vnd.oasis.opendocument.text-master' => '21415b27-ce2a-5b5d-bb98-569ce922c97c',
110 'application/vnd.oasis.opendocument.text-master-template' => '889508ab-6a78-5337-b13a-756a8232baae',
111 'application/vnd.oasis.opendocument.text-template' => '8f0bfe22-f343-5cbb-98c7-d826d0f31e63',
112 'application/vnd.oasis.opendocument.text-web' => '83baa5da-8956-51ff-8ec1-41aee5d5b1eb',
113 'application/xhtml+xml' => 'e553c22e-542b-50d8-9abb-aa36625be67e',
114 'application/xml' => '371b035f-45b7-5ba2-9d3e-811bf3b937bc',
115 'audio/flac' => 'a7ea86ac-4938-5adc-8544-b4908e21c7e4',
116 'audio/matroska' => 'e5eae178-ccf2-5659-b23a-3d0d936be8a2',
117 'audio/ogg' => 'ef171c40-2b55-572a-b66f-3d4ecb8182a5',
118 'image/gif' => 'b5ec5cdd-2811-5e51-8b0e-b07d0bd2b570',
119 'image/jpeg' => 'c1e9e865-4653-5037-97f3-06c0c1c061a5',
120 'image/png' => '7c859f1d-693b-5070-a928-dfd051a4f93d',
121 'image/svg+xml' => '3970f481-591e-530a-b962-a2e87b2efde2',
122 'image/webp' => 'd71ad7ca-abd5-59e5-a360-086aa1f39ad0',
123 'message/http' => '3f59f23e-d5ca-5f6d-a70e-05aa4d952f36',
124 'text/html' => 'ecd556c0-7ecb-5b88-ab0a-ec4e09d61782',
125 'text/plain' => '552ec0dc-8678-5657-9422-8a71ea8e5cd0',
126 'video/matroska' => '6155907c-d116-5d88-8d60-850753015fca',
127 'video/matroska-3d' => '46ce8e26-b8e3-5cf6-a534-9d1d6dbcae72',
128 'video/ogg' => 'f14a9d8d-daf4-52aa-9ff8-e0815a3e5b65',
129 'video/webm' => '0ee63dad-e52f-5c62-9c32-e6b872b828c7',
130 );
131  
132 3 my %_inverse_mediatypes = map {$_mediatypes{$_} => $_} keys %_mediatypes;
133  
134 3 my %_ise_re = (
135 uuid => RE_UUID,
136 oid => RE_OID,
137 uri => RE_URI,
138 );
139  
140 3 my %_known_digest_algos = map {$_ => undef} (
141 values(%_digest_name_converter),
142 qw(md-4-128 ripemd-1-160 tiger-1-192 tiger-2-192),
143 );
144  
145  
146 3 my %_ise_keys = map {$_ => 1} qw(ise uuid oid uri);
147 3 my %_data_identifier_keys = map {$_ => 1} keys %_ise_keys;
148  
149 3 my %_tagpool_relations = (
150 tagpool_file_title => WK_TAGPOOL_TITLE,
151 tagpool_file_comment => WK_TAGPOOL_COMMENT,
152 tagpool_file_description => WK_TAGPOOL_DESCRIPTION,
153 );
154  
155 3 my @_stable_properties = qw(boring comment contentise description displayname fetchurl finalmode hidden inodeise ise mediatype oid pages readonly system size thumbnail title uri uuid writemode);
156  
157 3 my %_properties = (
158 uuid => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_uuid tagpool_directory_setting_tag uuid(xattr_utag_ise) uuid(store_inodeise) uuid(db_inode_tag) :self dev_disk_by_uuid tagpool_pool_uuid)], rawtype => 'uuid'},
159 oid => {loader => \&_load_aggregate, sources => [qw(::Inode oid(xattr_utag_ise) oid(store_inodeise) oid(db_inode_tag))], rawtype => 'oid'},
160 uri => {loader => \&_load_aggregate, sources => [qw(::Inode uri(xattr_utag_ise) uri(store_inodeise) uri(db_inode_tag))], rawtype => 'uri'},
161 ise => {loader => \&_load_aggregate, sources => [qw(:self uuid oid uri ::Inode xattr_utag_ise ::Base data_uriid_ise store_inodeise)], rawtype => 'ise'},
162 inodeise => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_uuid tagpool_directory_setting_tag xattr_utag_ise store_inodeise db_inode_tag)], rawtype => 'ise'},
163 contentise => {loader => \&_load_aggregate, sources => [qw(::Inode content_sha_1_160_sha_3_512_uuid content_sha_3_512_uuid store_contentise)], rawtype => 'ise'},
164  
165 size => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_size xattr_utag_final_file_size xattr_utag_final_file_hash_size st_size ::Chunk chunk_outer_size ::Base store_size data_tagdb_size)]},
166 title => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_title tagpool_directory_title xattr_dublincore_title dotcomments_caption ::Deep pdf_info_title odf_info_title audio_scan_title)]},
167 comment => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_comment tagpool_directory_comment xattr_xdg_comment dotcomments_note)]},
168 description => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_description tagpool_directory_description xattr_dublincore_description)]},
169 displayname => {loader => \&_load_aggregate, sources => [qw(:self title link_basename_clean dev_disk_by_label dev_mapper_name dev_name data_uriid_attr_displayname)]},
170 mediatype => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_mediatype xattr_utag_final_file_encoding magic_mediatype ::Base data_uriid_attr_media_subtype store_mediasubtype data_tagdb_encoding)], rawtype => 'mediatype'},
171 writemode => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_write_mode xattr_utag_write_mode ::Base store_writemode)], rawtype => 'ise'},
172 pages => {loader => \&_load_aggregate, sources => [qw(::Deep pdf_pages odf_stats_meta_page_count)]},
173  
174 thumbnail => {loader => \&_load_aggregate, sources => [qw(::Link link_thumbnail ::Inode tagpool_file_thumbnail)], rawtype => 'filename'},
175 finalmode => {loader => \&_load_aggregate, sources => [qw(::Inode tagpool_file_finalmode xattr_utag_final_mode ::Base store_finalmode)], rawtype => 'ise'},
176 hidden => {loader => \&_load_aggregate, sources => [qw(::Link link_dotfile ::Inode ntfs_file_attribute_hidden)], rawtype => 'bool', towards => 1},
177 system => {loader => \&_load_aggregate, sources => [qw(::Inode ntfs_file_attribute_system)], rawtype => 'bool', towards => 1},
178 readonly => {loader => \&_load_readonly, rawtype => 'bool'},
179  
180 fetchurl => {loader => \&_load_aggregate, sources => [qw(:self tagpool_file_original_url xattr_xdg_origin_url zonetransfer_hosturl)]},
181  
182 boring => {loader => \&_load_aggregate, sources => [qw(size_boring ::Link link_basename_boring)], rawtype => 'bool', towards => 1},
183  
184 # TODO: displaycolour icontext charset (hash) (mediatype / encoding)
185  
186 size_boring => {loader => \&_load_size_boring, rawtype => 'bool'},
187  
188 data_tagdb_size => {loader => \&_load_data_tagdb},
189 data_tagdb_displayname => {loader => \&_load_data_tagdb},
190 data_tagdb_fetch_uri => {loader => \&_load_data_tagdb, rawtype => 'uri'},
191 data_tagdb_encoding => {loader => \&_load_data_tagdb, rawtype => 'Data::TagDB::Tag'},
192 data_tagdb_charset => {loader => \&_load_data_tagdb, rawtype => 'Data::TagDB::Tag'},
193  
194 store_size => {loader => \&_load_fstore},
195 store_inode => {loader => \&_load_fstore},
196 store_mediasubtype => {loader => \&_load_fstore, rawtype => 'mediatype'},
197 store_contentise => {loader => \&_load_fstore, rawtype => 'ise'},
198 store_inodeise => {loader => \&_load_fstore, rawtype => 'ise'},
199 store_final => {loader => \&_load_fstore, rawtype => 'bool'},
200 store_finalmode => {loader => \&_load_fstore, rawtype => 'ise'},
201 store_writemode => {loader => \&_load_fstore, rawtype => 'ise'},
202 );
203  
204 3 my @_digest_preload_properties = qw(xattr_utag_final_file_hash xattr_utag_final_file_size tagpool_file_size);
205  
206 4 ▶sub _new {
Subroutine _new: called CC=3 SCAR=11.3
207 4 my ($pkg, %opts) = @_;
208 4 my $self = bless \%opts, $pkg;
209  
210 4 ▶ croak 'No instance is given' unless defined $self->{instance};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"instance"} 0 4 4
211  
212 4 ▶ $self->{properties} //= {}; # empty list.
Condition50%1/2
$self->{"properties"} //= {}
l!l
40
MC/DC0%0/1
$self->{"properties"} //= {}
$self->{"properties"}
Truth table50%1/2
A
A= $self->{"properties"}
Aresult
11
00
213  
214 4 return $self;
215 }
216  
217  
218 64 ▶sub get {
Subroutine get: called CC=99 SCAR=76.2
Pod documented
219 64 my ($self, $key, %opts) = @_;
220 64 ▶ my $info = $self->{properties}{$key} // $_properties{$key};
Condition100%3/3
$self->{"properties"}{$key} // $_properties{$key}
l!l&&r!l&&!r
202024
MC/DC100%2/2
$self->{"properties"}{$key} // $_properties{$key}
$self->{"properties"}{$key} $_properties{$key}
Truth table100%3/3
A // B
A= $self->{"properties"}{$key}B= $_properties{$key}
ABresult
1X1
011
000
221 64 my $rawtype = $info->{rawtype};
222 64 ▶ my $pv = $self->{properties_values} //= {};
Condition100%2/2
$self->{"properties_values"} //= {}
l!l
604
MC/DC100%1/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table100%2/2
A
A= $self->{"properties_values"}
Aresult
11
00
223 64 my $v;
224 my $res;
225 64 my $as;
226 64 my $lifecycle;
227  
228 64 ▶ unless (defined $info) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $info) 0 64 64
229 0 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
230 0 croak 'Unknown key '.$key;
231 }
232  
233 64 ▶ $as = $opts{as} //= $info->{default_as} // 'raw';
Condition75%3/4
$opts{"as"} //= $info->{"default_as"} // "raw"
l!l
5212
$info->{"default_as"} // "raw"
l!l
012
MC/DC100%1/1
$opts{"as"} //= $info->{"default_as"} // "raw"
$opts{"as"}
Truth table100%2/2
A
A= $opts{"as"}
Aresult
11
00
234 64 ▶ $lifecycle = $opts{lifecycle} //= 'current';
Condition100%2/2
$opts{"lifecycle"} //= "current"
l!l
5212
MC/DC100%1/1
$opts{"lifecycle"} //= "current"
$opts{"lifecycle"}
Truth table100%2/2
A
A= $opts{"lifecycle"}
Aresult
11
00
235  
236 64 ▶ $pv = $pv->{$lifecycle} //= {};
Condition100%2/2
$pv->{$lifecycle} //= {}
l!l
604
MC/DC100%1/1
$pv->{$lifecycle} //= {}
$pv->{$lifecycle}
Truth table100%2/2
A
A= $pv->{$lifecycle}
Aresult
11
00
237  
238 # load the value if needed.
239 64 ▶ if ((!defined($pv->{$key}) || (ref($pv->{$key}) eq 'HASH' && !scalar(%{$pv->{$key}}))) && defined(my $loader = $info->{loader})) {
Branch: 1 branch
BranchTrueFalseTotal
if (!defined($pv->{$key}) || ref $pv->{$key} eq "HASH" && !scalar(%{$pv->{$key};}) and defined(my $loader = $info->{"loader"})) 34 30 64
Condition88%8/9
!defined($pv->{$key}) || ref $pv->{$key} eq "HASH" && !scalar(%{$pv->{$key};}) and defined(my $loader = $info->{"loader"})
!ll&&!rl&&r
62434
not defined $pv->{$key} or ref $pv->{$key} eq "HASH" and not scalar %{$pv->{$key};}
l!l&&r!l&&!r
44146
ref $pv->{$key} eq "HASH" and not scalar %{$pv->{$key};}
!ll&&!rl&&r
0614
MC/DC75%3/4
!defined($pv->{$key}) || ref $pv->{$key} eq "HASH" && !scalar(%{$pv->{$key};}) and defined(my $loader = $info->{"loader"})
not defined $pv->{$key} ref $pv->{$key} eq "HASH" not scalar %{$pv->{$key};} defined(my $loader = $info->{"loader"})
Truth table83%5/6
not(A) or B and not(C) and D
A= not defined $pv->{$key}B= ref $pv->{$key} eq "HASH"C= not scalar %{$pv->{$key};}D= defined(my $loader = $info->{"loader"})
ABCDresult
00XX0
010X0
1XX00
01100
1XX11
01111
240 34 ▶ $loader = $self->can($loader) unless ref $loader;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $loader 0 34 34
241 34 $self->$loader($key, %opts, list => undef);
242 }
243  
244 64 ▶ $v = $pv->{$key} //= {};
Condition100%2/2
$pv->{$key} //= {}
l!l
2638
MC/DC100%1/1
$pv->{$key} //= {}
$pv->{$key}
Truth table100%2/2
A
A= $pv->{$key}
Aresult
11
00
245  
246 64 ▶ if ($opts{list}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts{'list'}) { } 4 60 64
elsif (ref $v eq 'ARRAY') { } 0 60 60
247 4 my $default = delete $opts{default};
248  
249 4 delete $opts{list};
250  
251 4 ▶ if (ref($v) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq 'ARRAY') { } 0 4 4
252 0 my @list;
253 my $error;
254  
255 0 foreach my $entry (@{$v}) {
256 0 local $pv->{$key} = $entry;
257 0 my $val = $self->get($key, %opts, default => undef);
258  
259 0 ▶ if (defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val) { } 0 0 0
260 0 push(@list, $val);
261 } else {
262 0 $error = 1;
263 0 last;
264 }
265 }
266  
267 0 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) { } 0 0 0
268 0 ▶ return @{$default} if defined $default;
Branch: 1 branch
BranchTrueFalseTotal
if defined $default 0 0 0
269 0 $v = {}; # handle like an empty entry.
270 } else {
271 0 return @list;
272 }
273 } else {
274 4 my $val = $self->get($key, %opts, default => undef);
275  
276 #warn sprintf('key=%s, v=%s, val=%s, default=%s', $key, $v, $val // '<undef>', $default // '<undef>');
277 4 ▶ if (defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val) { } 0 4 4
278 0 return ($val);
279 } else {
280 4 ▶ return @{$default} if defined $default;
Branch: 1 branch
BranchTrueFalseTotal
if defined $default 4 0 4
281 #confess 'Doof';
282 0 $v = {}; # handle like an empty entry.
283 }
284 }
285 } elsif (ref($v) eq 'ARRAY') {
286 0 $v = {}; # handle like an empty entry.
287 }
288  
289 # Update rawtype as needed:
290 60 ▶ $rawtype = $v->{rawtype} // $rawtype;
Condition66%2/3
$v->{"rawtype"} // $rawtype
l!l&&r!l&&!r
03426
MC/DC50%1/2
$v->{"rawtype"} // $rawtype
$v->{"rawtype"} $rawtype
Truth table66%2/3
A // B
A= $v->{"rawtype"}B= $rawtype
ABresult
1X1
011
000
291  
292 # Try: Check if we have what we want.
293 60 $res = $v->{$as};
294  
295 # Try: Check if we can convert (rawtype, raw) to what we want.
296 60 ▶ if (!defined($res) && defined($rawtype) && defined(my $raw = $v->{raw})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $res and defined $rawtype and defined(my $raw = $v->{"raw"})) 0 60 60
Condition83%5/6
not defined $res and defined $rawtype and defined(my $raw = $v->{"raw"})
!ll&&!rl&&r
34260
not defined $res and defined $rawtype
!ll&&!rl&&r
122226
MC/DC0%0/3
not defined $res and defined $rawtype and defined(my $raw = $v->{"raw"})
not defined $res defined $rawtype defined(my $raw = $v->{"raw"})
Truth table75%3/4
not(A) and B and C
A= not defined $resB= defined $rawtypeC= defined(my $raw = $v->{"raw"})
ABCresult
0XX0
10X0
1100
1111
297 0 ▶ if ($rawtype eq $as) {
Branch: 9 branches
BranchTrueFalseTotal
if ($rawtype eq $as) { } 0 0 0
elsif ($rawtype eq 'unixts' and $as eq 'DateTime') { } 0 0 0
elsif ($rawtype eq 'unixts' and $as eq 'Data::Identifier') { } 0 0 0
elsif ($rawtype eq 'ise' and defined(my $re = $_ise_re{$as})) { } 0 0 0
elsif ($_data_identifier_keys{$rawtype} and $as eq 'Data::Identifier') { } 0 0 0
elsif ($_ise_keys{$rawtype} and $as eq 'Data::URIID::Result') { } 0 0 0
elsif ($rawtype eq 'filename' and $as eq 'File::Information::Link') { } 0 0 0
elsif ($rawtype eq 'filename' and $as eq 'IO::Handle' || $as eq 'IO::File') { } 0 0 0
elsif (exists $_ise_re{$rawtype} and $as eq 'Data::TagDB::Tag' and $self->instance->db) { } 0 0 0
298 0 $res = $raw;
299 ▶ } elsif ($rawtype eq 'unixts' && $as eq 'DateTime') {
Condition0%0/3
$rawtype eq "unixts" and $as eq "DateTime"
!ll&&!rl&&r
000
MC/DC0%0/2
$rawtype eq "unixts" and $as eq "DateTime"
$rawtype eq "unixts" $as eq "DateTime"
Truth table0%0/3
A and B
A= $rawtype eq "unixts"B= $as eq "DateTime"
ABresult
0X0
100
111
300 0 require DateTime;
301 0 $res = DateTime->from_epoch(epoch => $raw, time_zone => 'UTC');
302 ▶ } elsif ($rawtype eq 'unixts' && $as eq 'Data::Identifier') {
Condition0%0/3
$rawtype eq "unixts" and $as eq "Data::Identifier"
!ll&&!rl&&r
000
MC/DC0%0/2
$rawtype eq "unixts" and $as eq "Data::Identifier"
$rawtype eq "unixts" $as eq "Data::Identifier"
Truth table0%0/3
A and B
A= $rawtype eq "unixts"B= $as eq "Data::Identifier"
ABresult
0X0
100
111
303 0 require Data::Identifier::Generate;
304 0 $res = Data::Identifier::Generate->date($raw);
305 ▶ } elsif ($rawtype eq 'ise' && defined(my $re = $_ise_re{$as})) {
Condition0%0/3
$rawtype eq "ise" and defined(my $re = $_ise_re{$as})
!ll&&!rl&&r
000
MC/DC0%0/2
$rawtype eq "ise" and defined(my $re = $_ise_re{$as})
$rawtype eq "ise" defined(my $re = $_ise_re{$as})
Truth table0%0/3
A and B
A= $rawtype eq "ise"B= defined(my $re = $_ise_re{$as})
ABresult
0X0
100
111
306 0 ▶ $res = $raw if $raw =~ $re;
Branch: 1 branch
BranchTrueFalseTotal
if $raw =~ /$re/u 0 0 0
307 ▶ } elsif ($_data_identifier_keys{$rawtype} && $as eq 'Data::Identifier') {
Condition0%0/3
$_data_identifier_keys{$rawtype} and $as eq "Data::Identifier"
!ll&&!rl&&r
000
MC/DC0%0/2
$_data_identifier_keys{$rawtype} and $as eq "Data::Identifier"
$_data_identifier_keys{$rawtype} $as eq "Data::Identifier"
Truth table0%0/3
A and B
A= $_data_identifier_keys{$rawtype}B= $as eq "Data::Identifier"
ABresult
0X0
100
111
308 0 $res = Data::Identifier->new($rawtype => $raw);
309 ▶ } elsif ($_ise_keys{$rawtype} && $as eq 'Data::URIID::Result') {
Condition0%0/3
$_ise_keys{$rawtype} and $as eq "Data::URIID::Result"
!ll&&!rl&&r
000
MC/DC0%0/2
$_ise_keys{$rawtype} and $as eq "Data::URIID::Result"
$_ise_keys{$rawtype} $as eq "Data::URIID::Result"
Truth table0%0/3
A and B
A= $_ise_keys{$rawtype}B= $as eq "Data::URIID::Result"
ABresult
0X0
100
111
310 0 $res = $self->instance->extractor->lookup(ise => $raw);
311 ▶ } elsif ($rawtype eq 'filename' && $as eq 'File::Information::Link') {
Condition0%0/3
$rawtype eq "filename" and $as eq "File::Information::Link"
!ll&&!rl&&r
000
MC/DC0%0/2
$rawtype eq "filename" and $as eq "File::Information::Link"
$rawtype eq "filename" $as eq "File::Information::Link"
Truth table0%0/3
A and B
A= $rawtype eq "filename"B= $as eq "File::Information::Link"
ABresult
0X0
100
111
312 0 $res = $self->instance->for_link($raw);
313 ▶ } elsif ($rawtype eq 'filename' && ($as eq 'IO::Handle' || $as eq 'IO::File')) {
Condition0%0/6
$rawtype eq "filename" and $as eq "IO::Handle" || $as eq "IO::File"
!ll&&!rl&&r
000
$as eq "IO::Handle" or $as eq "IO::File"
l!l&&r!l&&!r
000
MC/DC0%0/3
$rawtype eq "filename" and $as eq "IO::Handle" || $as eq "IO::File"
$rawtype eq "filename" $as eq "IO::Handle" $as eq "IO::File"
Truth table0%0/4
A and B or C
A= $rawtype eq "filename"B= $as eq "IO::Handle"C= $as eq "IO::File"
ABCresult
0XX0
1000
11X1
1011
314 0 require IO::File;
315 0 $res = IO::File->new($raw, 'r');
316 ▶ } elsif (exists($_ise_re{$rawtype}) && $as eq 'Data::TagDB::Tag' && $self->instance->db) {
Condition0%0/6
exists $_ise_re{$rawtype} and $as eq "Data::TagDB::Tag" and $self->instance->db
!ll&&!rl&&r
000
exists $_ise_re{$rawtype} and $as eq "Data::TagDB::Tag"
!ll&&!rl&&r
000
MC/DC0%0/3
exists $_ise_re{$rawtype} and $as eq "Data::TagDB::Tag" and $self->instance->db
exists $_ise_re{$rawtype} $as eq "Data::TagDB::Tag" $self->instance->db
Truth table0%0/4
A and B and C
A= exists $_ise_re{$rawtype}B= $as eq "Data::TagDB::Tag"C= $self->instance->db
ABCresult
0XX0
10X0
1100
1111
317 0 $res = eval {$self->instance->db->tag_by_id($rawtype => $raw)};
318 }
319  
320 0 ▶ $v->{$as} = $res if defined($res) && $as !~ /^IO::/; # Cache unless it is a file handle.
Branch: 1 branch
BranchTrueFalseTotal
if defined $res and not $as =~ /^IO::/u 0 0 0
Condition0%0/3
defined $res and not $as =~ /^IO::/u
!ll&&!rl&&r
000
MC/DC0%0/2
defined $res and not $as =~ /^IO::/u
defined $res not $as =~ /^IO::/u
Truth table0%0/3
A and not(B)
A= defined $resB= not $as =~ /^IO::/u
ABresult
0X0
100
111
321 }
322  
323 60 ▶ if (!defined($res) && blessed($v->{raw})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $res and builtin::blessed($v->{"raw"})) 0 60 60
Condition66%2/3
not defined $res and builtin::blessed($v->{"raw"})
!ll&&!rl&&r
12480
MC/DC0%0/2
not defined $res and builtin::blessed($v->{"raw"})
not defined $res builtin::blessed($v->{"raw"})
Truth table66%2/3
not(A) and B
A= not defined $resB= builtin::blessed($v->{"raw"})
ABresult
0X0
100
111
324 0 $res = eval {$v->{raw}->Data::Identifier::as($as, db => $self->db, extractor => $self->extractor)};
325 }
326  
327 # Try: Check if we have a Data::Identifier and want a sid.
328 60 ▶ if (!defined($res) && $as eq 'sid' && defined(my $identifier = $v->{'Data::Identifier'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $res and $as eq "sid" and defined(my $identifier = $v->{"Data::Identifier"})) 0 60 60
Condition50%3/6
not defined $res and $as eq "sid" and defined(my $identifier = $v->{"Data::Identifier"})
!ll&&!rl&&r
6000
not defined $res and $as eq "sid"
!ll&&!rl&&r
12480
MC/DC0%0/3
not defined $res and $as eq "sid" and defined(my $identifier = $v->{"Data::Identifier"})
not defined $res $as eq "sid" defined(my $identifier = $v->{"Data::Identifier"})
Truth table50%2/4
not(A) and B and C
A= not defined $resB= $as eq "sid"C= defined(my $identifier = $v->{"Data::Identifier"})
ABCresult
0XX0
10X0
1100
1111
329 0 ▶ $v->{sid} = $res if defined($res = eval {$identifier->sid});
Branch: 1 branch
BranchTrueFalseTotal
if defined($res = eval { do { $identifier->sid } }) 0 0 0
330 }
331  
332 # Try: Check if we can manage to get hold of a ISE in some way.
333 60 ▶ if (!defined($res) && !defined($v->{ise}) && defined($rawtype) && $rawtype eq 'ise') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $res || defined $v->{"ise"} and defined $rawtype and $rawtype eq "ise") 16 44 60
Condition88%8/9
not defined $res || defined $v->{"ise"} and defined $rawtype and $rawtype eq "ise"
!ll&&!rl&&r
341016
not defined $res || defined $v->{"ise"} and defined $rawtype
!ll&&!rl&&r
122226
defined $res || defined $v->{'ise'}
l!l&&r!l&&!r
12048
MC/DC75%3/4
not defined $res || defined $v->{"ise"} and defined $rawtype and $rawtype eq "ise"
defined $res defined $v->{'ise'} defined $rawtype $rawtype eq "ise"
Truth table80%4/5
not(A || B) and C and D
A= defined $resB= defined $v->{'ise'}C= defined $rawtypeD= $rawtype eq "ise"
ABCDresult
1XXX0
01XX0
000X0
00100
00111
334 16 $v->{ise} = $v->{raw};
335 }
336 60 ▶ if (!defined($res) && !defined($v->{ise})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $res or defined $v->{"ise"}) 48 12 60
Condition66%2/3
defined $res or defined $v->{"ise"}
l!l&&r!l&&!r
12048
MC/DC50%1/2
defined $res or defined $v->{"ise"}
defined $res defined $v->{"ise"}
Truth table66%2/3
A or B
A= defined $resB= defined $v->{"ise"}
ABresult
1X1
011
000
337 48 foreach my $key (keys %_ise_re) {
338 144 ▶ last if defined($v->{ise} = $v->{$key});
Branch: 1 branch
BranchTrueFalseTotal
if defined($v->{"ise"} = $v->{$key}) 0 144 144
339 144 ▶ last if defined($rawtype) && $rawtype eq $key && defined($v->{ise} = $v->{raw});
Branch: 1 branch
BranchTrueFalseTotal
if defined $rawtype and $rawtype eq $key and defined($v->{"ise"} = $v->{"raw"}) 0 144 144
Condition83%5/6
defined $rawtype and $rawtype eq $key and defined($v->{"ise"} = $v->{"raw"})
!ll&&!rl&&r
13680
defined $rawtype and $rawtype eq $key
!ll&&!rl&&r
66708
MC/DC0%0/3
defined $rawtype and $rawtype eq $key and defined($v->{"ise"} = $v->{"raw"})
defined $rawtype $rawtype eq $key defined($v->{"ise"} = $v->{"raw"})
Truth table75%3/4
A and B and C
A= defined $rawtypeB= $rawtype eq $keyC= defined($v->{"ise"} = $v->{"raw"})
ABCresult
0XX0
10X0
1100
1111
340 }
341 }
342 60 ▶ if (!defined($res) && !defined($v->{ise}) && ($rawtype // '') eq 'mediatype') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $res || defined $v->{"ise"} and ($rawtype // "") eq "mediatype") 0 60 60
Condition75%6/8
not defined $res || defined $v->{"ise"} and ($rawtype // "") eq "mediatype"
!ll&&!rl&&r
12480
defined $res || defined $v->{'ise'}
l!l&&r!l&&!r
12048
$rawtype // ""
l!l
2622
MC/DC66%2/3
not defined $res || defined $v->{"ise"} and ($rawtype // "") eq "mediatype"
defined $res defined $v->{'ise'} $rawtype
Truth table75%3/4
not(A || B) and C
A= defined $resB= defined $v->{'ise'}C= $rawtype
ABCresult
1XX0
01X0
0000
0011
343 0 ▶ $v->{ise} = $_mediatypes{$v->{raw} // ''};
Condition0%0/2
$v->{"raw"} // ""
l!l
00
MC/DC0%0/1
$v->{"raw"} // ""
$v->{"raw"}
Truth table0%0/2
A
A= $v->{"raw"}
Aresult
11
00
344 }
345 60 ▶ if (!defined($res) && !defined($v->{ise})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $res or defined $v->{"ise"}) 48 12 60
Condition66%2/3
defined $res or defined $v->{"ise"}
l!l&&r!l&&!r
12048
MC/DC50%1/2
defined $res or defined $v->{"ise"}
defined $res defined $v->{"ise"}
Truth table66%2/3
A or B
A= defined $resB= defined $v->{"ise"}
ABresult
1X1
011
000
346 48 foreach my $source_type (qw(Data::Identifier Data::URIID::Result Data::URIID::Colour Data::TagDB::Tag)) {
347 192 ▶ if (defined(my $obj = $v->{$source_type})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $obj = $v->{$source_type})) 0 192 192
348 0 ▶ last if defined($v->{ise} = eval {$obj->ise});
Branch: 1 branch
BranchTrueFalseTotal
if defined($v->{"ise"} = eval { do { $obj->ise } }) 0 0 0
349 }
350 192 ▶ if (defined($rawtype) && $rawtype eq $source_type && defined(my $obj = $v->{raw})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rawtype and $rawtype eq $source_type and defined(my $obj = $v->{"raw"})) 0 192 192
Condition50%3/6
defined $rawtype and $rawtype eq $source_type and defined(my $obj = $v->{"raw"})
!ll&&!rl&&r
19200
defined $rawtype and $rawtype eq $source_type
!ll&&!rl&&r
881040
MC/DC0%0/3
defined $rawtype and $rawtype eq $source_type and defined(my $obj = $v->{"raw"})
defined $rawtype $rawtype eq $source_type defined(my $obj = $v->{"raw"})
Truth table50%2/4
A and B and C
A= defined $rawtypeB= $rawtype eq $source_typeC= defined(my $obj = $v->{"raw"})
ABCresult
0XX0
10X0
1100
1111
351 0 ▶ last if defined($v->{ise} = eval {$obj->ise});
Branch: 1 branch
BranchTrueFalseTotal
if defined($v->{"ise"} = eval { do { $obj->ise } }) 0 0 0
352 }
353 }
354 }
355  
356 60 ▶ delete $v->{ise} unless defined $v->{ise}; # TODO: Figure out where it is set to undef
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v->{"ise"} 60 0 60
357  
358 # Try: Check if we have an ISE and can convert that to what we want.
359 60 ▶ if (!defined($res) && defined(my $ise = $v->{ise})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $res and defined(my $ise = $v->{"ise"})) 0 60 60
Condition66%2/3
not defined $res and defined(my $ise = $v->{"ise"})
!ll&&!rl&&r
12480
MC/DC0%0/2
not defined $res and defined(my $ise = $v->{"ise"})
not defined $res defined(my $ise = $v->{"ise"})
Truth table66%2/3
not(A) and B
A= not defined $resB= defined(my $ise = $v->{"ise"})
ABresult
0X0
100
111
360 0 ▶ if ($as eq 'Data::Identifier') {
Branch: 6 branches
BranchTrueFalseTotal
if ($as eq 'Data::Identifier') { } 0 0 0
elsif ($as eq 'Data::URIID::Result') { } 0 0 0
elsif ($as eq 'Data::TagDB::Tag' and $self->instance->db) { } 0 0 0
elsif (defined(my $re = $_ise_re{$as})) { } 0 0 0
elsif ($as eq 'sid') { } 0 0 0
elsif ($as eq 'mediatype') { } 0 0 0
361 0 $res = Data::Identifier->new(ise => $ise);
362 } elsif ($as eq 'Data::URIID::Result') {
363 0 $res = $self->instance->extractor->lookup(ise => $ise);
364 ▶ } elsif ($as eq 'Data::TagDB::Tag' && $self->instance->db) {
Condition0%0/3
$as eq "Data::TagDB::Tag" and $self->instance->db
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "Data::TagDB::Tag" and $self->instance->db
$as eq "Data::TagDB::Tag" $self->instance->db
Truth table0%0/3
A and B
A= $as eq "Data::TagDB::Tag"B= $self->instance->db
ABresult
0X0
100
111
365 0 foreach my $type (keys %_ise_re) {
366 0 ▶ if ($ise =~ $_ise_re{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ise =~ /$_ise_re{$type}/u) 0 0 0
367 0 ▶ $res = eval {$self->instance->db->tag_by_id($type => $ise)} and last;
Branch: 1 branch
BranchTrueFalseTotal
$res = eval { do { $self->instance->db->tag_by_id($type, $ise) } } and last 0 0 0
368 }
369 }
370 } elsif (defined(my $re = $_ise_re{$as})) {
371 0 ▶ $res = $ise if $ise =~ $re;
Branch: 1 branch
BranchTrueFalseTotal
if $ise =~ /$re/u 0 0 0
372 } elsif ($as eq 'sid') {
373 0 my $identifier = $v->{'Data::Identifier'} = Data::Identifier->new(ise => $ise);
374 0 $res = eval {$identifier->sid};
375 } elsif ($as eq 'mediatype') {
376 0 $res = $_inverse_mediatypes{$ise};
377 }
378  
379 0 ▶ $v->{$as} = $res if defined($res) && $as !~ /^IO::/; # Cache unless it is a file handle.
Branch: 1 branch
BranchTrueFalseTotal
if defined $res and not $as =~ /^IO::/u 0 0 0
Condition0%0/3
defined $res and not $as =~ /^IO::/u
!ll&&!rl&&r
000
MC/DC0%0/2
defined $res and not $as =~ /^IO::/u
defined $res not $as =~ /^IO::/u
Truth table0%0/3
A and not(B)
A= defined $resB= not $as =~ /^IO::/u
ABresult
0X0
100
111
380 }
381  
382 60 ▶ return $res if defined $res;
Branch: 1 branch
BranchTrueFalseTotal
if defined $res 12 48 60
383  
384 48 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 48 0 48
385  
386 0 confess 'Cannot get value for key '.$key;
387 }
388  
389  
390 0 ▶sub property_info {
Subroutine property_info: not called CC=8 SCAR=42.8
Pod documented
391 0 my ($self, @algos) = @_;
392 0 my @ret;
393  
394 0 ▶ unless ($self->{property_info}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"property_info"}) 0 0 0
395 0 my %properties = map {$_ => {
396 name => $_,
397 0 }} keys %{$self->{properties}}, keys %_properties;
398  
399 0 $properties{$_}{stable} = 1 foreach @_stable_properties;
400  
401 0 $self->{property_info} = \%properties;
402 }
403  
404 0 ▶ @algos = keys %{$self->{property_info}} unless scalar @algos;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @algos 0 0 0
405  
406 0 ▶ croak 'Request for more than one property in scalar context' if !wantarray && scalar(@algos) != 1;
Branch: 1 branch
BranchTrueFalseTotal
if not wantarray and scalar @algos != 1 0 0 0
Condition0%0/3
not wantarray and scalar @algos != 1
!ll&&!rl&&r
000
MC/DC0%0/2
not wantarray and scalar @algos != 1
not wantarray scalar @algos != 1
Truth table0%0/3
not(A) and B
A= not wantarrayB= scalar @algos != 1
ABresult
0X0
100
111
407  
408 @ret = map{
409 0 ▶ $self->{property_info}{$_} ||
Condition0%0/2
$self->{'property_info'}{$_} || croak('Unknown property: ' . $_)
l!l
00
MC/DC0%0/1
$self->{'property_info'}{$_} || croak('Unknown property: ' . $_)
$self->{'property_info'}{$_}
Truth table0%0/2
A
A= $self->{'property_info'}{$_}
Aresult
11
00
410 croak 'Unknown property: '.$_
411 } @algos;
412  
413 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
414 0 return @ret;
415 } else {
416 0 return $ret[0];
417 }
418 }
419  
420  
421 0 ▶sub digest {
Subroutine digest: not called CC=31 SCAR=69.0
Pod documented
422 0 my ($self, $key, %opts) = @_;
423 0 ▶ my $as = $opts{as} // 'hex';
Condition0%0/2
$opts{"as"} // "hex"
l!l
00
MC/DC0%0/1
$opts{"as"} // "hex"
$opts{"as"}
Truth table0%0/2
A
A= $opts{"as"}
Aresult
11
00
424 0 ▶ my $lifecycle = $opts{lifecycle} //= 'current';
Condition0%0/2
$opts{"lifecycle"} //= "current"
l!l
00
MC/DC0%0/1
$opts{"lifecycle"} //= "current"
$opts{"lifecycle"}
Truth table0%0/2
A
A= $opts{"lifecycle"}
Aresult
11
00
425 0 my $value;
426  
427 # convert L<Digest> name into utag name if needed:
428 0 ▶ $key = $_digest_name_converter{fc($key)} // $key;
Condition0%0/3
$File::Information::Base::_digest_name_converter{fc $key} // $key
l!l&&r!l&&!r
000
MC/DC0%0/2
$File::Information::Base::_digest_name_converter{fc $key} // $key
$File::Information::Base::_digest_name_converter{fc $key} $key
Truth table0%0/3
A // B
A= $File::Information::Base::_digest_name_converter{fc $key}B= $key
ABresult
1X1
011
000
429  
430 # Check utag name:
431 0 ▶ if ($key !~ /^[a-z]+-[0-9]+-[1-9][0-9]*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key =~ /^[a-z]+-[0-9]+-[1-9][0-9]*$/u) 0 0 0
432 0 croak sprintf('Unknown digest format "%s"', $key);
433 }
434  
435 0 foreach my $property (@_digest_preload_properties) {
436 0 eval {$self->get($property, lifecycle => $lifecycle)};
437 }
438  
439 0 $value = $self->{digest}{$lifecycle}{$key};
440  
441 0 ▶ if (!defined($value) && $lifecycle eq 'current' && $self->isa('File::Information::Inode') && !$opts{no_defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value and $lifecycle eq "current" and $self->isa("File::Information::Inode") and not $opts{"no_defaults"}) 0 0 0
Condition0%0/9
not defined $value and $lifecycle eq "current" and $self->isa("File::Information::Inode") and not $opts{"no_defaults"}
!ll&&!rl&&r
000
not defined $value and $lifecycle eq "current" and $self->isa("File::Information::Inode")
!ll&&!rl&&r
000
not defined $value and $lifecycle eq "current"
!ll&&!rl&&r
000
MC/DC0%0/4
not defined $value and $lifecycle eq "current" and $self->isa("File::Information::Inode") and not $opts{"no_defaults"}
not defined $value $lifecycle eq "current" $self->isa("File::Information::Inode") not $opts{"no_defaults"}
Truth table0%0/5
not(A) and B and C and not(D)
A= not defined $valueB= $lifecycle eq "current"C= $self->isa("File::Information::Inode")D= not $opts{"no_defaults"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
442 0 my $size = $self->get('size', default => undef);
443 0 my $limit = $self->instance->{digest_sizelimit};
444  
445 0 ▶ if (defined($size) && ($limit == -1 || $size <= $limit)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $size and $limit == -1 || $size <= $limit) 0 0 0
Condition0%0/6
defined $size and $limit == -1 || $size <= $limit
!ll&&!rl&&r
000
$limit == -1 or $size <= $limit
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $size and $limit == -1 || $size <= $limit
defined $size $limit == -1 $size <= $limit
Truth table0%0/4
A and B or C
A= defined $sizeB= $limit == -1C= $size <= $limit
ABCresult
0XX0
1000
11X1
1011
446 0 my $digest;
447  
448 0 eval {
449 0 ▶ if ($key eq 'md-5-128') {
Branch: 5 branches
BranchTrueFalseTotal
if ($key eq 'md-5-128') { } 0 0 0
elsif ($key eq 'sha-1-160') { } 0 0 0
elsif ($key eq 'ripemd-1-160') { } 0 0 0
elsif ($key =~ /^sha-2-(224|256|384|512)$/u) { } 0 0 0
elsif ($key =~ /^sha-3-(224|256|384|512)$/u) { } 0 0 0
450 0 require Digest;
451 0 $digest = Digest->new('MD5');
452 } elsif ($key eq 'sha-1-160') {
453 0 require Digest;
454 0 $digest = Digest->new('SHA-1');
455 } elsif ($key eq 'ripemd-1-160') {
456 0 require Digest;
457 0 $digest = Digest->new('RIPEMD-160');
458 } elsif ($key =~ /^sha-2-(224|256|384|512)$/) {
459 0 require Digest;
460 0 $digest = Digest->new('SHA-'.$1);
461 } elsif ($key =~ /^sha-3-(224|256|384|512)$/) {
462 0 require Digest::SHA3;
463 0 $digest = Digest::SHA3->new($1);
464 }
465 };
466  
467 0 ▶ if (defined $digest) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $digest) 0 0 0
468 0 eval {
469 0 my $fh = $self->_get_fh;
470  
471 0 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 0 0 0
472 0 $digest->addfile($fh);
473 0 $self->{digest}{$lifecycle}{$key} = $value = $digest->hexdigest;
474 }
475 };
476 }
477 }
478 }
479  
480 0 ▶ unless (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 0 0 0
481 0 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
482 0 croak 'No such value for digest '.$key;
483 }
484  
485 0 ▶ if ($as eq 'hex') {
Branch: 6 branches
BranchTrueFalseTotal
if ($as eq 'hex') { } 0 0 0
elsif ($as eq 'binary') { } 0 0 0
elsif ($as eq 'base64' or $as eq 'b64') { } 0 0 0
elsif ($as eq 'base64_padded') { } 0 0 0
elsif ($as eq 'utag') { } 0 0 0
elsif ($as eq 'Digest') { } 0 0 0
486 0 return $value;
487 } elsif ($as eq 'binary') {
488 0 return pack('H*', $value);
489 ▶ } elsif ($as eq 'base64' || $as eq 'b64') {
Condition0%0/3
$as eq "base64" or $as eq "b64"
l!l&&r!l&&!r
000
MC/DC0%0/2
$as eq "base64" or $as eq "b64"
$as eq "base64" $as eq "b64"
Truth table0%0/3
A or B
A= $as eq "base64"B= $as eq "b64"
ABresult
1X1
011
000
490 0 require MIME::Base64;
491 0 return MIME::Base64::encode(pack('H*', $value), '') =~ s/=+$//r;
492 } elsif ($as eq 'base64_padded') {
493 0 require MIME::Base64;
494 0 return MIME::Base64::encode(pack('H*', $value), '');
495 } elsif ($as eq 'utag') {
496 0 ▶ if (defined(my $size = $self->get('size', lifecycle => $lifecycle, default => undef))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $size = $self->get("size", "lifecycle", $lifecycle, "default", undef))) 0 0 0
497 0 ▶ if ($size > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size > 0) { } 0 0 0
498 0 return sprintf('v0 %s bytes 0-%u/%u %s', $key, $size - 1, $size, $value);
499 } else {
500 0 return sprintf('v0 %s bytes 0-/%u %s', $key, $size, $value);
501 }
502 }
503  
504 0 return sprintf('v0 %s bytes 0-/* %s', $key, $value);
505 } elsif ($as eq 'Digest') {
506 0 require Data::URIID::Digest;
507 0 return Data::URIID::Digest->_new($value); # Not public API but developed by same developers as this module.
508 # DO NOT USE THIS IN YOUR CODE!
509 }
510  
511 0 croak sprintf('Cannot convert from type "%s" to "%s" for digest "%s"', 'hex', $as, $key);
512 }
513  
514  
515  
516 #@returns File::Information::VerifyBase
517 0 ▶sub verify {
Subroutine verify: not called CC=1 SCAR=6.9
Pod documented
518 0 my ($self, %opts) = @_;
519 0 require File::Information::VerifyResult;
520 0 return File::Information::VerifyResult->_new(base => $self, instance => $self->instance, %opts{'lifecycle_from', 'lifecycle_to', 'base_from', 'base_to'});
521 }
522  
523  
524 0 ▶sub link_stream {
Subroutine link_stream: not called CC=38 SCAR=73.0
Pod documented
525 0 my ($self, $cb, %opts) = @_;
526 0 my File::Information $instance = $self->instance;
527 0 my $extractor = eval {$self->extractor};
528 0 ▶ my @subobjects = map {lc s/^File::Information:://r} ref($opts{subobjects}) eq 'ARRAY' ? @{$opts{subobjects}} : ($opts{subobjects} // ref($self));
Branch: 1 branch
BranchTrueFalseTotal
ref $opts{'subobjects'} eq 'ARRAY' ? : 0 0 0
Condition0%0/2
$opts{"subobjects"} // ref $self
l!l
00
MC/DC0%0/1
$opts{"subobjects"} // ref $self
$opts{"subobjects"}
Truth table0%0/2
A
A= $opts{"subobjects"}
Aresult
11
00
529 0 ▶ my $inode = $self->isa('File::Information::Inode') ? $self : eval {$self->inode};
Branch: 1 branch
BranchTrueFalseTotal
$self->isa('File::Information::Inode') ? : 0 0 0
530 0 my @lifecycle;
531 my %contentise;
532 0 my @cleanup = (
533 WK_NEEDSTAGGING,
534 WK_FINAL,
535 WK_WM_RANDOM_ACCESS, WK_WM_READ_ONLY, WK_WM_NONE,
536 );
537  
538 0 ▶ if (ref($opts{lifecycle}) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $opts{'lifecycle'} eq 'ARRAY') { } 0 0 0
elsif (defined $opts{'lifecycle'}) { } 0 0 0
539 0 @lifecycle = @{$opts{lifecycle}};
540 } elsif (defined $opts{lifecycle}) {
541 0 @lifecycle = ($opts{lifecycle});
542 } else {
543 0 @lifecycle = $instance->lifecycles;
544 }
545  
546 0 foreach my $subobject (@subobjects) {
547 0 ▶ my $base = $self->isa('File::Information::'.ucfirst($subobject)) ? $self : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->isa('File::Information::' . ucfirst($subobject)) ? : 0 0 0
548  
549 0 foreach my $lifecycle (@lifecycle) {
550 0 ▶ if ($subobject eq 'inode') {
Branch: 3 branches
BranchTrueFalseTotal
if ($subobject eq 'inode') { } 0 0 0
elsif ($subobject eq 'filesystem') { } 0 0 0
elsif ($subobject eq 'tagpool') { } 0 0 0
551 0 ▶ $base //= $self->inode;
Condition0%0/3
$base //= $self->inode
l!l&&r!l&&!r
000
MC/DC0%0/2
$base //= $self->inode
$base $self->inode
Truth table0%0/3
A //= B
A= $baseB= $self->inode
ABresult
1X1
011
000
552  
553 0 ▶ if (defined(my $contentise = $base->get('contentise', default => undef, as => 'Data::Identifier', lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $contentise = $base->get("contentise", "default", undef, "as", "Data::Identifier", "lifecycle", $lifecycle))) 0 0 0
554 0 $contentise{$lifecycle} = $contentise;
555  
556 0 $cb->('tag-ise', [$contentise]);
557 0 $cb->('tag-relation', {tag => $contentise, relation => _to_di(WK_ALSO_HAS_ROLE), related => _to_di(WK_SPECIFIC_PROTO_FILE_STATE)});
558  
559 0 ▶ if (defined(my $mediatype = $base->get('mediatype', default => undef, as => 'Data::Identifier', lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $mediatype = $base->get("mediatype", "default", undef, "as", "Data::Identifier", "lifecycle", $lifecycle))) 0 0 0
560 0 $cb->('tag-relation', {tag => $contentise, relation => _to_di(WK_FINAL_FILE_ENCODING), related => $mediatype});
561 0 push(@cleanup, $mediatype);
562 }
563  
564 0 ▶ if (defined(my $size = $base->get('size', default => undef, lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $size = $base->get("size", "default", undef, "lifecycle", $lifecycle))) 0 0 0
565 0 $cb->('tag-metadata', {tag => $contentise, relation => _to_di(WK_FINAL_FILE_SIZE), data => $size});
566 }
567  
568 0 foreach my $algo (map {$_->{name}} $instance->digest_info) {
569 0 ▶ my $hash = $base->digest($algo, as => 'utag', default => undef, lifecycle => $lifecycle, no_defaults => !$_important_digests{$algo}) // next;
Condition0%0/2
$base->digest($algo, "as", "utag", "default", undef, "lifecycle", $lifecycle, "no_defaults", !$_important_digests{$algo}) // (next)
l!l
00
MC/DC0%0/1
$base->digest($algo, "as", "utag", "default", undef, "lifecycle", $lifecycle, "no_defaults", !$_important_digests{$algo}) // (next)
$base->digest($algo, "as", "utag", "default", undef, "lifecycle", $lifecycle, "no_defaults", !$_important_digests{$algo})
Truth table0%0/2
A
A= $base->digest($algo, "as", "utag", "default", undef, "lifecycle", $lifecycle, "no_defaults", !$_important_digests{$algo})
Aresult
11
00
570 0 $cb->('tag-metadata', {tag => $contentise, relation => _to_di(WK_FINAL_FILE_HASH), data => $hash});
571 }
572  
573 0 ▶ if (defined(my $size = $base->get('fetchurl', default => undef, lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $size = $base->get("fetchurl", "default", undef, "lifecycle", $lifecycle))) 0 0 0
574 0 $cb->('tag-metadata', {tag => $contentise, relation => _to_di(WK_FETCH_FILE_URI), data => $size});
575 }
576  
577 }
578  
579 0 ▶ if (defined(my $tagpoolise = $base->get('tagpool_file_uuid', as => 'Data::Identifier', default => undef, lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $tagpoolise = $base->get("tagpool_file_uuid", "as", "Data::Identifier", "default", undef, "lifecycle", $lifecycle))) 0 0 0
580 0 my %tags = map {$_->ise => $_} $base->get('tagpool_file_tags', as => 'Data::Identifier', list => 1, default => [], lifecycle => $lifecycle);
581 0 my %states;
582  
583 0 $cb->('tag-ise', [$tagpoolise]);
584  
585 0 $cb->('tag-relation', {tag => $tagpoolise, relation => _to_di(WK_ALSO_HAS_ROLE), related => _to_di(WK_PROTO_FILE)});
586 0 $cb->('tag-relation', {tag => $tagpoolise, relation => _to_di(WK_ALSO_HAS_ROLE), related => _to_di(WK_TAGPOOL_FILE)});
587  
588 0 foreach my $l ('final', @lifecycle) {
589 0 ▶ my $contentise = $contentise{$l} // next;
Condition0%0/2
$contentise{$l} // (next)
l!l
00
MC/DC0%0/1
$contentise{$l} // (next)
$contentise{$l}
Truth table0%0/2
A
A= $contentise{$l}
Aresult
11
00
590 0 ▶ my $relation = $l eq 'final' ? WK_HAS_FINAL_STATE : WK_ALSO_HAS_STATE;
Branch: 1 branch
BranchTrueFalseTotal
$l eq 'final' ? : 0 0 0
591  
592 # skip duplicates.
593 0 ▶ next if $states{$contentise->ise};
Branch: 1 branch
BranchTrueFalseTotal
if $states{$contentise->ise} 0 0 0
594 0 $states{$contentise->ise} = 1;
595  
596 0 $cb->('tag-relation', {tag => $tagpoolise, relation => _to_di($relation), related => $contentise});
597 }
598  
599 0 foreach my $key (keys %_tagpool_relations) {
600 0 ▶ if (defined(my $value = $base->get($key, default => undef, lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = $base->get($key, "default", undef, "lifecycle", $lifecycle))) 0 0 0
601 0 $cb->('tag-metadata', {tag => $tagpoolise, relation => _to_di($_tagpool_relations{$key}), data => $value});
602 }
603 }
604  
605 0 ▶ if (defined(my $description_url = $base->get('tagpool_file_original_description_url', default => undef, lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $description_url = $base->get("tagpool_file_original_description_url", "default", undef, "lifecycle", $lifecycle))) 0 0 0
606 0 ▶ if (defined(my $result = eval { $extractor->lookup(qrcode => $description_url)->as('Data::Identifier') })) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $result = eval { do { $extractor->lookup("qrcode", $description_url)->as("Data::Identifier") } })) 0 0 0
607 0 $cb->('tag-relation', {tag => $tagpoolise, relation => _to_di(WK_SEE_ALSO), related => $result});
608 }
609 }
610  
611 # Clean up tags:
612 0 foreach my $tag (@cleanup) {
613 0 ▶ if (ref $tag) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $tag) { } 0 0 0
614 0 delete $tags{$tag->ise};
615 } else {
616 0 delete $tags{$tag};
617 }
618 }
619  
620 0 foreach my $related (values %tags) {
621 0 $cb->('tag-relation', {tag => $tagpoolise, relation => _to_di(WK_TAGPOOL_TAGGED_AS), related => $related});
622 }
623 }
624 } elsif ($subobject eq 'filesystem') {
625 0 ▶ $base //= $self->filesystem;
Condition0%0/3
$base //= $self->filesystem
l!l&&r!l&&!r
000
MC/DC0%0/2
$base //= $self->filesystem
$base $self->filesystem
Truth table0%0/3
A //= B
A= $baseB= $self->filesystem
ABresult
1X1
011
000
626  
627 0 ▶ if (defined(my $ise = $base->get('ise', default => undef, as => 'Data::Identifier', lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $ise = $base->get("ise", "default", undef, "as", "Data::Identifier", "lifecycle", $lifecycle))) 0 0 0
628 0 $cb->('tag-ise', [$ise]);
629 0 $cb->('tag-relation', {tag => $ise, relation => _to_di(WK_ALSO_HAS_ROLE), related => _to_di(WK_FILESYSTEM)});
630  
631 0 ▶ if (defined(my $label = $base->get('dev_disk_by_label', default => undef, lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $label = $base->get("dev_disk_by_label", "default", undef, "lifecycle", $lifecycle))) 0 0 0
632 0 $cb->('tag-metadata', {tag => $ise, relation => _to_di(WK_ALSO_SHARES_IDENTIFIER), type => _to_di(WK_TAGNAME), data => $label});
633 }
634 }
635 } elsif ($subobject eq 'tagpool') {
636 0 ▶ foreach my $tagpool ($base ? ($base) : $self->tagpool) {
Branch: 1 branch
BranchTrueFalseTotal
$base ? : 0 0 0
637 0 ▶ if (defined(my $ise = $tagpool->get('ise', default => undef, as => 'Data::Identifier', lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $ise = $tagpool->get("ise", "default", undef, "as", "Data::Identifier", "lifecycle", $lifecycle))) 0 0 0
638 0 $cb->('tag-ise', [$ise]);
639 0 $cb->('tag-relation', {tag => $ise, relation => _to_di(WK_ALSO_HAS_ROLE), related => _to_di(WK_TAGPOOL_POOL)});
640 }
641 }
642 } else {
643 0 ▶ if (defined(my $ise = $base->get('ise', default => undef, as => 'Data::Identifier', lifecycle => $lifecycle))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $ise = $base->get("ise", "default", undef, "as", "Data::Identifier", "lifecycle", $lifecycle))) 0 0 0
644 0 $cb->('tag-ise', [$ise]);
645 }
646 }
647 }
648 }
649 }
650  
651  
652 0 ▶sub uuid { return $_[0]->get('uuid', @_[1..$#_]); }
Subroutine uuid: not called CC=1 SCAR=6.9
Pod documented
653 0 ▶sub oid { return $_[0]->get('oid', @_[1..$#_]); }
Subroutine oid: not called CC=1 SCAR=6.9
Pod documented
654 0 ▶sub uri { return $_[0]->get('uri', @_[1..$#_]); }
Subroutine uri: not called CC=1 SCAR=6.9
Pod documented
655 0 ▶sub ise { return $_[0]->get('ise', @_[1..$#_]); }
Subroutine ise: not called CC=1 SCAR=6.9
Pod documented
656 0 ▶sub displayname { return $_[0]->get('displayname', @_[1..$#_]); }
Subroutine displayname: not called CC=1 SCAR=6.9
Pod documented
657 0 ▶sub displaycolour { return $_[0]->get('displaycolour', @_[1..$#_]); }
Subroutine displaycolour: not called CC=1 SCAR=6.9
Pod documented
658 0 ▶sub icontext { return $_[0]->get('icontext', @_[1..$#_]); }
Subroutine icontext: not called CC=1 SCAR=6.9
Pod documented
659 0 ▶sub description { return $_[0]->get('description', @_[1..$#_]); }
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
660  
661  
662  
663 #@returns File::Information
664 10 ▶sub instance {
Subroutine instance: called CC=1 SCAR=0.0
Pod documented
665 10 my ($self) = @_;
666 10 return $self->{instance};
667 }
668  
669  
670 0 ▶sub store {
Subroutine store: not called CC=5 SCAR=34.0
Pod documented
671 0 my ($self, %opts) = @_;
672 0 my $as = delete $opts{as};
673 0 my %stores; # simple deduplication.
674  
675 0 ▶ croak 'Invalid as parameter' unless ($as // '') eq 'File::FStore';
Branch: 1 branch
BranchTrueFalseTotal
unless ($as // "") eq "File::FStore" 0 0 0
Condition0%0/2
$as // ""
l!l
00
MC/DC0%0/1
$as // ""
$as
Truth table0%0/2
A
A= $as
Aresult
11
00
676 0 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 0 0
677  
678 0 foreach my $store ($self->get('store_file', list => 1, default => [])) {
679 0 $stores{$store} = $store;
680 }
681  
682 0 return values %stores;
683 }
684  
685  
686 #@returns Data::URIID
687 0 ▶sub extractor {
Subroutine extractor: not called CC=2 SCAR=17.9
Pod documented
688 0 my ($self, @args) = @_;
689 0 ▶ return $self->{extractor} //= $self->instance->extractor(@args);
Condition0%0/3
$self->{"extractor"} //= $self->instance->extractor(@args)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"extractor"} //= $self->instance->extractor(@args)
$self->{"extractor"} $self->instance->extractor(@args)
Truth table0%0/3
A //= B
A= $self->{"extractor"}B= $self->instance->extractor(@args)
ABresult
1X1
011
000
690 }
691  
692 #@returns Data::TagDB
693 0 ▶sub db {
Subroutine db: not called CC=2 SCAR=17.9
Pod documented
694 0 my ($self, @args) = @_;
695 0 ▶ return $self->{db} //= $self->instance->db(@args);
Condition0%0/3
$self->{"db"} //= $self->instance->db(@args)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"db"} //= $self->instance->db(@args)
$self->{"db"} $self->instance->db(@args)
Truth table0%0/3
A //= B
A= $self->{"db"}B= $self->instance->db(@args)
ABresult
1X1
011
000
696 }
697  
698 0 ▶sub digest_info {
Subroutine digest_info: not called CC=1 SCAR=6.9
Pod undocumented
699 0 my ($self, @args) = @_;
700 0 return $self->instance->digest_info(@args);
701 }
702  
703 #@returns File::Information::Editor
704 0 ▶sub editor {
Subroutine editor: not called CC=1 SCAR=6.9
Pod undocumented
705 0 my ($self) = @_;
706 0 require File::Information::Editor;
707 0 return File::Information::Editor->_new(parent => $self);
708 }
709  
710 # ----------------
711 #@returns File::Information::Inode
712 0 ▶sub inode {
Subroutine inode: not called CC=3 SCAR=24.8
Pod undocumented
713 # TODO: Consider this for the public API.
714 0 my ($self) = @_;
715  
716 0 ▶ return $self if $self->isa('File::Information::Inode');
Branch: 1 branch
BranchTrueFalseTotal
if $self->isa("File::Information::Inode") 0 0 0
717  
718 0 ▶ if (defined(my $inode = eval {$self->parent->inode})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $inode = eval { do { $self->parent->inode } })) 0 0 0
719 0 return $inode;
720 }
721  
722 0 croak 'Invalid request: No inode for this object';
723 }
724  
725 0 ▶sub peek {
Subroutine peek: not called CC=2 SCAR=17.9
Pod undocumented
726 # TODO: Consider this for the public API.
727 0 my ($self, %opts) = @_;
728 0 my $res;
729  
730 0 ▶ if (defined($res = eval { $self->parent->peek(%opts) })) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($res = eval { do { $self->parent->peek(%opts) } })) 0 0 0
731 0 return $res;
732 }
733  
734 0 return $self->inode->peek(%opts);
735 }
736  
737 0 ▶sub _to_di {
Subroutine _to_di: not called CC=2 SCAR=17.9
738 0 my ($uuid) = @_;
739 0 state $cache = {};
740  
741 0 ▶ return $cache->{$uuid} //= Data::Identifier->new(uuid => $uuid);
Condition0%0/3
$cache->{$uuid} //= "Data::Identifier"->new("uuid", $uuid)
l!l&&r!l&&!r
000
MC/DC0%0/2
$cache->{$uuid} //= "Data::Identifier"->new("uuid", $uuid)
$cache->{$uuid} "Data::Identifier"->new("uuid", $uuid)
Truth table0%0/3
A //= B
A= $cache->{$uuid}B= "Data::Identifier"->new("uuid", $uuid)
ABresult
1X1
011
000
742 }
743  
744 0 ▶sub _set_digest_utag {
Subroutine _set_digest_utag: not called CC=12 SCAR=50.5
745 0 my ($self, $lifecycle, $v, $given_size) = @_;
746 0 my %digest;
747  
748 0 eval {
749 0 ▶ while ($v =~ s/^(v0m?) ([a-z]+)-([0-9]+)-([0-9]+) bytes 0-([0-9]+)\/([0-9]+) ([0-9a-f]+)( |$)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ s[^(v0m?) ([a-z]+)-([0-9]+)-([0-9]+) bytes 0-([0-9]+)/([0-9]+) ([0-9a-f]+)( |$)][]u) 0 0 0
750 0 my ($type, $name, $version, $bits, $end, $size, $hash, $mark) = ($1, $2, $3, $4, $5, $6, $7, $8);
751 0 ▶ next if $end != ($size - 1);
Branch: 1 branch
BranchTrueFalseTotal
if $end != $size - 1 0 0 0
752 0 ▶ die if (length($hash) * 4) != $bits;
Branch: 1 branch
BranchTrueFalseTotal
if length($hash) * 4 != $bits 0 0 0
753 0 ▶ die if $type eq 'v0' && length($mark);
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "v0" and length $mark 0 0 0
Condition0%0/3
$type eq "v0" and length $mark
!ll&&!rl&&r
000
MC/DC0%0/2
$type eq "v0" and length $mark
$type eq "v0" length $mark
Truth table0%0/3
A and B
A= $type eq "v0"B= length $mark
ABresult
0X0
100
111
754  
755 0 ▶ $given_size //= $size;
Condition0%0/3
$given_size //= $size
l!l&&r!l&&!r
000
MC/DC0%0/2
$given_size //= $size
$given_size $size
Truth table0%0/3
A //= B
A= $given_sizeB= $size
ABresult
1X1
011
000
756 0 ▶ die unless $given_size == $size;
Branch: 1 branch
BranchTrueFalseTotal
unless $given_size == $size 0 0 0
757 0 $digest{join('-', $name, $version, $bits)} = $hash;
758 }
759 };
760  
761 0 ▶ $self->{digest} //= {};
Condition0%0/2
$self->{"digest"} //= {}
l!l
00
MC/DC0%0/1
$self->{"digest"} //= {}
$self->{"digest"}
Truth table0%0/2
A
A= $self->{"digest"}
Aresult
11
00
762  
763 {
764 0 ▶ my $digests = $self->{digest}{$lifecycle} //= {};
Condition0%0/2
$self->{"digest"}{$lifecycle} //= {}
l!l
00
MC/DC0%0/1
$self->{"digest"}{$lifecycle} //= {}
$self->{"digest"}{$lifecycle}
Truth table0%0/2
A
A= $self->{"digest"}{$lifecycle}
Aresult
11
00
765 0 foreach my $algo (keys %digest) {
766 0 ▶ $digests->{$algo} //= $digest{$algo};
Condition0%0/3
$digests->{$algo} //= $digest{$algo}
l!l&&r!l&&!r
000
MC/DC0%0/2
$digests->{$algo} //= $digest{$algo}
$digests->{$algo} $digest{$algo}
Truth table0%0/3
A //= B
A= $digests->{$algo}B= $digest{$algo}
ABresult
1X1
011
000
767 }
768 }
769  
770 0 return $given_size;
771 }
772  
773 8 ▶sub _load_aggregate {
Subroutine _load_aggregate: called CC=34 SCAR=61.5
774 8 my ($self, $key, %opts) = @_;
775 8 ▶ my $pv = ($self->{properties_values} //= {})->{$opts{lifecycle}} //= {};
Condition50%2/4
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}} //= {}
l!l
80
$self->{"properties_values"} //= {}
l!l
80
MC/DC0%0/1
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}} //= {}
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table50%1/2
A
A= ($self->{"properties_values"} //= {})->{$opts{"lifecycle"}}
Aresult
11
00
Truth table50%1/2
A
A= $self->{"properties_values"}
Aresult
11
00
776 8 my $info = $_properties{$key};
777 8 my $current = $self;
778  
779 8 ▶ return unless defined($info) && defined($info->{sources});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $info and defined $info->{"sources"} 0 8 8
Condition33%1/3
defined $info and defined $info->{"sources"}
!ll&&!rl&&r
008
MC/DC0%0/2
defined $info and defined $info->{"sources"}
defined $info defined $info->{"sources"}
Truth table33%1/3
A and B
A= defined $infoB= defined $info->{"sources"}
ABresult
0X0
100
111
780  
781 8 foreach my $source (@{$info->{sources}}) {
782 40 ▶ if ($source eq ':self') {
Branch: 4 branches
BranchTrueFalseTotal
if ($source eq ':self') { } 0 40 40
elsif ($source =~ /^::/u) { } 16 24 40
elsif (not defined $current) { } 0 24 24
elsif ($source =~ /^([a-z]+)\((.+)\)$/u) { } 0 24 24
783 0 $current = $self;
784 } elsif ($source =~ /^::/) {
785 16 $current = undef;
786  
787 16 ▶ if ($self->isa('File::Information'.$source)) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->isa('File::Information' . $source)) { } 12 4 16
elsif ($source eq '::Inode') { } 4 0 4
elsif ($source eq '::Filesystem') { } 0 0 0
elsif ($source eq '::Deep') { } 0 0 0
788 12 $current = $self;
789 } elsif ($source eq '::Inode') {
790 4 $current = eval{$self->inode};
791 } elsif ($source eq '::Filesystem') {
792 0 $current = eval{$self->filesystem};
793 } elsif ($source eq '::Deep') {
794 0 $current = eval{$self->deep(no_defaults => 1, default => undef)};
795 }
796 } elsif (!defined $current) {
797 0 next;
798 } elsif ($source =~ /^([a-z]+)\((.+)\)$/) {
799 0 my $func = $1;
800 0 ▶ my $re = $_ise_re{$func} // croak 'BUG';
Condition0%0/2
$_ise_re{$func} // croak("BUG")
l!l
00
MC/DC0%0/1
$_ise_re{$func} // croak("BUG")
$_ise_re{$func}
Truth table0%0/2
A
A= $_ise_re{$func}
Aresult
11
00
801 0 my $value = $current->get($2, %opts, default => undef, as => 'raw');
802  
803 0 ▶ if (defined($value) && eval {$value->isa('Data::TagDB::Tag')}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value and eval { do { $value->isa("Data::TagDB::Tag") } }) 0 0 0
Condition0%0/3
defined $value and eval { do { $value->isa("Data::TagDB::Tag") } }
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value and eval { do { $value->isa("Data::TagDB::Tag") } }
defined $value eval { do { $value->isa("Data::TagDB::Tag") } }
Truth table0%0/3
A and B
A= defined $valueB= eval { do { $value->isa("Data::TagDB::Tag") } }
ABresult
0X0
100
111
804 0 ▶ if (defined(my $c = $value->can($func))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $c = $value->can($func))) 0 0 0
805 0 $value = $value->$c(no_defaults => 1, default => undef);
806 }
807 }
808  
809 0 ▶ if (defined($value) && !ref($value) && $value =~ $re) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value and not ref $value and $value =~ /$re/u) 0 0 0
Condition0%0/6
defined $value and not ref $value and $value =~ /$re/u
!ll&&!rl&&r
000
defined $value and not ref $value
!ll&&!rl&&r
000
MC/DC0%0/3
defined $value and not ref $value and $value =~ /$re/u
defined $value not ref $value $value =~ /$re/u
Truth table0%0/4
A and not(B) and C
A= defined $valueB= not ref $valueC= $value =~ /$re/u
ABCresult
0XX0
10X0
1100
1111
810 0 ▶ if (defined($pv->{$key}) && defined($info->{towards})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pv->{$key} and defined $info->{"towards"}) 0 0 0
Condition0%0/3
defined $pv->{$key} and defined $info->{"towards"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $pv->{$key} and defined $info->{"towards"}
defined $pv->{$key} defined $info->{"towards"}
Truth table0%0/3
A and B
A= defined $pv->{$key}B= defined $info->{"towards"}
ABresult
0X0
100
111
811 0 ▶ next if ($value xor $info->{towards});
Branch: 1 branch
BranchTrueFalseTotal
if $value xor $info->{"towards"} 0 0 0
Condition0%0/4
$value xor $info->{"towards"}
l&&rl&&!r!l&&r!l&&!r
0000
MC/DC0%0/2
$value xor $info->{"towards"}
$value $info->{"towards"}
Truth table0%0/4
A xor B
A= $valueB= $info->{"towards"}
ABresult
110
101
011
000
812 }
813  
814 0 $pv->{$key} = {raw => $value};
815 }
816 } else {
817 24 my $value_ref;
818  
819 #warn sprintf('%s <- %s %s %s', $key, $current, $source, $opts{lifecycle});
820 24 ▶ next unless defined $current->get($source, %opts, default => undef, as => 'raw');
Branch: 1 branch
BranchTrueFalseTotal
unless defined $current->get($source, %opts, "default", undef, "as", "raw") 24 0 24
821  
822 0 $value_ref = eval {$current->{properties_values}{$opts{lifecycle}}{$source}};
823  
824 0 ▶ if (defined($value_ref) && defined($pv->{$key}) && defined($info->{towards})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value_ref and defined $pv->{$key} and defined $info->{"towards"}) 0 0 0
Condition0%0/6
defined $value_ref and defined $pv->{$key} and defined $info->{"towards"}
!ll&&!rl&&r
000
defined $value_ref and defined $pv->{$key}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $value_ref and defined $pv->{$key} and defined $info->{"towards"}
defined $value_ref defined $pv->{$key} defined $info->{"towards"}
Truth table0%0/4
A and B and C
A= defined $value_refB= defined $pv->{$key}C= defined $info->{"towards"}
ABCresult
0XX0
10X0
1100
1111
825 0 ▶ next if ($value_ref->{raw} xor $info->{towards});
Branch: 1 branch
BranchTrueFalseTotal
if $value_ref->{"raw"} xor $info->{"towards"} 0 0 0
Condition0%0/4
$value_ref->{"raw"} xor $info->{"towards"}
l&&rl&&!r!l&&r!l&&!r
0000
MC/DC0%0/2
$value_ref->{"raw"} xor $info->{"towards"}
$value_ref->{"raw"} $info->{"towards"}
Truth table0%0/4
A xor B
A= $value_ref->{"raw"}B= $info->{"towards"}
ABresult
110
101
011
000
826 }
827  
828 0 $pv->{$key} = $value_ref;
829 }
830  
831 0 ▶ last if !defined($info->{towards}) && defined($pv->{$key}) && scalar(keys %{$pv->{$key}});
Branch: 1 branch
BranchTrueFalseTotal
if not defined $info->{"towards"} and defined $pv->{$key} and scalar keys %{$$pv{$key};} 0 16 16
Condition40%2/5
not defined $info->{"towards"} and defined $pv->{$key} and scalar keys %{$$pv{$key};}
!ll
160
not defined $info->{"towards"} and defined $pv->{$key}
!ll&&!rl&&r
0160
MC/DC0%0/2
not defined $info->{"towards"} and defined $pv->{$key} and scalar keys %{$$pv{$key};}
not defined $info->{"towards"} defined $pv->{$key}
Truth table33%1/3
not(A) and B
A= not defined $info->{"towards"}B= defined $pv->{$key}
ABresult
0X0
100
111
832 }
833 }
834  
835 4 ▶sub _load_readonly {
Subroutine _load_readonly: called CC=15 SCAR=34.9
836 4 my ($self, $key, %opts) = @_;
837 4 ▶ my $pv = ($self->{properties_values} //= {})->{$opts{lifecycle}} //= {};
Condition50%2/4
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}} //= {}
l!l
40
$self->{"properties_values"} //= {}
l!l
40
MC/DC0%0/1
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}} //= {}
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table50%1/2
A
A= ($self->{"properties_values"} //= {})->{$opts{"lifecycle"}}
Aresult
11
00
Truth table50%1/2
A
A= $self->{"properties_values"}
Aresult
11
00
838 4 my $info = $_properties{$key};
839 4 ▶ my $inode = eval {$self->isa('File::Information::Inode') ? $self : $self->inode};
Branch: 1 branch
BranchTrueFalseTotal
$self->isa('File::Information::Inode') ? : 2 2 4
840 4 my $v = $opts{lifecycle} eq 'final';
841  
842 4 ▶ return unless defined($info);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $info 0 4 4
843  
844 4 ▶ if (defined $inode) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $inode) 4 0 4
845 4 ▶ $v ||= $inode->get('stat_readonly', %opts, default => undef, as => 'raw');
Condition33%1/3
$v ||= $inode->get("stat_readonly", %opts, "default", undef, "as", "raw")
l!l&&r!l&&!r
004
MC/DC0%0/2
$v ||= $inode->get("stat_readonly", %opts, "default", undef, "as", "raw")
$v $inode->get("stat_readonly", %opts, "default", undef, "as", "raw")
Truth table33%1/3
A ||= B
A= $vB= $inode->get("stat_readonly", %opts, "default", undef, "as", "raw")
ABresult
1X1
011
000
846 4 ▶ $v ||= $inode->get('ntfs_file_attribute_readonly', %opts, default => undef, as => 'raw');
Condition33%1/3
$v ||= $inode->get("ntfs_file_attribute_readonly", %opts, "default", undef, "as", "raw")
l!l&&r!l&&!r
004
MC/DC0%0/2
$v ||= $inode->get("ntfs_file_attribute_readonly", %opts, "default", undef, "as", "raw")
$v $inode->get("ntfs_file_attribute_readonly", %opts, "default", undef, "as", "raw")
Truth table33%1/3
A ||= B
A= $vB= $inode->get("ntfs_file_attribute_readonly", %opts, "default", undef, "as", "raw")
ABresult
1X1
011
000
847 }
848  
849 4 ▶ $v ||= $self->get('writemode', %opts, default => '', as => 'uuid') eq WK_WM_NONE;
Condition33%1/3
$v ||= $self->get("writemode", %opts, "default", "", "as", "uuid") eq "7b177183-083c-4387-abd3-8793eb647373"
l!l&&r!l&&!r
004
MC/DC0%0/2
$v ||= $self->get("writemode", %opts, "default", "", "as", "uuid") eq "7b177183-083c-4387-abd3-8793eb647373"
$v $self->get("writemode", %opts, "default", "", "as", "uuid") eq "7b177183-083c-4387-abd3-8793eb647373"
Truth table33%1/3
A ||= B
A= $vB= $self->get("writemode", %opts, "default", "", "as", "uuid") eq "7b177183-083c-4387-abd3-8793eb647373"
ABresult
1X1
011
000
850 4 ▶ $v ||= $self->get('finalmode', %opts, default => '', as => 'uuid') eq WK_FINAL;
Condition33%1/3
$v ||= $self->get("finalmode", %opts, "default", "", "as", "uuid") eq "f418cdb9-64a7-4f15-9a18-63f7755c5b47"
l!l&&r!l&&!r
004
MC/DC0%0/2
$v ||= $self->get("finalmode", %opts, "default", "", "as", "uuid") eq "f418cdb9-64a7-4f15-9a18-63f7755c5b47"
$v $self->get("finalmode", %opts, "default", "", "as", "uuid") eq "f418cdb9-64a7-4f15-9a18-63f7755c5b47"
Truth table33%1/3
A ||= B
A= $vB= $self->get("finalmode", %opts, "default", "", "as", "uuid") eq "f418cdb9-64a7-4f15-9a18-63f7755c5b47"
ABresult
1X1
011
000
851  
852 # Mount options:
853 4 ▶ unless ($v) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v) 4 0 4
854 4 foreach my $option (qw(linux_mount_options linux_superblock_options)) {
855 8 ▶ my $value = $self->get($option, %opts, default => undef, as => 'raw') // next;
Condition50%1/2
$self->get($option, %opts, "default", undef, "as", "raw") // (next)
l!l
08
MC/DC0%0/1
$self->get($option, %opts, "default", undef, "as", "raw") // (next)
$self->get($option, %opts, "default", undef, "as", "raw")
Truth table50%1/2
A
A= $self->get($option, %opts, "default", undef, "as", "raw")
Aresult
11
00
856 0 ▶ $v ||= $value =~ /^ro(?:,.+)?$/ || $value =~ /,ro$/;
Condition0%0/6
$v ||= $value =~ /^ro(?:,.+)?$/u || $value =~ /,ro$/u
l!l&&r!l&&!r
000
$value =~ /^ro(?:,.+)?$/u || $value =~ /,ro$/u
l!l&&r!l&&!r
000
MC/DC0%0/3
$v ||= $value =~ /^ro(?:,.+)?$/u || $value =~ /,ro$/u
$v $value =~ /^ro(?:,.+)?$/u $value =~ /,ro$/u
Truth table0%0/4
A ||= B || C
A= $vB= $value =~ /^ro(?:,.+)?$/uC= $value =~ /,ro$/u
ABCresult
1XX1
01X1
0011
0000
857 }
858 }
859  
860 4 $pv->{$key} = {raw => $v};
861 }
862  
863 0 ▶sub _load_size_boring {
Subroutine _load_size_boring: not called CC=4 SCAR=30.0
864 0 my ($self, $key, %opts) = @_;
865 0 ▶ my $pv = ($self->{properties_values} //= {})->{$opts{lifecycle}} //= {};
Condition0%0/4
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}} //= {}
l!l
00
$self->{"properties_values"} //= {}
l!l
00
MC/DC0%0/1
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}} //= {}
($self->{"properties_values"} //= {})->{$opts{"lifecycle"}}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table0%0/2
A
A= ($self->{"properties_values"} //= {})->{$opts{"lifecycle"}}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"properties_values"}
Aresult
11
00
866 0 my $size;
867  
868 0 $size = $self->get('size', %opts, default => undef, as => 'raw');
869 0 ▶ return unless defined $size;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $size 0 0 0
870 0 $pv->{size_boring} = {raw => $size < $self->instance->{boring_sizelimit}};
871 }
872  
873 0 ▶sub _load_data_tagdb {
Subroutine _load_data_tagdb: not called CC=27 SCAR=66.3
874 0 my ($self) = @_;
875 0 ▶ my $pv_current = ($self->{properties_values} //= {})->{current} //= {};
Condition0%0/4
+($self->{"properties_values"} //= {})->{"current"} //= {}
l!l
00
$self->{"properties_values"} //= {}
l!l
00
MC/DC0%0/1
+($self->{"properties_values"} //= {})->{"current"} //= {}
+($self->{"properties_values"} //= {})->{"current"}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table0%0/2
A
A= +($self->{"properties_values"} //= {})->{"current"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"properties_values"}
Aresult
11
00
876 0 ▶ my $pv_final = ($self->{properties_values} //= {})->{final} //= {};
Condition0%0/4
+($self->{"properties_values"} //= {})->{"final"} //= {}
l!l
00
$self->{"properties_values"} //= {}
l!l
00
MC/DC0%0/1
+($self->{"properties_values"} //= {})->{"final"} //= {}
+($self->{"properties_values"} //= {})->{"final"}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table0%0/2
A
A= +($self->{"properties_values"} //= {})->{"final"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"properties_values"}
Aresult
11
00
877  
878 0 ▶ return if $self->{_loaded_data_tagdb};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_loaded_data_tagdb"} 0 0 0
879 0 $self->{_loaded_data_tagdb} = 1;
880  
881 0 ▶ if (defined(my $db = eval {$self->db})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $db = eval { do { $self->db } })) 0 0 0
882 0 my $wk = $db->wk;
883 0 my %tags;
884 0 my %final_metadata = (
885 data_tagdb_size => $wk->final_file_size,
886 data_tagdb_fetch_uri => $db->tag_by_id(uuid => '96674c6c-cf5e-40cd-af1e-63b86e741f4f'),
887 );
888 0 my %final_relation = (
889 data_tagdb_encoding => $wk->final_file_encoding,
890 data_tagdb_charset => $db->tag_by_id(uuid => '99437f71-f1b5-4a50-8ecf-882b61b86b1e'),
891 );
892  
893 0 foreach my $key (qw(data_uriid_result contentise inodeise ise)) {
894 0 ▶ my $tag = $self->get($key, as => 'Data::TagDB::Tag', default => undef) // next;
Condition0%0/2
$self->get($key, "as", "Data::TagDB::Tag", "default", undef) // (next)
l!l
00
MC/DC0%0/1
$self->get($key, "as", "Data::TagDB::Tag", "default", undef) // (next)
$self->get($key, "as", "Data::TagDB::Tag", "default", undef)
Truth table0%0/2
A
A= $self->get($key, "as", "Data::TagDB::Tag", "default", undef)
Aresult
11
00
895 0 $tags{$tag->dbid} = $tag;
896 }
897  
898 0 foreach my $tag (values %tags) {
899 0 my $given_size;
900  
901 0 ▶ if (defined(my $displayname = $tag->displayname(default => undef, no_defaults => 1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $displayname = $tag->displayname("default", undef, "no_defaults", 1))) 0 0 0
902 0 ▶ my $l = $pv_current->{data_tagdb_displayname} //= [];
Condition0%0/2
$pv_current->{"data_tagdb_displayname"} //= []
l!l
00
MC/DC0%0/1
$pv_current->{"data_tagdb_displayname"} //= []
$pv_current->{"data_tagdb_displayname"}
Truth table0%0/2
A
A= $pv_current->{"data_tagdb_displayname"}
Aresult
11
00
903 0 push(@{$l}, {raw => $displayname});
904 }
905  
906 0 foreach my $key (keys %final_metadata) {
907 0 ▶ my $relation = $final_metadata{$key} // next;
Condition0%0/2
$final_metadata{$key} // (next)
l!l
00
MC/DC0%0/1
$final_metadata{$key} // (next)
$final_metadata{$key}
Truth table0%0/2
A
A= $final_metadata{$key}
Aresult
11
00
908 0 ▶ $db->metadata(tag => $tag, relation => $relation)->foreach(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
909 0 my ($entry) = @_;
910 0 ▶ my $l = $pv_final->{$key} //= [];
Condition0%0/2
$pv_final->{$key} //= []
l!l
00
MC/DC0%0/1
$pv_final->{$key} //= []
$pv_final->{$key}
Truth table0%0/2
A
A= $pv_final->{$key}
Aresult
11
00
911 0 push(@{$l}, {raw => $entry->data_raw});
912 0 });
913 }
914  
915 0 foreach my $key (keys %final_relation) {
916 0 ▶ my $relation = $final_relation{$key} // next;
Condition0%0/2
$final_relation{$key} // (next)
l!l
00
MC/DC0%0/1
$final_relation{$key} // (next)
$final_relation{$key}
Truth table0%0/2
A
A= $final_relation{$key}
Aresult
11
00
917 0 ▶ $db->relation(tag => $tag, relation => $relation)->foreach(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
918 0 my ($entry) = @_;
919 0 ▶ my $l = $pv_final->{$key} //= [];
Condition0%0/2
$pv_final->{$key} //= []
l!l
00
MC/DC0%0/1
$pv_final->{$key} //= []
$pv_final->{$key}
Truth table0%0/2
A
A= $pv_final->{$key}
Aresult
11
00
920 0 push(@{$l}, {raw => $entry->related, rawtype => 'Data::TagDB::Tag'});
921 0 });
922 }
923  
924 0 ▶ if (defined(my $relation = $wk->final_file_hash)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $relation = $wk->final_file_hash)) 0 0 0
925 0 ▶ $db->metadata(tag => $tag, relation => $relation)->foreach(sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
926 0 my ($entry) = @_;
927 0 $given_size = $self->_set_digest_utag(final => $entry->data_raw, $given_size);
928 0 });
929 }
930  
931 0 ▶ push(@{$pv_final->{data_tagdb_size} //= []}, {raw => $given_size}) if defined $given_size;
Branch: 1 branch
BranchTrueFalseTotal
if defined $given_size 0 0 0
Condition0%0/2
$pv_final->{"data_tagdb_size"} //= []
l!l
00
MC/DC0%0/1
$pv_final->{"data_tagdb_size"} //= []
$pv_final->{"data_tagdb_size"}
Truth table0%0/2
A
A= $pv_final->{"data_tagdb_size"}
Aresult
11
00
932  
933 {
934 0 my @size_values = map {int($_->{raw})} @{$pv_final->{data_tagdb_size}};
935 0 ▶ if (scalar @size_values) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @size_values) 0 0 0
936 0 ▶ $given_size //= $size_values[0];
Condition0%0/3
$given_size //= $size_values[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$given_size //= $size_values[0]
$given_size $size_values[0]
Truth table0%0/3
A //= B
A= $given_sizeB= $size_values[0]
ABresult
1X1
011
000
937 0 foreach my $size (@size_values) {
938 0 ▶ if ($given_size != $size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($given_size != $size) 0 0 0
939 0 $given_size = undef;
940 0 last;
941 }
942 }
943 0 ▶ $pv_final->{data_tagdb_size} = defined($given_size) ? {raw => $given_size} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $given_size ? : 0 0 0
944 }
945 }
946  
947 0 foreach my $key (keys(%final_metadata), keys(%final_relation)) {
948 0 ▶ if (ref($pv_final->{$key}) eq 'ARRAY' && scalar(@{$pv_final->{$key}}) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $pv_final->{$key} eq "ARRAY" and scalar @{$pv_final->{$key};} == 1) 0 0 0
Condition0%0/3
ref $pv_final->{$key} eq "ARRAY" and scalar @{$pv_final->{$key};} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
ref $pv_final->{$key} eq "ARRAY" and scalar @{$pv_final->{$key};} == 1
ref $pv_final->{$key} eq "ARRAY" scalar @{$pv_final->{$key};} == 1
Truth table0%0/3
A and B
A= ref $pv_final->{$key} eq "ARRAY"B= scalar @{$pv_final->{$key};} == 1
ABresult
0X0
100
111
949 0 $pv_final->{$key} = $pv_final->{$key}->[0];
950 }
951 }
952 }
953 }
954 }
955  
956 8 ▶sub _load_fstore {
Subroutine _load_fstore: called CC=27 SCAR=57.7
957 8 my ($self, $key, %opts) = @_;
958  
959 8 ▶ return if $self->{_loaded_fstore_base};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_loaded_fstore_base"} 4 4 8
960 4 $self->{_loaded_fstore_base} = 1;
961  
962 {
963 4 ▶ my $pv_current = ($self->{properties_values} //= {})->{current} //= {};
Condition50%2/4
+($self->{"properties_values"} //= {})->{"current"} //= {}
l!l
40
$self->{"properties_values"} //= {}
l!l
40
MC/DC0%0/1
+($self->{"properties_values"} //= {})->{"current"} //= {}
+($self->{"properties_values"} //= {})->{"current"}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table50%1/2
A
A= +($self->{"properties_values"} //= {})->{"current"}
Aresult
11
00
Truth table50%1/2
A
A= $self->{"properties_values"}
Aresult
11
00
964 4 ▶ my $pv_final = ($self->{properties_values} //= {})->{final} //= {};
Condition50%2/4
+($self->{"properties_values"} //= {})->{"final"} //= {}
l!l
04
$self->{"properties_values"} //= {}
l!l
40
MC/DC0%0/1
+($self->{"properties_values"} //= {})->{"final"} //= {}
+($self->{"properties_values"} //= {})->{"final"}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table50%1/2
A
A= +($self->{"properties_values"} //= {})->{"final"}
Aresult
11
00
Truth table50%1/2
A
A= $self->{"properties_values"}
Aresult
11
00
965 4 ▶ my $digest_final = $self->{digest}{final} //= {};
Condition50%1/2
$self->{"digest"}{"final"} //= {}
l!l
04
MC/DC0%0/1
$self->{"digest"}{"final"} //= {}
$self->{"digest"}{"final"}
Truth table50%1/2
A
A= $self->{"digest"}{"final"}
Aresult
11
00
966  
967 4 foreach my $candidate ($self->get('store_file', list => 1, default => [])) {
968 0 my $properties = $candidate->get('properties');
969 0 my $digests = $candidate->get('digests');
970  
971 0 ▶ push(@{$pv_final->{store_size} //=[]}, {raw => $properties->{size}}) if defined $properties->{size};
Branch: 1 branch
BranchTrueFalseTotal
if defined $properties->{"size"} 0 0 0
Condition0%0/2
$pv_final->{"store_size"} //= []
l!l
00
MC/DC0%0/1
$pv_final->{"store_size"} //= []
$pv_final->{"store_size"}
Truth table0%0/2
A
A= $pv_final->{"store_size"}
Aresult
11
00
972 0 ▶ push(@{$pv_final->{store_inode} //=[]}, {raw => $properties->{inode}}) if defined $properties->{inode};
Branch: 1 branch
BranchTrueFalseTotal
if defined $properties->{"inode"} 0 0 0
Condition0%0/2
$pv_final->{"store_inode"} //= []
l!l
00
MC/DC0%0/1
$pv_final->{"store_inode"} //= []
$pv_final->{"store_inode"}
Truth table0%0/2
A
A= $pv_final->{"store_inode"}
Aresult
11
00
973 0 ▶ push(@{$pv_final->{store_mediasubtype} //=[]}, {raw => $properties->{mediasubtype}}) if defined $properties->{mediasubtype};
Branch: 1 branch
BranchTrueFalseTotal
if defined $properties->{"mediasubtype"} 0 0 0
Condition0%0/2
$pv_final->{"store_mediasubtype"} //= []
l!l
00
MC/DC0%0/1
$pv_final->{"store_mediasubtype"} //= []
$pv_final->{"store_mediasubtype"}
Truth table0%0/2
A
A= $pv_final->{"store_mediasubtype"}
Aresult
11
00
974 0 ▶ push(@{$pv_final->{store_contentise} //=[]}, {raw => $properties->{contentise}}) if defined $properties->{contentise};
Branch: 1 branch
BranchTrueFalseTotal
if defined $properties->{"contentise"} 0 0 0
Condition0%0/2
$pv_final->{"store_contentise"} //= []
l!l
00
MC/DC0%0/1
$pv_final->{"store_contentise"} //= []
$pv_final->{"store_contentise"}
Truth table0%0/2
A
A= $pv_final->{"store_contentise"}
Aresult
11
00
975 0 ▶ push(@{$pv_final->{store_inodeise} //=[]}, {raw => $properties->{inodeise}}) if defined $properties->{inodeise};
Branch: 1 branch
BranchTrueFalseTotal
if defined $properties->{"inodeise"} 0 0 0
Condition0%0/2
$pv_final->{"store_inodeise"} //= []
l!l
00
MC/DC0%0/1
$pv_final->{"store_inodeise"} //= []
$pv_final->{"store_inodeise"}
Truth table0%0/2
A
A= $pv_final->{"store_inodeise"}
Aresult
11
00
976  
977 0 ▶ push(@{$pv_final->{store_final} //=[]}, {raw => 1});
Condition0%0/2
$pv_final->{"store_final"} //= []
l!l
00
MC/DC0%0/1
$pv_final->{"store_final"} //= []
$pv_final->{"store_final"}
Truth table0%0/2
A
A= $pv_final->{"store_final"}
Aresult
11
00
978  
979 0 foreach my $algo (keys %{$digests}) {
980 0 $digest_final->{$algo} = $digests->{$algo};
981 }
982 }
983  
984 4 foreach my $key (qw(store_size store_inode store_mediasubtype store_contentise store_inodeise store_final store_finalmode store_writemode)) {
985 32 ▶ if (defined(my $v = $pv_final->{$key})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $v = $pv_final->{$key})) 0 32 32
986 0 ▶ if (scalar(@{$v}) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$v;} > 1) 0 0 0
987 0 my %values = map {$_->{raw} => $_->{raw}} @{$v};
988 0 $v = [map {{raw => $_}} values %values];
989 }
990  
991 0 ▶ if (scalar(@{$v}) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$v;} == 1) 0 0 0
992 0 $v = $v->[0];
993 0 $pv_final->{$key} = $v;
994 }
995 }
996 }
997  
998 4 ▶ if (defined($pv_final->{store_final}) && $pv_final->{store_final}{raw}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pv_final->{"store_final"} and $pv_final->{"store_final"}{"raw"}) 0 4 4
Condition33%1/3
defined $pv_final->{"store_final"} and $pv_final->{"store_final"}{"raw"}
!ll&&!rl&&r
400
MC/DC0%0/2
defined $pv_final->{"store_final"} and $pv_final->{"store_final"}{"raw"}
defined $pv_final->{"store_final"} $pv_final->{"store_final"}{"raw"}
Truth table33%1/3
A and B
A= defined $pv_final->{"store_final"}B= $pv_final->{"store_final"}{"raw"}
ABresult
0X0
100
111
999 0 $pv_final->{store_finalmode} = {raw => WK_FINAL};
1000 0 $pv_final->{store_writemode} = {raw => WK_WM_NONE};
1001 }
1002  
1003 4 foreach my $key (qw(store_final store_finalmode store_writemode)) {
1004 12 $pv_current->{$key} = $pv_final->{$key};
1005 }
1006 }
1007 }
1008  
1009 # --- Overrides for Data::Identifier::Interface::Known ---
1010  
1011  
1012 0 ▶sub _known_provider {
Subroutine _known_provider: not called CC=4 SCAR=30.0
1013 0 my ($pkg, $class, %opts) = @_;
1014  
1015 0 ▶ croak 'Unsupported options passed' if scalar(keys %opts);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 0 0
1016  
1017 0 ▶ if ($class eq 'properties_name') {
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq "properties_name") 0 0 0
1018 0 return ([map {$_->{name}} $pkg->property_info], not_identifiers => 1);
1019 }
1020  
1021 0 ▶ if (ref $pkg) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $pkg) { } 0 0 0
1022 0 return $pkg->instance->_known_provider($class, %opts);
1023 } else {
1024 0 return File::Information->_known_provider($class, %opts);
1025 }
1026 }
1027  
1028  
1029 # --- Overrides for Data::Identifier::Interface::Simple ---
1030  
1031 0 ▶sub as {
Subroutine as: not called CC=3 SCAR=24.8
Pod documented
1032 0 my ($self, $as, %opts) = @_;
1033  
1034 0 ▶ if ($as eq 'Data::Identifier' && !scalar keys %opts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($as eq 'Data::Identifier' and not scalar keys %opts) { } 0 0 0
Condition0%0/3
$as eq "Data::Identifier" and not scalar keys %opts
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "Data::Identifier" and not scalar keys %opts
$as eq "Data::Identifier" not scalar keys %opts
Truth table0%0/3
A and not(B)
A= $as eq "Data::Identifier"B= not scalar keys %opts
ABresult
0X0
100
111
1035 0 return Data::Identifier->new(ise => $self->ise);
1036 } else {
1037 0 return Data::Identifier->new(ise => $self->ise)->as($as, %opts);
1038 }
1039 }
1040  
1041 3 1;
1042  
1043 __END__
« lib/File/Information/Link.pm ↑ Summary lib/File/Information/Tagpool.pm »