ValueFile.pm

filter: Statementstmt 82.8% 29 / 35 Branchbran 37.5% 3 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 88.8% 8 / 9 Podpod 100% 1 / 1 totaltotal 65.0% 41 / 63 CC 7 SCAR 24.0
CC
7
Cov
65%
add_utf8_marker
30.0
_known_provider
3.0
BEGIN
1.0
CRAP 11.1
« ValueFile/Simple/Writer.pm ↑ Summary
1 # Copyright (c) 2024-2026 Philipp Schafft
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: module for reading and writing ValueFile files
6  
7 package File::ValueFile;
8  
9 4 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Data::Identifier v0.34;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use parent 'Data::Identifier::Interface::Known';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 our $VERSION = v0.11;
18  
19 4 my @wellknown = (
20 Data::Identifier->new(uuid => '54bf8af4-b1d7-44da-af48-5278d11e8f32', displayname => 'ValueFile'),
21 Data::Identifier->new(uuid => 'e5da6a39-46d5-48a9-b174-5c26008e208e', displayname => 'tagpool-source-format'),
22 Data::Identifier->new(uuid => '11431b85-41cd-4be5-8d88-a769ebbd603f', displayname => 'tagpool-directory-info-format'),
23 Data::Identifier->new(uuid => 'afdb46f2-e13f-4419-80d7-c4b956ed85fa', displayname => 'tagpool-taglist-format-v1'),
24 Data::Identifier->new(uuid => '25990339-3913-4b5a-8bcf-5042ef6d8b5e', displayname => 'tagpool-httpd-htdirectories-format'),
25 Data::Identifier->new(uuid => '5a1895b8-61f1-4ce1-a44f-1a239b7d9de7', displayname => 'tagpool-source-format-hybrid'),
26 Data::Identifier->new(uuid => 'f06c2226-b33e-48f2-9085-cd906a3dcee0', displayname => 'tagpool-source-format-modern-limited'),
27 Data::Identifier->new(uuid => '1c71f5b1-216d-4a9b-81a1-54dc22d8a067', displayname => 'tagpool-source-format-modern-full'),
28 Data::Identifier->new(uuid => '7e5d56d4-98e6-4205-89c0-763e1d729531', displayname => 'utf-8-marker'),
29 Data::Identifier->new(uuid => '2ec67bbe-4698-4a0c-921d-1f0951923ee6', displayname => 'dot-repeat-marker'),
30 );
31  
32 4 $_->register foreach @wellknown;
33  
34 my %_is_utf8 = (
35 4 (map {$_ => undef} (
36 'e5da6a39-46d5-48a9-b174-5c26008e208e', # tagpool-source-format
37 '11431b85-41cd-4be5-8d88-a769ebbd603f', # tagpool-directory-info-format
38 '7e5d56d4-98e6-4205-89c0-763e1d729531', # utf-8-marker
39 )),
40 );
41  
42  
43  
44  
45 0 ▶sub add_utf8_marker {
Subroutine add_utf8_marker: not called CC=5 SCAR=34.0
Pod documented
46 0 my ($pkg, $class, $id) = @_;
47  
48 0 ▶ if (!defined($class) || !defined($id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $class and defined $id) 0 0 0
Condition0%0/3
defined $class and defined $id
!ll&&!rl&&r
000
MC/DC0%0/2
defined $class and defined $id
defined $class defined $id
Truth table0%0/3
A and B
A= defined $classB= defined $id
ABresult
0X0
100
111
49 0 croak 'Class or identifier not defined';
50 }
51  
52 0 ▶ if ($class ne 'format' && $class ne 'feature') {
Branch: 1 branch
BranchTrueFalseTotal
if ($class ne "format" and $class ne "feature") 0 0 0
Condition0%0/3
$class ne "format" and $class ne "feature"
!ll&&!rl&&r
000
MC/DC0%0/2
$class ne "format" and $class ne "feature"
$class ne "format" $class ne "feature"
Truth table0%0/3
A and B
A= $class ne "format"B= $class ne "feature"
ABresult
0X0
100
111
53 0 croak 'Class given with an unsupported value: '.$class;
54 }
55  
56 0 $_is_utf8{Data::Identifier->new(from => $id)->ise} = undef;
57 }
58  
59 # ---- Private helpers ----
60  
61 2 ▶sub _is_utf8 {
Subroutine _is_utf8: called CC=1 SCAR=0.0
62 2 my ($pkg, $id) = @_;
63 2 return exists $_is_utf8{Data::Identifier->new(from => $id)->ise};
64 }
65  
66 5 ▶sub _known_provider {
Subroutine _known_provider: called CC=3 SCAR=11.0
67 5 my ($pkg, $class, %opts) = @_;
68 5 ▶ croak 'Unsupported options passed' if scalar(keys %opts);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 5 5
69 5 ▶ return (\@wellknown, rawtype => 'uuid') if $class eq ':all';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq ":all" 4 1 5
70 1 croak 'Unsupported class';
71 }
72  
73 4 1;
74  
75 __END__
« ValueFile/Simple/Writer.pm ↑ Summary