| 1 | # Copyright (c) 2023-2026 Philipp Schafft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: format independent identifier object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | package Data::Identifier::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use v5.14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use parent qw(Data::Identifier::Interface::Userdata Data::Identifier::Interface::Subobjects); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Data::Identifier; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use Data::Identifier::Generate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | our $VERSION = v0.38; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | BOOL_TRUE => Data::Identifier->new(uuid => 'eb50b3dc-28be-4cfc-a9ea-bd7cee73aed5')->register, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | BOOL_FALSE => Data::Identifier->new(uuid => '6d34d4a1-8fbc-4e22-b3e0-d50f43d97cb1')->register, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | _update_tag(BOOL_TRUE, 46, 190, 'true'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | _update_tag(BOOL_FALSE, 45, 189, 'false'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | my @truths = (BOOL_TRUE, qw(https://schema.org/True http://schema.org/True), Data::Identifier->new(wd => 'Q16751793')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | my @falses = (BOOL_FALSE, qw(https://schema.org/False http://schema.org/False), Data::Identifier->new(wd => 'Q5432619')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | foreach my $id (@truths, @falses) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 24 | $id = Data::Identifier->new(from => $id)->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | my $_DEFAULT_INSTANCE = __PACKAGE__->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | my %_4plus12_prefix = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | sni => (0<<15)|(0<<14), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | sid => (0<<15)|(1<<14), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | hdi => (1<<15)|(0<<14), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | udi => (1<<15)|(1<<14), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | my $_logical = '5e80c7b7-215e-4154-b310-a5387045c336'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | my %_raes_to_raen = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | NONE => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | NOENT => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | NOSYS => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | NOTSUP => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | NOMEM => 12, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | INVAL => 13, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | FAULT => 18, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | IO => 19, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | NODATA => 25, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | NOSPC => 38, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | TYPEMM => 39, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | RO => 45, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ILLSEQ => 56, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | BADEXEC => 79, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | BADFH => 83, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | my %_logicals_to_sni = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | sni => 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | sid => 115, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | raen => 116, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | chat0w => 118, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | uuid => 119, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | uri => 121, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | asciicp => 122, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | oid => 120, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | wd => 123, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | logical => 129, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | false => 189, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | true => 190, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | my %_logicals_to_sid = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | asi => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | tagname => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | SEEK_SET => 34, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | SEEK_CUR => 35, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | SEEK_END => 36, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | backwards => 43, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | forwards => 44, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | black => 61, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | white => 62, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | grey => 63, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | red => 119, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | green => 120, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | blue => 121, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | cyan => 122, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | magenta => 123, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | yellow => 124, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | orange => 125, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | gtin => 160, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | left => 192, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | right => 193, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | up => 194, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | down => 195, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | north => 208, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | east => 209, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | south => 210, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | west => 211, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | my %_wk = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | bunit_ns => {uuid => 'e8e9846a-37ec-42fd-8e89-d15f5467aa9c', displayname => 'unit-namespace'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | bunit_gen => {uuid => 'b1620795-b29a-4aea-ba46-371b187d0a4b', displayname => 'unit-generator'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | dunit_ns => {uuid => 'da8a7fe4-935c-4bf7-9bd1-aaf8fc39305b', displayname => 'derived-unit-namespace'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | dunit_gen => {uuid => 'c3446cff-672b-4247-b62c-755a295ee15f', displayname => 'derived-unit-generator'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | #x => {uuid => '', displayname => ''}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | foreach my $value (values %_wk) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 12 | my $uuid = delete $value->{uuid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 12 | $value = Data::Identifier->new(uuid => $uuid, %{$value})->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | my %_base_units = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | $_->{id} = Data::Identifier::Generate->generic( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | namespace => $_wk{bunit_ns}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | generator => $_wk{bunit_gen}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | style => 'name-based', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | request => $_->{symbol}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | displayname => $_->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 21 | )->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 21 | $_->{symbol} => $_ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | {name => 'second', symbol => 's', dimension => 'T', quantity => 'time', variable => [qw(t)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | {name => 'metre', symbol => 'm', dimension => 'L', quantity => 'length', variable => [qw(l x r)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | {name => 'kilogram', symbol => 'kg', dimension => 'M', quantity => 'mass', variable => [qw(m)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | {name => 'ampere', symbol => 'A', dimension => 'I', quantity => 'electric current', variable => [qw(I i)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | {name => 'kelvin', symbol => 'K', dimension => "\N{U+0398}", quantity => 'thermodynamic temperature', variable => [qw(T)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | {name => 'mole', symbol => 'mol', dimension => 'N', quantity => 'amount of substance', variable => [qw(n)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | {name => 'candela', symbol => 'cd', dimension => 'J', quantity => 'luminous intensity', variable => [qw(Iv)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | my %_number_units = map { $_ => Data::Identifier::Generate->integer($_)->register } (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73); # primes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | my %_composite_unit_elements = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | Hz => {s => -1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | N => {s => -2, m => 1, kg => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Pa => {s => -2, m => -1, kg => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | J => {s => -2, m => 2, kg => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | W => {s => -3, m => 2, kg => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | C => {s => 1, A => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | V => {s => -3, m => 2, kg => 1, A => -1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | F => {s => 4, m => -2, kg => -1, A => 2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | "\N{U+03A9}" => {s => -3, m => 2, kg => 1, A => -2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | "\N{U+2126}" => {s => -3, m => 2, kg => 1, A => -2}, # alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ohm => {s => -3, m => 2, kg => 1, A => -2}, # alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | S => {s => 3, m => -2, kg => -1, A => 2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | Wb => {s => -2, m => 2, kg => 1, A => -1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | T => {s => -2, kg => 1, A => -1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | H => {s => -2, m => 2, kg => 1, A => -2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | kat => {s => -1, mol => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 10 => {2 => 1, 5 => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 12 => {2 => 2, 3 => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 24 => {2 => 3, 3 => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 28 => {2 => 2, 7 => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 30 => {2 => 1, 3 => 1, 5 => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 60 => {2 => 2, 3 => 1, 5 => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 365 => { 5 => 1, 73 => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 366 => {2 => 1, 3 => 1, 61 => 1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3600 => {2 => 4, 3 => 2, 5 => 2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 86400 => {2 => 7, 3 => 3, 5 => 2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | my %_component_to_name = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # Units: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 21 | (map {$_base_units{$_}{id}->uuid => $_} keys %_base_units), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # Numbers: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | (map {$_number_units{$_}->uuid => $_} keys %_number_units), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | my %_si_prefix = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | quetta => 30, Q => 30, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ronna => 27, R => 27, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | yotta => 24, Y => 24, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | zetta => 21, Z => 21, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | exa => 18, E => 18, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | peta => 15, P => 15, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | tera => 12, T => 12, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | giga => 9, G => 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | mega => 6, M => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | kilo => 3, k => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | hecto => 2, h => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | deca => 1, da => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | deci => -1, d => -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | centi => -2, c => -2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | milli => -3, m => -3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | ▶ | micro => -6, "\N{GREEK SMALL LETTER MU}" => -6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | nano => -9, n => -9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | pico => -12, p => -12, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | femto => -15, f => -15, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | atto => -18, a => -18, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | zepto => -21, z => -21, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | yocto => -24, y => -24, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ronto => -27, r => -27, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | quecto => -30, q => -30, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | my ($pkg, @opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 4 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | return bless {}, $pkg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub from_bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_bool: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my ($self, $bool, @opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | return $bool ? BOOL_TRUE : BOOL_FALSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub is_true { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_true: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my ($self, $identifier, @opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | foreach my $ref (@truths) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | return !!1 if $ref->eq($identifier); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | return !!0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub is_false { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_false: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my ($self, $identifier, @opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | foreach my $ref (@falses) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | return !!1 if $ref->eq($identifier); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | return !!0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 16 | ▶ | sub pack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack: called CC=26 SCAR=42.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 16 | my ($self, $template, $identifier, @opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 16 | my $pack_template; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | my $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 16 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 16 | ▶ | $template //= '<undef>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$template //= "<undef>"
MC/DC0%0/1
$template //= "<undef>"
$template
Truth table50%1/2
A
A= $template
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 16 | ▶ | $identifier = Data::Identifier->new(from => $identifier) unless eval {$identifier->isa('Data::Identifier')}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 16 | ▶ | if ($template =~ /^(sid|sni|hdi|udi)([1-9][0-9]*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 6 | my $bits = int($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 6 | $v = $identifier->as(Data::Identifier->new(wellknown => $1), no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 6 | ▶ | if ($bits == 8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | $pack_template = 'C'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } elsif ($bits == 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | $pack_template = 'n'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } elsif ($bits == 32) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | $pack_template = 'N'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | croak 'Invalid width: '.$bits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } elsif ($template eq '4+12') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $prefix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | foreach my $type (qw(sid sni hdi udi)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $v = $identifier->as(Data::Identifier->new(wellknown => $type), no_defaults => 1, default => undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if (defined $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if ($v < 0 || $v > 0x0FFF) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$v < 0 or $v > 4095
MC/DC0%0/2
$v < 0 or $v > 4095
$v < 0
$v > 4095
Truth table0%0/3
A or B
A= $v < 0B= $v > 4095
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $v |= $_4plus12_prefix{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $pack_template = 'n'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } elsif ($template eq 'uuid128') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | return pack('H*', $identifier->uuid(no_defaults => 1) =~ tr/-//dr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } elsif ($template eq 'uuidhexdash') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | return $identifier->uuid(no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } elsif ($template eq 'uuidHEXDASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | return $identifier->uuid(no_defaults => 1) =~ tr/a-f/A-F/r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } elsif ($template eq 'Data::Identifier') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 7 | return $identifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 6 | ▶ | if (defined($v) && defined($pack_template)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $v and defined $pack_template
MC/DC0%0/2
defined $v and defined $pack_template
defined $v
defined $pack_template
Truth table33%1/3
A and B
A= defined $vB= defined $pack_template
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 6 | my ($min, $max); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 6 | ▶ | if ($pack_template eq 'C') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | ($min, $max) = (0, 0xFF); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } elsif ($pack_template eq 'n') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | ($min, $max) = (0, 0xFFFF); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } elsif ($pack_template eq 'N') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | ($min, $max) = (0, 0xFFFF_FFFF); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | ▶ | if ((defined($min) && $v < $min) || (defined($max) && $v > $max)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $min and $v < $min or defined $max and $v > $max
defined $min and $v < $min
defined $max and $v > $max
MC/DC0%0/4
defined $min and $v < $min or defined $max and $v > $max
defined $min
$v < $min
defined $max
$v > $max
Truth table14%1/7
A and B or C and D
A= defined $minB= $v < $minC= defined $maxD= $v > $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | croak 'Identifier not in range for '.$template.': '.$v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 6 | return pack($pack_template, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | croak 'Unknown template: '.$template; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 9 | ▶ | sub unpack { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=21 SCAR=38.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 9 | my ($self, $template, $data, @opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 9 | my $pack_template; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | my $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 9 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 9 | ▶ | if ($template =~ /^(sid|sni|hdi|udi)([1-9][0-9]*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 6 | my $bits = int($2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 6 | $type = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 6 | ▶ | if ($bits == 8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 2 | $pack_template = 'C'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } elsif ($bits == 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 2 | $pack_template = 'n'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } elsif ($bits == 32) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 2 | $pack_template = 'N'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | croak 'Invalid width: '.$bits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } elsif ($template eq '4+12') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | my $prefix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | croak 'Input has bad length, expected 2 bytes, got '.length($data) unless length($data) == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $v = unpack('n', $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $prefix = $v & 0xF000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $v = $v & 0x0FFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | foreach my $key (keys %_4plus12_prefix) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ($prefix == $_4plus12_prefix{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return Data::Identifier->new($key => $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | croak sprintf('Invalid/unknown prefix: 0x%04x', $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } elsif ($template eq 'uuid128') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | ▶ | croak 'Input has bad length, expected 16 bytes, got '.length($data) unless length($data) == 16; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | return Data::Identifier->new(uuid => join('-', unpack('H8H4H4H4H12', $data))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } elsif ($template eq 'uuidhexdash') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | return Data::Identifier->new(uuid => $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } elsif ($template eq 'uuidHEXDASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | return Data::Identifier->new(uuid => $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } elsif ($template eq 'Data::Identifier') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # We don't care too much here if it is actually a Data::Identifier or just any other supported type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # Data::Identifier will do the right thing anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return Data::Identifier->new(from => $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 6 | ▶ | if (defined($type) && defined($pack_template)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $type and defined $pack_template
MC/DC0%0/2
defined $type and defined $pack_template
defined $type
defined $pack_template
Truth table33%1/3
A and B
A= defined $typeB= defined $pack_template
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 6 | my $len = length($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 6 | my $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 6 | ▶ | if ($pack_template eq 'C') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 2 | $exp = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } elsif ($pack_template eq 'n') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 2 | $exp = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } elsif ($pack_template eq 'N') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 2 | $exp = 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 6 | ▶ | croak 'Input has bad length, expected '.$exp.' bytes, got '.$len unless $len == $exp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 6 | return Data::Identifier->new($type => unpack($pack_template, $data)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | croak 'Unknown template: '.$template; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 16 | ▶ | sub parse_sirtx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_sirtx: called CC=20 SCAR=34.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 16 | my ($self, $data, @opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 16 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 16 | $self->_load_well_known; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 16 | $data =~ s/^\[(.+)\]$/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # Experimental: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 16 | ▶ | if (my ($d, $v) = $data =~ /^(\[.+?\]):(.+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | $d = $self->parse_sirtx($d); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | $v =~ s/^\[(.+)\]$/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | return Data::Identifier->new($d => $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 15 | ▶ | if ($data =~ /^'([0-9]*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 13 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 2 | ▶ | my $num = int($1 || '0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$1 || '0'
MC/DC0%0/1
$1 || '0'
$1
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | require Data::Identifier::Generate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | return Data::Identifier::Generate->integer($num); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } elsif ($data =~ /^\/([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return Data::Identifier->new('d73b6550-5309-46ad-acc9-865c9261065b' => int($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } elsif ($data =~ /^(sid|sni):([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 4 | return Data::Identifier->new($1 => int($2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } elsif ($data =~ /^uuid:([0-9a-fA-F-]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | return Data::Identifier->new(uuid => $1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } elsif ($data =~ /^wd:([QPL][1-9][0-9]*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | return Data::Identifier->new(wd => $1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } elsif ($data =~ /^~([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | return Data::Identifier->new(hdi => int($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } elsif ($data =~ /^raen:([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | return Data::Identifier->new('2bffc55d-7380-454e-bd53-c5acd525d692' => int($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } elsif ($data =~ /^chat0w:([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | return Data::Identifier->new('2c7e15ed-aa2f-4e2f-9a1d-64df0c85875a' => int($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } elsif ($data =~ /^asciicp:([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | require Data::Identifier::Generate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | return Data::Identifier::Generate->unicode_character(ascii => int($1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } elsif ($data =~ /^raes:(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | ▶ | if (defined(my $raen = $_raes_to_raen{$1})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1 | return Data::Identifier->new('2bffc55d-7380-454e-bd53-c5acd525d692' => $raen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } elsif (defined $_logicals_to_sni{$data}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | return Data::Identifier->new(sni => $_logicals_to_sni{$data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } elsif (defined $_logicals_to_sid{$data}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | return Data::Identifier->new(sid => $_logicals_to_sid{$data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } elsif ($data =~ /^logical:(.+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | $data = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 2 | ▶ | if (defined $_logicals_to_sni{$data}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | return Data::Identifier->new(sni => $_logicals_to_sni{$data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } elsif (defined $_logicals_to_sid{$data}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | return Data::Identifier->new(sid => $_logicals_to_sid{$data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | croak 'Unsupported/invalid SIRTX identifier'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | sub render_sirtx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_sirtx: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my ($self, $identifier, @opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | state $map = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | [sid => Data::Identifier->new(wellknown => 'sid')->register], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | [sni => Data::Identifier->new(wellknown => 'sni')->register], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | [wd => Data::Identifier->new(wellknown => 'wd')->register], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | ['/' => Data::Identifier->new(uuid => 'd73b6550-5309-46ad-acc9-865c9261065b')->register], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | [raen => Data::Identifier->new(uuid => '2bffc55d-7380-454e-bd53-c5acd525d692')->register], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | [chat0w => Data::Identifier->new(uuid => '2c7e15ed-aa2f-4e2f-9a1d-64df0c85875a')->register], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | ['~' => Data::Identifier->new(wellknown => 'hdi')->register], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $identifier = Data::Identifier->new(from => $identifier); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | if (defined(my Data::Identifier $generator = $identifier->generator(default => undef)) && defined(my $req = $identifier->request(default => undef))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined(my Data::Identifier $generator = $identifier->generator("default", undef)) and defined(my $req = $identifier->request("default", undef))
MC/DC0%0/2
defined(my Data::Identifier $generator = $identifier->generator("default", undef)) and defined(my $req = $identifier->request("default", undef))
defined(my Data::Identifier $generator = $identifier->generator("default", undef))
defined(my $req = $identifier->request("default", undef))
Truth table0%0/3
A and B
A= defined(my Data::Identifier $generator = $identifier->generator("default", undef))B= defined(my $req = $identifier->request("default", undef))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | if ($generator->eq('53863a15-68d4-448d-bd69-a9b19289a191')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | return sprintf('\'%u', $req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | ▶ | } elsif ($generator->eq('d74f8c35-bcb8-465c-9a77-01010e8ed25c') && $req =~ /^[Uu]\+([0-9a-fA-F]{4,6})$/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$generator->eq("d74f8c35-bcb8-465c-9a77-01010e8ed25c") and $req =~ /^[Uu]\+([0-9a-fA-F]{4,6})$/u
MC/DC0%0/2
$generator->eq("d74f8c35-bcb8-465c-9a77-01010e8ed25c") and $req =~ /^[Uu]\+([0-9a-fA-F]{4,6})$/u
$generator->eq("d74f8c35-bcb8-465c-9a77-01010e8ed25c")
$req =~ /^[Uu]\+([0-9a-fA-F]{4,6})$/u
Truth table0%0/3
A and B
A= $generator->eq("d74f8c35-bcb8-465c-9a77-01010e8ed25c")B= $req =~ /^[Uu]\+([0-9a-fA-F]{4,6})$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $cp = hex $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | if ($cp < 0x80) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | return sprintf('asciicp:%u', $cp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | foreach my $ent (@{$map}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | my $v = $identifier->as($ent->[1], no_defaults => 1, default => undef) // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$identifier->as($ent->[1], "no_defaults", 1, "default", undef) // (next)
MC/DC0%0/1
$identifier->as($ent->[1], "no_defaults", 1, "default", undef) // (next)
$identifier->as($ent->[1], "no_defaults", 1, "default", undef)
Truth table0%0/2
A
A= $identifier->as($ent->[1], "no_defaults", 1, "default", undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | $v = sprintf($ent->[0] =~ /^[a-z]/ ? '%s:%s' : '%s%s', $ent->[0], $v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | $v = '['.$v.']' if $v =~ /-/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # Fallback: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return sprintf('[uuid:%s]', $identifier->uuid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # Too experimental for listing in public API. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # TODO: Get this on track for the public API! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | sub parse_unit_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_unit_request: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my ($self, $template, $request, %opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | my $exponentas = delete($opts{exponentas}) // 'int'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $opts{"exponentas"} // "int"
MC/DC0%0/1
delete $opts{"exponentas"} // "int"
delete $opts{"exponentas"}
Truth table0%0/2
A
A= delete $opts{"exponentas"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | if ($template eq 'request') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | foreach my $subreq (split(/--/, $request)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ($uuid, $neg, $exp_mul) = $subreq =~ /^([0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})~(-?)([0-9])\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | #printf("%-42s -> <%s> <%1s> <%s>\n", $subreq, $uuid, $neg, $exp_mul); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if ($exponentas eq 'int') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $exp = int($exp_mul); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | $exp = -$exp if $neg eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | croak 'Invalid exponentas: '.$exponentas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | push(@res, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | component => Data::Identifier->new(uuid => $uuid), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | exponent => $exp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | croak 'Unknown template: '.$template; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | return \@res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | # Too experimental for listing in public API. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # TODO: Get this on track for the public API! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 7 | ▶ | sub render_unit_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_unit_request: called CC=28 SCAR=36.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 7 | my ($pkg, $template, $request, %opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 7 | my $displayname = delete $opts{displayname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 7 | my $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | my %took; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 7 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 7 | ▶ | if (ref($request) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | $request = {map {($_component_to_name{$_->{component}->uuid} // croak 'Unknown base unit: '.$_->{component}->uuid) => $_->{exponent}} @{$request}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_component_to_name{$_->{"component"}->uuid} // croak('Unknown base unit: ' . $_->{"component"}->uuid)
MC/DC0%0/1
$_component_to_name{$_->{"component"}->uuid} // croak('Unknown base unit: ' . $_->{"component"}->uuid)
$_component_to_name{$_->{"component"}->uuid}
Truth table0%0/2
A
A= $_component_to_name{$_->{"component"}->uuid}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 7 | ▶ | if (defined(my $prefix = delete($request->{prefix}))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 5 | ▶ | $prefix = $_si_prefix{$prefix} // croak 'Bad prefix: '.$prefix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_si_prefix{$prefix} // croak('Bad prefix: ' . $prefix)
MC/DC0%0/1
$_si_prefix{$prefix} // croak('Bad prefix: ' . $prefix)
$_si_prefix{$prefix}
Truth table50%1/2
A
A= $_si_prefix{$prefix}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 5 | ▶ | $request->{10} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$request->{10} //= 0
MC/DC0%0/1
$request->{10} //= 0
$request->{10}
Truth table50%1/2
A
A= $request->{10}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 5 | $request->{10} += $prefix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 7 | foreach my $key (keys(%_composite_unit_elements)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 182 | my $n = $_composite_unit_elements{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 182 | ▶ | my $mul = delete($request->{$key}) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $request->{$key} // 0
MC/DC100%1/1
delete $request->{$key} // 0
delete $request->{$key}
Truth table100%2/2
A
A= delete $request->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 182 | ▶ | croak 'Bad exponent: '.$mul if $mul != int($mul); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 182 | $mul = int($mul); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 182 | ▶ | next if $mul == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 6 | foreach my $prime_element (keys %{$n}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 13 | ▶ | $request->{$prime_element} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$request->{$prime_element} //= 0
MC/DC0%0/1
$request->{$prime_element} //= 0
$request->{$prime_element}
Truth table50%1/2
A
A= $request->{$prime_element}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 13 | $request->{$prime_element} += $n->{$prime_element} * $mul; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 7 | foreach my $key (keys(%_base_units), keys(%_number_units)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 196 | ▶ | my $mul = delete($request->{$key}) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $request->{$key} // 0
MC/DC100%1/1
delete $request->{$key} // 0
delete $request->{$key}
Truth table100%2/2
A
A= delete $request->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 196 | ▶ | croak 'Bad exponent: '.$mul if $mul != int($mul); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 196 | $mul = int($mul); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 196 | ▶ | $took{$key} = $mul if $mul != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 7 | my @keys = keys %{$request}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 7 | ▶ | croak 'Bad extra units: '.join(', ', @keys) if scalar @keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 7 | ▶ | unless (scalar(grep {!defined $_number_units{$_}} keys %took)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 1 | my $i = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 1 | foreach my $key (keys %took) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | $i *= $key ** $took{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | ▶ | if ($i == int($i)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 1 | return $pkg->pack($template => Data::Identifier::Generate->integer($i)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | croak 'Invalid numeric only request'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # Rename from units to UUIDs as keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 6 | foreach my $key (keys %took) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 20 | ▶ | my $uuid = ($_number_units{$key} // $_base_units{$key}{id})->uuid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_number_units{$key} // $_base_units{$key}{"id"}
MC/DC0%0/2
$_number_units{$key} // $_base_units{$key}{"id"}
$_number_units{$key}
$_base_units{$key}{"id"}
Truth table66%2/3
A // B
A= $_number_units{$key}B= $_base_units{$key}{"id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 20 | $took{$uuid} = delete $took{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 6 | ▶ | if (scalar(keys %took) == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | my ($mul) = values %took; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 1 | ▶ | if ($mul == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | my ($uuid) = keys %took; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 1 | return $pkg->pack($template => Data::Identifier->new(uuid => $uuid)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 5 | $input = join('--', map{$_.'~'.$took{$_}} sort keys %took); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 5 | ▶ | if ($template eq 'request') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | return $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | $opts{namespace} //= $_wk{dunit_ns}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | $opts{generator} //= $_wk{dunit_gen}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 5 | ▶ | $opts{input} = $input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$opts{"namespace"} //= $_wk{"dunit_ns"}
$opts{"generator"} //= $_wk{"dunit_gen"}
MC/DC0%0/2
$opts{"namespace"} //= $_wk{"dunit_ns"}
$opts{"namespace"}
$_wk{"dunit_ns"}
MC/DC0%0/2
$opts{"generator"} //= $_wk{"dunit_gen"}
$opts{"generator"}
$_wk{"dunit_gen"}
Truth table33%1/3
A //= B
A= $opts{"namespace"}B= $_wk{"dunit_ns"}
Truth table33%1/3
A //= B
A= $opts{"generator"}B= $_wk{"dunit_gen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 5 | $opts{request} = $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 5 | $opts{displayname} = $displayname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 5 | return $pkg->pack($template => Data::Identifier::Generate->generic(%opts)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | sub announce { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
announce: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my ($pkg, $type, $regs, @opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | $type = Data::Identifier->new(from => $type); # Force to Data::Identifier | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | $type->register; # Ensure it is registered | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | if (ref($regs) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | $type = $type->uuid; # Convert to UUID for cache usage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | foreach my $key (keys %{$regs}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $identifier = Data::Identifier->new(from => $regs->{$key}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | $identifier->{id_cache} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$identifier->{"id_cache"} //= {}
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table0%0/2
A
A= $identifier->{"id_cache"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | $identifier->{id_cache}->{$type} //= $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$identifier->{"id_cache"}{$type} //= $key
MC/DC0%0/2
$identifier->{"id_cache"}{$type} //= $key
$identifier->{"id_cache"}{$type}
$key
Truth table0%0/3
A //= B
A= $identifier->{"id_cache"}{$type}B= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | $identifier->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } elsif (ref($regs) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | foreach my $key (@{$regs}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if (ref $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | Data::Identifier->new(from => $key)->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | Data::Identifier->new($type => $key)->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | croak 'Unsupported data type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 1 | ▶ | sub register_namespace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_namespace: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 1 | my ($self, $identifier, %opts) = _register_base(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | $identifier->uuid; # ensure we map to an UUID | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 1 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 1 | return $identifier->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 1 | ▶ | sub register_generator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_generator: called CC=6 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 1 | my ($self, $identifier, %opts) = _register_base(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 1 | my %pass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 1 | $pass{$_} = delete $opts{$_} foreach qw(namespace style type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 1 | delete $opts{$_} foreach qw(native_case source_role up_relation for_type copy_tagnames native_ise_template); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 1 | ▶ | $pass{namespace} = $self->register_namespace($pass{namespace}) if defined $pass{namespace}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 1 | ▶ | $pass{type} = $self->register_type($pass{type}) if defined $pass{type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 1 | Data::Identifier::Generate->_register_generator($identifier, %pass); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 1 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 1 | return $identifier->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | sub register_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_type: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | my ($self, $identifier, %opts) = _register_base(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my $uuid = $identifier->uuid; # ensure we map to an UUID | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | if (defined(my $validate = delete $opts{validate})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | $identifier->{validate} //= $validate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$identifier->{"validate"} //= $validate
MC/DC0%0/2
$identifier->{"validate"} //= $validate
$identifier->{"validate"}
$validate
Truth table0%0/3
A //= B
A= $identifier->{"validate"}B= $validate
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | if (defined(my $namespace = delete $opts{namespace})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | $identifier->{namespace} //= $self->register_namespace($namespace); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$identifier->{"namespace"} //= $self->register_namespace($namespace)
MC/DC0%0/2
$identifier->{"namespace"} //= $self->register_namespace($namespace)
$identifier->{"namespace"}
$self->register_namespace($namespace)
Truth table0%0/3
A //= B
A= $identifier->{"namespace"}B= $self->register_namespace($namespace)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | if (defined(my $null_value = delete $opts{null_value})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | my $null = Data::Identifier->new(sid => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | $null->{id_cache}{$uuid} //= $null_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$null->{"id_cache"}{$uuid} //= $null_value
MC/DC0%0/2
$null->{"id_cache"}{$uuid} //= $null_value
$null->{"id_cache"}{$uuid}
$null_value
Truth table0%0/3
A //= B
A= $null->{"id_cache"}{$uuid}B= $null_value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $null->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | return $identifier->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 2 | ▶ | sub regenerate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
regenerate: called CC=13 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 2 | my ($self, $identifier, %opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 2 | $identifier = Data::Identifier->new(from => $identifier); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 2 | ▶ | if (defined(my $generator = delete $opts{generator})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | # TODO compare with what is in $identifier already and die on mismatch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | ▶ | $identifier->{generator} //= Data::Identifier->new(from => $generator); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$identifier->{"generator"} //= "Data::Identifier"->new("from", $generator)
MC/DC0%0/2
$identifier->{"generator"} //= "Data::Identifier"->new("from", $generator)
$identifier->{"generator"}
"Data::Identifier"->new("from", $generator)
Truth table33%1/3
A //= B
A= $identifier->{"generator"}B= "Data::Identifier"->new("from", $generator)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 2 | ▶ | if (defined(my $request = delete $opts{request})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # TODO compare with what is in $identifier already and die on mismatch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 1 | ▶ | croak 'Invalid request' unless length($request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | ▶ | $identifier->{request} //= $request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$identifier->{"request"} //= $request
MC/DC0%0/2
$identifier->{"request"} //= $request
$identifier->{"request"}
$request
Truth table33%1/3
A //= B
A= $identifier->{"request"}B= $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 2 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 2 | ▶ | if (defined(my $generator = $identifier->{generator}) && defined(my $request = $identifier->{request})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined(my $generator = $identifier->{"generator"}) and defined(my $request = $identifier->{"request"})
MC/DC0%0/2
defined(my $generator = $identifier->{"generator"}) and defined(my $request = $identifier->{"request"})
defined(my $generator = $identifier->{"generator"})
defined(my $request = $identifier->{"request"})
Truth table33%1/3
A and B
A= defined(my $generator = $identifier->{"generator"})B= defined(my $request = $identifier->{"request"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 2 | my $n = eval { Data::Identifier::Generate->generic(generator => $generator, request => $request) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 2 | ▶ | if (defined $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 1 | foreach my $key (qw(displayname displaycolour description icontext)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 4 | ▶ | next unless defined $n->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 1 | ▶ | $identifier->{$key} //= $n->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$identifier->{$key} //= $n->{$key}
MC/DC0%0/2
$identifier->{$key} //= $n->{$key}
$identifier->{$key}
$n->{$key}
Truth table33%1/3
A //= B
A= $identifier->{$key}B= $n->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 2 | return $identifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | # ---- Private helpers ---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 52 | ▶ | sub _normalise_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normalise_args: called CC=5 SCAR=17.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 52 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 52 | ▶ | if (scalar(@args)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 52 | ▶ | if (ref($args[0]) && eval {$args[0]->isa(__PACKAGE__)}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
ref $args[0] and eval {
do {
$args[0]->isa(__PACKAGE__)
}
}
MC/DC50%1/2
ref $args[0] and eval {
do {
$args[0]->isa(__PACKAGE__)
}
}
ref $args[0]
eval {
do {
$args[0]->isa(__PACKAGE__)
}
}
Truth table66%2/3
A and B
A= ref $args[0]B= eval {
do {
$args[0]->isa(__PACKAGE__)
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | # no-op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } elsif ($args[0] eq __PACKAGE__) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 7 | $args[0] = $_DEFAULT_INSTANCE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | unshift(@args, $_DEFAULT_INSTANCE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 52 | return @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | return ($_DEFAULT_INSTANCE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 16 | ▶ | sub _load_well_known { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_well_known: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 16 | state $done = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 1 | my %meta = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | sni => \%_logicals_to_sni, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | sid => \%_logicals_to_sid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 1 | foreach my $type (keys %meta) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 2 | my $hash = $meta{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 2 | foreach my $key (keys %{$hash}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 38 | my $id = Data::Identifier->new($type => $hash->{$key}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 38 | ▶ | next unless defined $id->uuid(no_defaults => 1, default => undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 16 | ▶ | $id->{id_cache} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$id->{"id_cache"} //= {}
MC/DC0%0/1
$id->{"id_cache"} //= {}
$id->{"id_cache"}
Truth table50%1/2
A
A= $id->{"id_cache"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 16 | ▶ | $id->{id_cache}->{$_logical} //= $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$id->{"id_cache"}{$_logical} //= $key
MC/DC0%0/2
$id->{"id_cache"}{$_logical} //= $key
$id->{"id_cache"}{$_logical}
$key
Truth table33%1/3
A //= B
A= $id->{"id_cache"}{$_logical}B= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 16 | $id->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 6 | ▶ | sub _update_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_tag: called CC=7 SCAR=22.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 6 | my ($identifier, $sid, $sni, $tagname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 6 | ▶ | my $id_cache = $identifier->{id_cache} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$identifier->{"id_cache"} //= {}
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table50%1/2
A
A= $identifier->{"id_cache"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 6 | ▶ | $id_cache->{Data::Identifier::WK_SID()} //= $sid if defined $sid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$id_cache->{"f87a38cb-fd13-4e15-866c-e49901adbec5"} //= $sid
MC/DC0%0/2
$id_cache->{"f87a38cb-fd13-4e15-866c-e49901adbec5"} //= $sid
$id_cache->{"f87a38cb-fd13-4e15-866c-e49901adbec5"}
$sid
Truth table33%1/3
A //= B
A= $id_cache->{"f87a38cb-fd13-4e15-866c-e49901adbec5"}B= $sid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 6 | ▶ | $id_cache->{Data::Identifier::WK_SNI()} //= $sni if defined $sni; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$id_cache->{"039e0bb7-5dd3-40ee-a98c-596ff6cce405"} //= $sni
MC/DC0%0/2
$id_cache->{"039e0bb7-5dd3-40ee-a98c-596ff6cce405"} //= $sni
$id_cache->{"039e0bb7-5dd3-40ee-a98c-596ff6cce405"}
$sni
Truth table33%1/3
A //= B
A= $id_cache->{"039e0bb7-5dd3-40ee-a98c-596ff6cce405"}B= $sni
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 6 | ▶ | if (defined $tagname) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 6 | $identifier->_add_tagnames($tagname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 6 | $identifier->register; # re-register | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 6 | return $identifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | # prepares arguments for register_*(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | # Removes any common arguments from %opts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | # does NOT call $identifier->register as register_*() might make additional changes that register needs to know about, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | # so doing it here would just mean to do it twice. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 2 | ▶ | sub _register_base { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_base: called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 2 | my ($self, $identifier, %opts) = _normalise_args(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 2 | $identifier = Data::Identifier->new(from => $identifier); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 2 | ▶ | if (defined(my $displayname = delete $opts{displayname})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | ▶ | $identifier->{displayname} //= $displayname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$identifier->{"displayname"} //= $displayname
MC/DC0%0/2
$identifier->{"displayname"} //= $displayname
$identifier->{"displayname"}
$displayname
Truth table0%0/3
A //= B
A= $identifier->{"displayname"}B= $displayname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 2 | ▶ | if (defined(my $tagname = delete $opts{tagname})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | $identifier->_add_tagnames($tagname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 2 | return ($self, $identifier, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||