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