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