| 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::Simple::Writer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use v5.20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use parent qw(Data::Identifier::Interface::Userdata Data::Identifier::Interface::Subobjects); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use URI::Escape qw(uri_escape uri_escape_utf8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Data::Identifier v0.34; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use File::ValueFile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use constant UTF_8 => Encode::find_encoding('UTF-8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | FORMAT_ISE => '54bf8af4-b1d7-44da-af48-5278d11e8f32', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | SF_ISE => 'e5da6a39-46d5-48a9-b174-5c26008e208e', # tagpool-source-format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | TLv1_ISE => 'afdb46f2-e13f-4419-80d7-c4b956ed85fa', # tagpool-taglist-format-v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | F_M_L_ISE => 'f06c2226-b33e-48f2-9085-cd906a3dcee0', # tagpool-source-format-modern-limited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | F_M_F_ISE => '1c71f5b1-216d-4a9b-81a1-54dc22d8a067', # tagpool-source-format-modern-full | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | DOT_REPEAT_ISE => '2ec67bbe-4698-4a0c-921d-1f0951923ee6', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | my %_default_style = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | generator_hint => 'auto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | tag_relation => 'tag-relation', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | degenerate_generator_hint => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | tag_ise_no_ise_retry => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | tag_ise_no_ise_one => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | tag_ise_no_ise_no_uriid => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | comment_column => 168, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | my %_generator_comments = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | '97b7f241-e1c5-4f02-ae3c-8e31e501e1dc' => 'gregorian-date', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | '7da02209-0cf5-4bd2-9ce9-50bd0b7d76e3' => 'owner', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | '5714e8d8-913a-4193-9de0-eb6ba9e13e1f' => 'favourite', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | '283511f7-1c0d-44d4-abd8-6ed1e1fc5d66' => 'like', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'fd7eb1c9-2840-467c-a77b-afa6f925f0c3' => 'dislike', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'f2bd1194-d658-4741-b1b1-b4cfd0d6ddea' => 'todo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'bd471aca-8b37-483c-8569-a84444b34cfc' => 'background', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'd511f370-0e49-42d5-ad18-bf280dc97e08' => 'body', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'bd1a1966-2e71-43cc-a7ce-f7a4547df450' => 'character', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'f616e3e2-7779-4172-ae26-865b979b4d0c' => 'artist', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'ee60545c-5415-474d-abe9-6de941045460' => 'fertilization', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | '2b85ca08-921c-4683-a102-f18748c88fda' => 'birth', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | '3e1c709e-32bf-4943-a9fa-8c25cb37dc92' => 'death', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | '8b864ce6-e034-432d-8803-c95cd6da53b6' => 'tagcombiner', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my %_old_style_relation = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | '7f265548-81dc-4280-9550-1bd0aa4bf748' => 'tag-type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 'e48cd5c6-83d7-411e-9640-cb370f3502fc' => 'tag-implies', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 'd926eb95-6984-415f-8892-233c13491931' => 'tag-links', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | our $VERSION = v0.11; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=36.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | my ($pkg, $out, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $self = bless \%opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | my $_is_utf8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | my %features; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | if (ref $out) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | $fh = $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | open($fh, '>', $out) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my $style = delete $opts{style}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | $self->{style} = {%_default_style}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | $self->style(%{$style}) if defined $style; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | $self->{fh} = $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | $self->{features} = \%features; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | $self->{escape} = \&uri_escape; # set here, so we can write the markers. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | if (defined $opts{format}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | my $format = $self->{format} = Data::Identifier->new(from => $opts{format}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | $self->_write_marker(required => 'ValueFile', FORMAT_ISE, $format); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | $_is_utf8 ||= File::ValueFile->_is_utf8($format); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_is_utf8 ||= "File::ValueFile"->_is_utf8($format)
MC/DC0%0/2
$_is_utf8 ||= "File::ValueFile"->_is_utf8($format)
$_is_utf8
"File::ValueFile"->_is_utf8($format)
Truth table33%1/3
A ||= B
A= $_is_utf8B= "File::ValueFile"->_is_utf8($format)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | foreach my $type (qw(required copy optional)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | ▶ | my $list = $opts{$type.'_feature'} // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{$type . '_feature'} // (next)
MC/DC0%0/1
$opts{$type . '_feature'} // (next)
$opts{$type . '_feature'}
Truth table50%1/2
A
A= $opts{$type . '_feature'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $list = [$list] unless ref($list) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | foreach my $entry (@{$list}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $feature = Data::Identifier->new(from => $entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | $self->{dot_repreat} ||= $feature->eq(DOT_REPEAT_ISE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"dot_repreat"} ||= $feature->eq("2ec67bbe-4698-4a0c-921d-1f0951923ee6")
MC/DC0%0/2
$self->{"dot_repreat"} ||= $feature->eq("2ec67bbe-4698-4a0c-921d-1f0951923ee6")
$self->{"dot_repreat"}
$feature->eq("2ec67bbe-4698-4a0c-921d-1f0951923ee6")
Truth table0%0/3
A ||= B
A= $self->{"dot_repreat"}B= $feature->eq("2ec67bbe-4698-4a0c-921d-1f0951923ee6")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $self->_write_marker($type, 'Feature', $feature); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | $_is_utf8 ||= File::ValueFile->_is_utf8($feature); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_is_utf8 ||= "File::ValueFile"->_is_utf8($feature)
MC/DC0%0/2
$_is_utf8 ||= "File::ValueFile"->_is_utf8($feature)
$_is_utf8
"File::ValueFile"->_is_utf8($feature)
Truth table0%0/3
A ||= B
A= $_is_utf8B= "File::ValueFile"->_is_utf8($feature)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $features{$feature->ise} = $feature; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | $opts{utf8} //= 'auto'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"utf8"} //= "auto"
MC/DC0%0/1
$opts{"utf8"} //= "auto"
$opts{"utf8"}
Truth table50%1/2
A
A= $opts{"utf8"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | if ($opts{utf8} eq 'auto') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | $opts{utf8} = $_is_utf8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | $self->{escape} = $opts{utf8} ? \&uri_escape_utf8 : \&uri_escape; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub format { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if (defined $self->{format}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return $self->{format}->as($opts{as}, so => $self) if defined $opts{as}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return $self->{format}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return $opts{default} if exists $opts{default}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | croak 'No value for format'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub features { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
features: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | return values %{$self->{features}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub style { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
style: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if (scalar(@args) == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return $self->{style}{$args[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } elsif ((scalar(@args) & 1) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my %merge = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | foreach my $key (keys %merge) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | croak 'Invalid style: '.$key unless exists $_default_style{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $self->{style}{$key} = $merge{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | croak 'Invalid call (bad arguments?)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 4 | ▶ | sub _escape { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_escape: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 4 | my ($self, $in) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | ▶ | return '!null' if !defined $in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | ▶ | return '!empty' if $in eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | return $self->{escape}->($in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | ▶ | sub _write_marker { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_marker: called CC=5 SCAR=18.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | my ($self, $type, @line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | $self->{last_line} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | if ($type eq 'required') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | $self->{fh}->print('!!'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } elsif ($type eq 'copy') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->{fh}->print('!&'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } elsif ($type eq 'optional') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->{fh}->print('!?'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | croak 'Bug: Bad marker: '.$type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | ▶ | @line = map {$self->_escape($_)} map {ref($_) ? $_->ise : $_} @line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | local $, = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | $self->{fh}->say(@line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | sub write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: called CC=19 SCAR=50.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | my ($self, @line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | unless (scalar @line) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $self->{fh}->say(''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | ▶ | @line = map {ref($_) ? $_->ise : $_} map {ref($_) ? Data::Identifier::null_to_undef($_) : $_} @line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | if ($self->{dot_repreat}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $line = [@line]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if (defined(my $last_line = $self->{last_line})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $x = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | foreach my $e (@line) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if (defined $e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if (defined($last_line->[$x]) && $e eq $last_line->[$x]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $last_line->[$x] and $e eq $last_line->[$x]
MC/DC0%0/2
defined $last_line->[$x] and $e eq $last_line->[$x]
defined $last_line->[$x]
$e eq $last_line->[$x]
Truth table0%0/3
A and B
A= defined $last_line->[$x]B= $e eq $last_line->[$x]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $e = '.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } elsif ($e =~ /^\.+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $e .= '.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } elsif (!defined($last_line->[$x])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $e = '.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $x++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | foreach my $e (@line) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if (defined $e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($e =~ /^\.+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $e .= '.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $self->{last_line} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | @line = map {$self->_escape($_)} @line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | my $l = length($line[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | ▶ | $line[0] .= ' ' x (19 - $l) if $l < 19; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | local $, = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | if ($self->{no_eol}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if (defined(my $width = $self->{style}{comment_column})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $line = join($,, @line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $l = length($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $width--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $line .= ' ' x ($width - $l) if $width > $l; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | @line = ($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $self->{fh}->print(@line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | $self->{fh}->say(@line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub write_with_comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_with_comment: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my ($self, @line) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $comment = pop(@line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | my $valid_comment = defined($comment) && length($comment); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $comment && length $comment
MC/DC0%0/2
defined $comment && length $comment
defined $comment
length $comment
Truth table0%0/3
A && B
A= defined $commentB= length $comment
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | $comment = UTF_8->encode($comment) if $valid_comment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | croak 'Unsupported comment: Bad characters' if $valid_comment && $comment =~ /[\x00-\x1F]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$valid_comment and $comment =~ /[\x00-\x1F]/u
MC/DC0%0/2
$valid_comment and $comment =~ /[\x00-\x1F]/u
$valid_comment
$comment =~ /[\x00-\x1F]/u
Truth table0%0/3
A and B
A= $valid_commentB= $comment =~ /[\x00-\x1F]/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if (scalar(@line)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | local $self->{no_eol} = $valid_comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->write(@line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $self->{fh}->print(' ') if $valid_comment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if ($valid_comment) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->{fh}->say('# ', $comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub write_blank { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_blank: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return $self->write; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub write_comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_comment: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my ($self, @comment) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | foreach my $comment_line (map {split /[\r\n]/} map {UTF_8->encode($_)} grep {defined} @comment) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | croak 'Unsupported comment: Bad characters' if $comment_line =~ /[\x00-\x1F]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $self->{fh}->say('# ', $comment_line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub write_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_hash: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my ($self, $hash) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | foreach my $key (keys %{$hash}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $value = $hash->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $value = [$value] unless ref($value) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | foreach my $entry (@{$value}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->write($key => $entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | sub write_taglist { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_taglist: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my ($self, @list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $format = $self->format; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my $mode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if ($format->eq(SF_ISE)) { # tagpool-source-format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | if (defined $self->{features}{F_M_L_ISE()}) { # tagpool-source-format-modern-limited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $mode = 'tag-ise'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } elsif (defined $self->{features}{F_M_F_ISE()}) { # tagpool-source-format-modern-full | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $mode = 'full'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $mode = 'tag'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } elsif ($format->eq(TLv1_ISE)) { # tagpool-taglist-format-v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $mode = 'tag'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | croak 'Unsupported format'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if ($mode eq 'full') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | foreach my $sublist (@list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | $sublist = [$sublist] unless ref($sublist) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | foreach my $id (@{$sublist}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $self->write_tag_ise($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | foreach my $sublist (@list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | $sublist = [$sublist] unless ref($sublist) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | foreach my $id (@{$sublist}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->write($mode, Data::Identifier->new(from => $id)->uuid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | sub write_tag_ise { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_tag_ise: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my ($self, @ids) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $displayname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my %collected = (uuid => {}, oid => {}, uri => {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | @ids = map {ref($_) eq 'ARRAY' ? @{$_} : $_} @ids; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | foreach my $id (@ids) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $found_for_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | $id = Data::Identifier->new(ise => $id) unless ref $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | $displayname //= $id->displayname(default => undef, no_defaults => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$displayname //= $id->displayname("default", undef, "no_defaults", 1)
MC/DC0%0/2
$displayname //= $id->displayname("default", undef, "no_defaults", 1)
$displayname
$id->displayname("default", undef, "no_defaults", 1)
Truth table0%0/3
A //= B
A= $displaynameB= $id->displayname("default", undef, "no_defaults", 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | foreach my $key (qw(uuid oid uri)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $func = $id->can($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $value = $id->$func(default => undef, no_defaults => 1, as => $key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $collected{$key}{$value} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $found_for_id = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | unless ($found_for_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | if (defined(my $retry = $self->{style}{tag_ise_no_ise_retry})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | my @list = map {$_ eq 'all' || $_ eq 'ise' ? qw(uuid oid uri) : ($_)} ref($retry) ? @{$retry} : split(/\s*,\s*|\s+/, $retry); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$_ eq "all" or $_ eq "ise"
MC/DC0%0/2
$_ eq "all" or $_ eq "ise"
$_ eq "all"
$_ eq "ise"
Truth table0%0/3
A or B
A= $_ eq "all"B= $_ eq "ise"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | foreach my $key (@list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | my $func = $id->can($key) // croak 'Bad value for retry: '.$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$id->can($key) // croak('Bad value for retry: ' . $key)
MC/DC0%0/1
$id->can($key) // croak('Bad value for retry: ' . $key)
$id->can($key)
Truth table0%0/2
A
A= $id->can($key)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $value = $id->$func(default => undef, as => $key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | next if $value =~ m#^https://uriid\.org/# && $self->{style}{tag_ise_no_ise_no_uriid}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$value =~ m[^https://uriid\.org/]u and $self->{"style"}{"tag_ise_no_ise_no_uriid"}
MC/DC0%0/2
$value =~ m[^https://uriid\.org/]u and $self->{"style"}{"tag_ise_no_ise_no_uriid"}
$value =~ m[^https://uriid\.org/]u
$self->{"style"}{"tag_ise_no_ise_no_uriid"}
Truth table0%0/3
A and B
A= $value =~ m[^https://uriid\.org/]uB= $self->{"style"}{"tag_ise_no_ise_no_uriid"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $collected{$key}{$value} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $found_for_id = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | last if $self->{style}{tag_ise_no_ise_one}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | croak 'No ISE found (after retry) for one of the ids' unless $found_for_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | croak 'No ISE found for one of the ids' unless $found_for_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | croak 'No ISEs found' unless scalar(keys(%{$collected{uuid}})) + scalar(keys(%{$collected{oid}})) + scalar(keys(%{$collected{uri}})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | local $self->{style}{comment_column} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $self->write_with_comment('tag-ise', keys(%{$collected{uuid}}), keys(%{$collected{oid}}), keys(%{$collected{uri}}), $displayname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub write_tag_relation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_tag_relation: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my ($tag, $relation, $related, $context, $filter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my %opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | if (scalar(@args) == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $ref = ref($args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ($ref eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | return $self->write_tag_relation(%{$args[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } elsif ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return $self->write_tag_relation(@{$args[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $tag = $args[0]->tag(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $relation = $args[0]->relation(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $related = $args[0]->related(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $context = $args[0]->context(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $filter = $args[0]->filter(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ▶ | } elsif (scalar(@args) == 3 || scalar(@args) == 5) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
scalar @args == 3 or scalar @args == 5
MC/DC0%0/2
scalar @args == 3 or scalar @args == 5
scalar @args == 3
scalar @args == 5
Truth table0%0/3
A or B
A= scalar @args == 3B= scalar @args == 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ($tag, $relation, $related, $context, $filter) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } elsif ((scalar(@args) % 2) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | %opts = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $tag = $opts{tag}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $relation = $opts{relation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $related = $opts{related}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $context = $opts{context}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $filter = $opts{filter}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | croak 'Invalid argument configuration'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | croak 'No tag given' unless defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | croak 'No relation given' unless defined $relation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | croak 'No related given' unless defined $related; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # Ensure types and well formatting: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | foreach my $ent ($tag, $relation, $related, $context, $filter) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | next unless defined $ent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | $ent = Data::Identifier->new(ise => $ent) unless ref $ent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $displayname_relation = $relation->displayname(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $displayname_related = $related->displayname(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | if (defined($displayname_relation) && defined($displayname_related)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
defined $displayname_relation and defined $displayname_related
MC/DC0%0/2
defined $displayname_relation and defined $displayname_related
defined $displayname_relation
defined $displayname_related
Truth table0%0/3
A and B
A= defined $displayname_relationB= defined $displayname_related
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $comment = sprintf('%s: %s', $displayname_relation, $displayname_related); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } elsif (defined($displayname_relation)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $comment = $displayname_relation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } elsif (defined($displayname_related)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $comment = '?: '.$displayname_related; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if ($self->{style}{tag_relation} eq 'mixed' && !defined($context) && !defined($filter) && defined(my $old_style = $_old_style_relation{$relation->ise})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$self->{"style"}{"tag_relation"} eq "mixed" and not defined $context and not defined $filter and defined(my $old_style = $_old_style_relation{$relation->ise})
$self->{"style"}{"tag_relation"} eq "mixed" and not defined $context and not defined $filter
$self->{"style"}{"tag_relation"} eq "mixed" and not defined $context
MC/DC0%0/4
$self->{"style"}{"tag_relation"} eq "mixed" and not defined $context and not defined $filter and defined(my $old_style = $_old_style_relation{$relation->ise})
$self->{"style"}{"tag_relation"} eq "mixed"
not defined $context
not defined $filter
defined(my $old_style = $_old_style_relation{$relation->ise})
Truth table0%0/5
A and not(B) and not(C) and D
A= $self->{"style"}{"tag_relation"} eq "mixed"B= not defined $contextC= not defined $filterD= defined(my $old_style = $_old_style_relation{$relation->ise})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $self->write_with_comment($old_style, $tag, $related, $comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $self->write_with_comment('tag-relation', $tag, $relation, $related, $context, $filter, $comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | sub write_tag_metadata { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_tag_metadata: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my ($tag, $relation, $context, $type, $encoding, $data_raw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my %opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if (scalar(@args) == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my $ref = ref($args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if ($ref eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return $self->write_tag_metadata(%{$args[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } elsif ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | return $self->write_tag_metadata(@{$args[0]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | $tag = $args[0]->tag(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $relation = $args[0]->relation(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $context = $args[0]->context(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $type = $args[0]->type(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $encoding = $args[0]->encoding(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | $data_raw = $args[0]->data_raw(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } elsif (scalar(@args) == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ($tag, $relation, $data_raw) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } elsif (scalar(@args) == 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ($tag, $relation, $type, $encoding, $data_raw) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } elsif ((scalar(@args) % 2) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | %opts = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $tag = $opts{tag}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $relation = $opts{relation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $context = $opts{context}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $type = $opts{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $encoding = $opts{encoding}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $data_raw = $opts{data_raw}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | croak 'Invalid argument configuration'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | croak 'No tag given' unless defined $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | croak 'No relation given' unless defined $relation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | croak 'No data_raw given' unless defined $data_raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # Ensure types and well formatting: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | foreach my $ent ($tag, $relation, $context, $type, $encoding) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | next unless defined $ent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | $ent = Data::Identifier->new(ise => $ent) unless ref $ent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $comment = $relation->displayname(default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | if (defined($comment) && defined($type) && defined(my $type_displayname = $type->displayname(default => undef, no_defaults => 1))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $comment and defined $type and defined(my $type_displayname = $type->displayname("default", undef, "no_defaults", 1))
defined $comment and defined $type
MC/DC0%0/3
defined $comment and defined $type and defined(my $type_displayname = $type->displayname("default", undef, "no_defaults", 1))
defined $comment
defined $type
defined(my $type_displayname = $type->displayname("default", undef, "no_defaults", 1))
Truth table0%0/4
A and B and C
A= defined $commentB= defined $typeC= defined(my $type_displayname = $type->displayname("default", undef, "no_defaults", 1))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $comment .= '('.$type_displayname.')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $self->write_with_comment('tag-metadata', $tag, $relation, $context, $type, $encoding, $data_raw, $comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | sub write_tag_generator_hint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_tag_generator_hint: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my ($self, $tag, $generator, $hint, $comment) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | $generator //= Data::Identifier->new(from => $tag)->generator(default => undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$generator //= "Data::Identifier"->new("from", $tag)->generator("default", undef)
MC/DC0%0/2
$generator //= "Data::Identifier"->new("from", $tag)->generator("default", undef)
$generator
"Data::Identifier"->new("from", $tag)->generator("default", undef)
Truth table0%0/3
A //= B
A= $generatorB= "Data::Identifier"->new("from", $tag)->generator("default", undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | $hint //= Data::Identifier->new(from => $tag)->request(default => undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$hint //= "Data::Identifier"->new("from", $tag)->request("default", undef)
MC/DC0%0/2
$hint //= "Data::Identifier"->new("from", $tag)->request("default", undef)
$hint
"Data::Identifier"->new("from", $tag)->request("default", undef)
Truth table0%0/3
A //= B
A= $hintB= "Data::Identifier"->new("from", $tag)->request("default", undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | if (ref($hint) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $hint = join('--', sort map {$_->uuid} @{$hint}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | if ((!defined($generator) || !defined($hint)) && ($self->{style}{degenerate_generator_hint} // '') eq 'auto') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
not defined $generator && defined $hint and ($self->{"style"}{"degenerate_generator_hint"} // "") eq "auto"
defined $generator && defined $hint
$self->{"style"}{"degenerate_generator_hint"} // ""
MC/DC0%0/3
not defined $generator && defined $hint and ($self->{"style"}{"degenerate_generator_hint"} // "") eq "auto"
defined $generator
defined $hint
$self->{"style"}{"degenerate_generator_hint"}
Truth table0%0/5
not(A && B) and C
A= defined $generatorB= defined $hintC= $self->{"style"}{"degenerate_generator_hint"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $self->write_tag_ise($tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | croak 'No generator given' unless defined $generator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | croak 'No hint given' unless defined $hint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"style"}{"generator_hint"} eq "auto" and defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"} || defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"} or defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
MC/DC0%0/3
$self->{"style"}{"generator_hint"} eq "auto" and defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"} || defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
$self->{"style"}{"generator_hint"} eq "auto"
defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"}
defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
Truth table0%0/4
A and B or C
A= $self->{"style"}{"generator_hint"} eq "auto"B= defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"}C= defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | $self->{style}{generator_hint} eq 'auto' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | defined($self->{features}{F_M_L_ISE()}) || # tagpool-source-format-modern-limited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | defined($self->{features}{F_M_F_ISE()}) # tagpool-source-format-modern-full | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | state $generator_request = Data::Identifier->new(uuid => 'ab573786-73bc-4f5c-9b03-24ef8a70ae45')->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | state $generated_by = Data::Identifier->new(uuid => '8efbc13b-47e5-4d92-a960-bd9a2efa9ccb')->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | $self->write_tag_metadata($tag, $generator_request, $hint); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | $self->write_tag_relation($tag, $generated_by, Data::Identifier->new(from => $generator)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | if (defined $generator) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | $comment //= $_generator_comments{ref($generator) ? $generator->ise : $generator}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$comment //= $_generator_comments{ref $generator ? $generator->ise : $generator}
MC/DC0%0/2
$comment //= $_generator_comments{ref $generator ? $generator->ise : $generator}
$comment
$_generator_comments{ref $generator ? $generator->ise : $generator}
Truth table0%0/3
A //= B
A= $commentB= $_generator_comments{ref $generator ? $generator->ise : $generator}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | if (defined $comment) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $self->write_with_comment('tag-generator-hint', $tag, $generator, $hint, $comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $self->write('tag-generator-hint', $tag, $generator, $hint); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | sub write_tagname { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_tagname: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my ($self, $tag, @tagnames) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | $tag = Data::Identifier::null_to_undef($tag) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | if (scalar(@tagnames) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | @tagnames = Data::Identifier->new(from => $tag)->tagname(list => 1, default => [], no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"} or defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
MC/DC0%0/2
defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"} or defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"}
defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
Truth table0%0/3
A or B
A= defined $self->{"features"}{"f06c2226-b33e-48f2-9085-cd906a3dcee0"}B= defined $self->{"features"}{"1c71f5b1-216d-4a9b-81a1-54dc22d8a067"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | defined($self->{features}{F_M_L_ISE()}) || # tagpool-source-format-modern-limited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | defined($self->{features}{F_M_F_ISE()}) # tagpool-source-format-modern-full | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | state $wk_asi = Data::Identifier->new(uuid => 'ddd60c5c-2934-404f-8f2d-fcb4da88b633')->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | state $wk_tagname = Data::Identifier->new(uuid => 'bfae7574-3dae-425d-89b1-9c087c140c23')->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | foreach my $tagname (@tagnames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | next unless defined($tagname) && length($tagname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $tagname and length $tagname
MC/DC0%0/2
defined $tagname and length $tagname
defined $tagname
length $tagname
Truth table0%0/3
A and B
A= defined $tagnameB= length $tagname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $self->write_tag_metadata($tag, $wk_asi, $wk_tagname, undef, $tagname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | foreach my $tagname (@tagnames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | next unless defined($tagname) && length($tagname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $tagname and length $tagname
MC/DC0%0/2
defined $tagname and length $tagname
defined $tagname
length $tagname
Truth table0%0/3
A and B
A= defined $tagnameB= length $tagname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | $self->write('tag', $tag, $tagname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||