rdapper.pm

filter: Statementstmt 60.4% 273 / 452 Branchbran 46.1% 96 / 208 Conditioncond 37.5% 36 / 96 MC/DCmcdc 8.6% 5 / 58 Subroutinesub 61.0% 47 / 77 Podpod 2.6% 1 / 38 totaltotal 49.3% 458 / 929 CC 165 SCAR 33.9
CC
165
Cov
54%
domain_search
110.0
print_ip
90.0
main
83.0
CRAP 29.8
↑ Summary rdapper/l10n.pm »
1 package App::rdapper;
2 2 ▶use App::rdapper::l10n;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Encode qw(decode);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use File::ShareDir qw(:ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Getopt::Long qw(GetOptionsFromArray :config pass_through);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use List::Util qw(any min max uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Net::ASN;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Net::DNS::Domain;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Net::IDN::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Net::IP;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Net::RDAP::EPPStatusMap;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Net::RDAP 0.42;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use POSIX qw(setlocale LC_ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Term::Size;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Text::Wrap;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 GETTEXT_DOMAIN => q{rdapper},
22 # see RFC 6350, Section 6.3.1.
23 'ADR_STREET' => 2,
24 'ADR_CITY' => 3,
25 'ADR_SP' => 4,
26 'ADR_PC' => 5,
27 'ADR_CC' => 6,
28 'INDENT' => ' ',
29 'IANA_BASE_URL' => 'https://rdap.iana.org/',
30 2 };
31 2 ▶use locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 2 ▶use vars qw($VERSION $LH);
Subroutine BEGIN: called CC=1 SCAR=0.0
33 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 2 $VERSION = '1.26';
36  
37 2 $LH = App::rdapper::l10n->get_handle;
38  
39 2 $LH->die_for_lookup_failures(1);
40 2 ▶$LH->bindtextdomain(GETTEXT_DOMAIN, $ENV{RDAPPER_LOCALE_DIR} || module_dir(__PACKAGE__));
Condition33%1/3
$ENV{'RDAPPER_LOCALE_DIR'} || module_dir(__PACKAGE__)
l!l&&r!l&&!r
020
MC/DC0%0/2
$ENV{'RDAPPER_LOCALE_DIR'} || module_dir(__PACKAGE__)
$ENV{'RDAPPER_LOCALE_DIR'} module_dir(__PACKAGE__)
Truth table33%1/3
A || B
A= $ENV{'RDAPPER_LOCALE_DIR'}B= module_dir(__PACKAGE__)
ABresult
1X1
011
000
41 2 $LH->textdomain(GETTEXT_DOMAIN);
42  
43 #
44 # global arg variables
45 #
46 my (
47 2 $type, $object, $help, $short, $bypass, $auth, $nopager, $raw, $both,
48 $registrar, $nocolor, $reverse, $version, $search, $debug, $registry,
49 $strings
50 );
51  
52 #
53 # options spec for Getopt::Long
54 #
55 my %opts = (
56 'type:s' => \$type,
57 'object:s' => \$object,
58 'help' => \$help,
59 'short' => \$short,
60 'bypass-cache' => \$bypass,
61 'auth:s' => \$auth,
62 'nopager' => \$nopager, # ignored
63 'raw' => \$raw,
64 'both' => \$both,
65 'registrar' => \$registrar,
66 'registry' => \$registry,
67 'nocolor' => \$nocolor,
68 'reverse' => \$reverse,
69 'version' => \$version,
70 'search' => \$search,
71 'debug' => \$debug,
72 0 ▶ 'autnum' => sub { $type = 'autnum' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 0 ▶ 'domain' => sub { $type = 'domain' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
74 0 ▶ 'nameserver' => sub { $type = 'nameserver' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
75 0 ▶ 'entity' => sub { $type = 'entity' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
76 0 ▶ 'ip' => sub { $type = 'ip' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
77 0 ▶ 'tld' => sub { $type = 'tld' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 0 ▶ 'url' => sub { $type = 'url' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 2 'strings' => \$strings,
80 );
81  
82 my $funcs = {
83 0 ▶ 'ip network' => sub { __PACKAGE__->print_ip(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
84 0 ▶ 'autnum' => sub { __PACKAGE__->print_asn(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
85 6 ▶ 'domain' => sub { __PACKAGE__->print_domain(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
86 24 ▶ 'entity' => sub { __PACKAGE__->print_entity(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
87 0 ▶ 'nameserver' => sub { __PACKAGE__->print_nameserver(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
88 0 ▶ 'help' => sub { 1 }, # help only contains generic properties
Subroutine __ANON__: not called CC=1 SCAR=6.9
89 2 };
90  
91 2 my $OBJECT_TYPE_DISPLAY_NAMES = {
92 'ip network' => _('IP Network'),
93 'autnum' => _('Autonomous System'),
94 'domain' => _('Domain Name'),
95 'entity' => _('Entity'),
96 'nameserver' => _('Nameserver'),
97 'help' => _('Help'),
98 };
99  
100 2 my @ROLE_DISPLAY_NAMES_ORDER = qw(registrant administrative technical billing
101 abuse registrar reseller sponsor proxy notifications noc);
102  
103 2 my %ROLE_DISPLAY_NAMES = (
104 'registrant' => _('Registrant'),
105 'technical' => _('Technical'),
106 'administrative' => _('Administrative'),
107 'abuse' => _('Abuse'),
108 'billing' => _('Billing'),
109 'registrar' => _('Registrar'),
110 'reseller' => _('Reseller'),
111 'sponsor' => _('Sponsor'),
112 'proxy' => _('Proxy'),
113 'notifications' => _('Notifications'),
114 'noc' => _('NOC'),
115 );
116  
117 2 my %EVENT_DISPLAY_NAMES = (
118 'registration' => _('Registration'),
119 'reregistration' => _('Reregistration'),
120 'last changed' => _('Last Changed'),
121 'expiration' => _('Expiration'),
122 'deletion' => _('Deletion'),
123 'reinstantiation' => _('Reinstantiation'),
124 'transfer' => _('Transfer'),
125 'locked' => _('Locked'),
126 'unlocked' => _('Unlocked'),
127 'last update of RDAP database' => _('Last update of RDAP database'),
128 'registrar expiration' => _('Registrar expiration'),
129 'enum validation expiration' => _('ENUM validation expiration'),
130 );
131  
132 2 my %STATUS_DISPLAY_NAMES = (
133 'validated' => _('validated'),
134 'renew prohibited' => _('renew prohibited'),
135 'update prohibited' => _('update prohibited'),
136 'transfer prohibited' => _('transfer prohibited'),
137 'delete prohibited' => _('delete prohibited'),
138 'proxy' => _('proxy'),
139 'private' => _('private'),
140 'removed' => _('removed'),
141 'obscured' => _('obscured'),
142 'associated' => _('associated'),
143 'active' => _('active'),
144 'inactive' => _('inactive'),
145 'locked' => _('locked'),
146 'pending create' => _('pending create'),
147 'pending renew' => _('pending renew'),
148 'pending transfer' => _('pending transfer'),
149 'pending update' => _('pending update'),
150 'pending delete' => _('pending delete'),
151 'add period' => _('add period'),
152 'auto renew period' => _('auto renew period'),
153 'client delete prohibited' => _('client delete prohibited'),
154 'client hold' => _('client hold'),
155 'client renew prohibited' => _('client renew prohibited'),
156 'client transfer prohibited' => _('client transfer prohibited'),
157 'client update prohibited' => _('client update prohibited'),
158 'pending restore' => _('pending restore'),
159 'redemption period' => _('redemption period'),
160 'renew period' => _('renew period'),
161 'server delete prohibited' => _('server delete prohibited'),
162 'server renew prohibited' => _('server renew prohibited'),
163 'server transfer prohibited' => _('server transfer prohibited'),
164 'server update prohibited' => _('server update prohibited'),
165 'server hold' => _('server hold'),
166 'transfer period' => _('transfer period'),
167 'administrative' => _('administrative'),
168 'reserved' => _('reserved'),
169 );
170  
171 2 my @EVENTS = (
172 'registration',
173 'reregistration',
174 'last changed',
175 'expiration',
176 'deletion',
177 'reinstantiation',
178 'transfer',
179 'locked',
180 'unlocked',
181 'last update of RDAP database',
182 'registrar expiration',
183 'enum validation expiration',
184 );
185  
186 2 my %EVENT_DISPLAY_ORDER;
187 2 ▶for (my $i = 0 ; $i < scalar(@EVENTS) ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @EVENTS) 24 2 26
188 24 $EVENT_DISPLAY_ORDER{$EVENTS[$i]} = $i;
189 }
190  
191 2 my %NOTICE_REMARK_TYPE = (
192 'result set truncated due to authorization' => _('result set truncated due to authorization'),
193 'result set truncated due to excessive load' => _('result set truncated due to excessive load'),
194 'result set truncated due to unexplainable reasons' => _('result set truncated due to unexplainable reasons'),
195 'object truncated due to authorization' => _('object truncated due to authorization'),
196 'object truncated due to excessive load' => _('object truncated due to excessive load'),
197 'object truncated due to unexplainable reasons' => _('object truncated due to unexplainable reasons'),
198 'object redacted due to authorization' => _('object redacted due to authorization'),
199 );
200  
201 2 my %VCARD_KIND_DISPLAY_NAME = (
202 'individual' => _('individual'),
203 'group' => _('group'),
204 'org' => _('org'),
205 'location' => _('location'),
206 'application' => _('application'),
207 'device' => _('device'),
208 );
209  
210 2 my @VCARD_DISPLAY_ORDER = qw(SOURCE KIND FN TITLE ROLE ORG ADR GEO EMAIL CONTACT-URI SOCIALPROFILE TEL IMPP URL CATEGORIES NOTE);
211 2 my %VCARD_NODE_NAMES = (
212 ADR => _('Address'),
213 CATEGORIES => _('Categories'),
214 'CONTACT-URI' => _('Contact Link'),
215 EMAIL => _('Email'),
216 FN => _('Name'),
217 GEO => _('Location'),
218 IMPP => _('Messaging'),
219 KIND => _('Kind'),
220 NOTE => _('Note'),
221 ORG => _('Organization'),
222 ROLE => _('Role'),
223 SOCIALPROFILE => _('Profile'),
224 SOURCE => _('Source'),
225 TEL => _('Phone'),
226 TITLE => _('Title'),
227 URL => _('Website'),
228 );
229  
230 2 my %PUBLIC_ID_DISPLAY_NAME = (
231 'IANA Registrar ID' => _('IANA Registrar ID'),
232 );
233  
234 2 my @ADR_DISPLAY_ORDER = (ADR_STREET, ADR_CITY, ADR_SP, ADR_PC, ADR_CC);
235 2 my %ADR_DISPLAY_NAMES = (
236 &ADR_STREET => _('Street'),
237 &ADR_CITY => _('City'),
238 &ADR_SP => _('State/Province'),
239 &ADR_PC => _('Postal Code'),
240 &ADR_CC => _('Country'),
241 );
242  
243 2 my $json = JSON->new->utf8->canonical->pretty->convert_blessed;
244  
245 2 my $rdap;
246  
247 2 my $out = \*STDOUT;
248 2 my $err = \*STDERR;
249  
250 2 $out->binmode(':utf8');
251 2 $err->binmode(':utf8');
252  
253 2 $Text::Wrap::columns = max((Term::Size::chars)[0], 75);
254 2 $Text::Wrap::huge = 'overflow';
255  
256 6 ▶sub main {
Subroutine main: called CC=28 SCAR=44.2
Pod undocumented
257 6 my $package = shift;
258  
259 6 my $rcfile = sprintf(q{%s/.rdapper}, $ENV{HOME});
260 6 ▶ if (-e $rcfile && open(my $fh, $rcfile)) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $rcfile and open my $fh, $rcfile) 0 6 6
Condition33%1/3
-e $rcfile and open my $fh, $rcfile
!ll&&!rl&&r
600
MC/DC0%0/2
-e $rcfile and open my $fh, $rcfile
-e $rcfile open my $fh, $rcfile
Truth table33%1/3
A and B
A= -e $rcfileB= open my $fh, $rcfile
ABresult
0X0
100
111
261 0 push(@_, map { chomp ; $_ } $fh->getlines);
262 0 $fh->close;
263 }
264  
265 6 ▶ GetOptionsFromArray(\@_, %opts) || $package->show_usage;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray(\@_, %opts) or $package->show_usage 6 0 6
266  
267 #
268 # this undocumented behaviour is used to export all the translateable
269 # strings in this file.
270 #
271 6 ▶ export_strings() if ($strings);
Branch: 1 branch
BranchTrueFalseTotal
if $strings 0 6 6
272  
273 6 ▶ $ENV{NET_RDAP_UA_DEBUG} = 1 if ($debug);
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 6 6
274  
275 6 ▶ my $lang = $LH->language_tag || q{en};
Condition50%1/2
$App::rdapper::LH->language_tag || 'en'
l!l
60
MC/DC0%0/1
$App::rdapper::LH->language_tag || 'en'
$App::rdapper::LH->language_tag
Truth table50%1/2
A
A= $App::rdapper::LH->language_tag
Aresult
11
00
276 6 $lang =~ s/_/-/g;
277  
278 6 $rdap = Net::RDAP->new(
279 'use_cache' => !$bypass,
280 'cache_ttl' => 300,
281 'accept_language' => $lang,
282 );
283  
284 6 ▶ $package->show_version if ($version);
Branch: 1 branch
BranchTrueFalseTotal
if $version 0 6 6
285  
286 6 ▶ if ($registry && $registrar) {
Branch: 2 branches
BranchTrueFalseTotal
if ($registry and $registrar) { } 0 6 6
elsif ($registry and $both) { } 0 9 9
Condition66%2/3
$registry and $registrar
!ll&&!rl&&r
330
MC/DC0%0/2
$registry and $registrar
$registry $registrar
Truth table66%2/3
A and B
A= $registryB= $registrar
ABresult
0X0
100
111
287 0 $package->error(_("cannot specify both --registry and --registrar, use one or the other."));
288  
289 ▶ } elsif ($registry && $both) {
Condition66%2/3
$registry and $both
!ll&&!rl&&r
330
MC/DC0%0/2
$registry and $both
$registry $both
Truth table66%2/3
A and B
A= $registryB= $both
ABresult
0X0
100
111
290 0 $package->error(_("cannot specify both --registry and --both, use one or the other."));
291  
292 }
293  
294 6 ▶ $registrar ||= $both;
Condition66%2/3
$registrar ||= $both
l!l&&r!l&&!r
105
MC/DC50%1/2
$registrar ||= $both
$registrar $both
Truth table66%2/3
A ||= B
A= $registrarB= $both
ABresult
1X1
011
000
295  
296 6 ▶ if (!$registry && !$both) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($registry or $both) 3 3 6
Condition66%2/3
$registry or $both
l!l&&r!l&&!r
303
MC/DC50%1/2
$registry or $both
$registry $both
Truth table66%2/3
A or B
A= $registryB= $both
ABresult
1X1
011
000
297 3 $registrar = 1;
298 }
299  
300 6 ▶ $object = shift(@_) if (!$object);
Branch: 1 branch
BranchTrueFalseTotal
unless $object 1 5 6
301  
302 6 ▶ $package->show_usage if ($help || length($object) < 1);
Branch: 1 branch
BranchTrueFalseTotal
if $help or length $object < 1 0 6 6
Condition33%1/3
$help or length $object < 1
l!l&&r!l&&!r
006
MC/DC0%0/2
$help or length $object < 1
$help length $object < 1
Truth table33%1/3
A or B
A= $helpB= length $object < 1
ABresult
1X1
011
000
303  
304 6 ▶ if (!$type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type) 1 5 6
305 0 ▶ if ($object =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { $type = 'ip' }
Branch: 7 branches
BranchTrueFalseTotal
if ($object =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/l) { } 0 1 1
elsif ($object =~ m[^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}$]l) { } 0 1 1
elsif ($object =~ /^[0-9a-f:]+:[0-9a-f:]*$/il) { } 0 1 1
elsif ($object =~ m[^[0-9a-f:]+:[0-9a-f:]*/\d{1,3}$]il) { } 0 1 1
elsif ($object =~ /^asn?\d+$/il) { } 0 1 1
elsif ($object =~ m[^(file|https)?://]l) { } 0 1 1
elsif ($object =~ /^([a-z]{2,}|xn--[a-z0-9\-]+)$/il) { } 0 1 1
306 0 elsif ($object =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}$/) { $type = 'ip' }
307 0 elsif ($object =~ /^[0-9a-f:]+:[0-9a-f:]*$/i) { $type = 'ip' }
308 0 elsif ($object =~ /^[0-9a-f:]+:[0-9a-f:]*\/\d{1,3}$/i) { $type = 'ip' }
309 0 elsif ($object =~ /^asn?\d+$/i) { $type = 'autnum' }
310 0 elsif ($object =~ /^(file|https)?:\/\//) { $type = 'url' }
311 0 elsif ($object =~ /^([a-z]{2,}|xn--[a-z0-9\-]+)$/i) { $type = 'tld' }
312 1 else { $type = 'domain' }
313 }
314  
315 6 my %args;
316 6 ▶ ($args{'user'}, $args{'pass'}) = split(/:/, $auth, 2) if ($auth);
Branch: 1 branch
BranchTrueFalseTotal
if $auth 0 6 6
317  
318 6 ▶ if ($search) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search) { } 0 6 6
319 0 $package->search($rdap, $object, $type, %args);
320  
321 } else {
322 6 $package->lookup($rdap, $object, $type, %args);
323  
324 }
325 }
326  
327 6 ▶sub lookup {
Subroutine lookup: called CC=11 SCAR=43.3
Pod undocumented
328 6 my ($package, $rdap, $object, $type, %args) = @_;
329  
330 6 my $response;
331  
332 6 ▶ if ('ip' eq $type) {
Branch: 7 branches
BranchTrueFalseTotal
if ('ip' eq $type) { } 0 6 6
elsif ('autnum' eq $type) { } 0 6 6
elsif ('domain' eq $type) { } 6 0 6
elsif ('nameserver' eq $type) { } 0 0 0
elsif ('entity' eq $type) { } 0 0 0
elsif ('tld' eq $type) { } 0 0 0
elsif ('url' eq $type) { } 0 0 0
333 0 my $ip = Net::IP->new($object);
334  
335 0 ▶ $package->error(_("invalid IP address '[_1]'", $object)) unless ($ip);
Branch: 1 branch
BranchTrueFalseTotal
unless $ip 0 0 0
336  
337 0 $response = $rdap->ip($ip, %args);
338  
339 0 ▶ $response = $rdap->fetch($response->domain) if ($reverse);
Branch: 1 branch
BranchTrueFalseTotal
if $reverse 0 0 0
340  
341 } elsif ('autnum' eq $type) {
342 0 my $asn = $object;
343 0 $asn =~ s/^asn?//ig;
344  
345 0 $response = $rdap->autnum(Net::ASN->new($asn), %args);
346  
347 } elsif ('domain' eq $type) {
348 6 $response = $rdap->domain(Net::DNS::Domain->new($package->encode_idn($object)), %args);
349  
350 } elsif ('nameserver' eq $type) {
351 0 my $url = Net::RDAP::Registry->get_url(Net::DNS::Domain->new($package->encode_idn($object)));
352  
353 #
354 # munge path
355 #
356 0 my $path = $url->path;
357 0 $path =~ s!/domain/!/nameserver/!;
358 0 $url->path($path);
359  
360 0 $response = $rdap->fetch($url, %args);
361  
362 } elsif ('entity' eq $type) {
363 0 $response = $rdap->entity($object, %args);
364  
365 } elsif ('tld' eq $type) {
366 0 $response = $rdap->fetch(URI->new(IANA_BASE_URL.'domain/'.$package->encode_idn($object)), %args);
367  
368 } elsif ('url' eq $type) {
369 0 my $uri = URI->new($object);
370  
371 #
372 # if the path ends with /help then we assume then it's a help query
373 #
374 0 ▶ $args{'class_override'} = 'help' if ('help' eq lc(($uri->path_segments)[-1]));
Branch: 1 branch
BranchTrueFalseTotal
if "help" eq lc(($uri->path_segments)[-1]) 0 0 0
375  
376 0 $response = $rdap->fetch($uri, %args);
377  
378 } else {
379 0 $package->error(_("Unable to handle type '[_1]'", $type));
380  
381 }
382  
383 6 $package->display($response, 0);
384 }
385  
386 0 ▶sub show_usage {
Subroutine show_usage: not called CC=1 SCAR=6.9
Pod undocumented
387 0 my $package = shift;
388  
389 0 pod2usage(
390 '-input' => __FILE__,
391 '-verbose' => 99,
392 '-sections' => [qw(SYNOPSIS OPTIONS)],
393 );
394 }
395  
396 0 ▶sub show_version {
Subroutine show_version: not called CC=1 SCAR=6.9
Pod undocumented
397 0 my $package = shift;
398 0 $out->say(sprintf('%s v%s', $package, $VERSION));
399 0 exit;
400 }
401  
402 0 ▶sub search {
Subroutine search: not called CC=2 SCAR=17.9
Pod undocumented
403 0 my ($package, $rdap, $object, $type, %args) = @_;
404  
405 0 ▶ if ('domain' eq $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ('domain' eq $type) { } 0 0 0
406 0 $package->domain_search($rdap, $object, %args);
407  
408 } else {
409 0 $package->error(_("current unable to do searches for '[_1]' objects.", $type));
410  
411 }
412 }
413  
414 0 ▶sub domain_search {
Subroutine domain_search: not called CC=10 SCAR=47.0
Pod undocumented
415 0 my ($package, $rdap, $query, %args) = @_;
416  
417 0 my @labels = grep { length > 0 } split(/\./, lc($query), 2);
418  
419 0 my $prefix = shift(@labels);
420 0 ▶ my $suffix = shift(@labels) || '*';
Condition0%0/2
shift @labels || '*'
l!l
00
MC/DC0%0/1
shift @labels || '*'
shift @labels
Truth table0%0/2
A
A= shift @labels
Aresult
11
00
421  
422 0 my $servers = {};
423 0 my $zones = {};
424  
425 0 foreach my $service (Net::RDAP::Registry->load_registry(Net::RDAP::Registry::DNS_URL)->services) {
426 0 foreach my $zone ($service->registries) {
427 0 my $url = Net::RDAP::Registry->get_best_url($service->urls);
428  
429 0 ▶ if (!exists($servers->{$url->as_string})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$servers{$url->as_string}) 0 0 0
430 0 $servers->{$url->as_string} = Net::RDAP::Service->new($url);
431 }
432  
433 0 $zones->{lc($zone)} = $url->as_string;
434 }
435 }
436  
437 0 my @zones = sort(keys(%{$zones}));
438 0 ▶ @zones = grep { lc($suffix) eq $_ || $suffix =~ /\.$_/i } @zones if ($suffix ne '*');
Branch: 1 branch
BranchTrueFalseTotal
if $suffix ne "*" 0 0 0
Condition0%0/3
lc $suffix eq $_ || $suffix =~ /\.$_/il
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $suffix eq $_ || $suffix =~ /\.$_/il
lc $suffix eq $_ $suffix =~ /\.$_/il
Truth table0%0/3
A || B
A= lc $suffix eq $_B= $suffix =~ /\.$_/il
ABresult
1X1
011
000
439  
440 0 foreach my $zone (@zones) {
441 0 my $server = $servers->{$zones->{$zone}};
442 0 my $result = $server->domains(name => $prefix);
443  
444 0 ▶ if ($result->isa('Net::RDAP::Error')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($result->isa('Net::RDAP::Error')) { } 0 0 0
elsif ($result->isa('Net::RDAP::SearchResult')) { } 0 0 0
445 0 $package->warning(sprintf('%s.%s: %s %s', $prefix, $zone, $result->errorCode, $result->title));
446  
447 } elsif ($result->isa('Net::RDAP::SearchResult')) {
448 0 $package->display_domain_search_results($result);
449  
450 }
451 }
452 }
453  
454 0 ▶sub display_domain_search_results {
Subroutine display_domain_search_results: not called CC=2 SCAR=17.9
Pod undocumented
455 0 my ($package, $result) = @_;
456  
457 0 foreach my $domain ($result->domains) {
458 0 $out->say($domain->name->name);
459 }
460 }
461  
462 0 ▶sub display_nameserver_search_results {
Subroutine display_nameserver_search_results: not called CC=2 SCAR=17.9
Pod undocumented
463 0 my ($package, $result) = @_;
464  
465 0 foreach my $nameserver ($result->nameservers) {
466 0 $out->say($nameserver->name->name);
467 }
468 }
469  
470 0 ▶sub display_entity_search_results {
Subroutine display_entity_search_results: not called CC=2 SCAR=17.9
Pod undocumented
471 0 my ($package, $result) = @_;
472  
473 0 foreach my $entity ($result->entities) {
474 0 $out->say($entity->handle);
475 }
476 }
477  
478 0 ▶sub display_search {
Subroutine display_search: not called CC=4 SCAR=30.0
Pod undocumented
479 0 my ($package, $result) = @_;
480  
481 0 ▶ $package->display_domain_search_results($result) if (exists($result->{domainSearchResults}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $result->{"domainSearchResults"} 0 0 0
482 0 ▶ $package->display_nameserver_search_results($result) if (exists($result->{nameserverSearchResults}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $result->{"nameserverSearchResults"} 0 0 0
483 0 ▶ $package->display_entity_search_results($result) if (exists($result->{entitySearchResults}));
Branch: 1 branch
BranchTrueFalseTotal
if exists $result->{"entitySearchResults"} 0 0 0
484 }
485  
486 33 ▶sub display {
Subroutine display: called CC=10 SCAR=29.2
Pod documented
487 33 my ($package, $object, $indent, $nofatal) = @_;
488  
489 33 ▶ if ($object->isa('Net::RDAP::Error')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object->isa('Net::RDAP::Error')) { } 0 33 33
490 0 ▶ if ($nofatal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nofatal) { } 0 0 0
491 0 $package->warning('%03u (%s)', $object->errorCode, $object->title);
492  
493 } else {
494 0 $package->error('%03u (%s)', $object->errorCode, $object->title);
495  
496 }
497  
498 } else {
499 33 ▶ my $link = (grep { 'related' eq $_->rel && $_->is_rdap } $object->links)[0];
Condition66%2/3
'related' eq $_->rel && $_->is_rdap
!ll&&!rl&&r
1506
MC/DC50%1/2
'related' eq $_->rel && $_->is_rdap
'related' eq $_->rel $_->is_rdap
Truth table66%2/3
A && B
A= 'related' eq $_->relB= $_->is_rdap
ABresult
0X0
100
111
500  
501 33 ▶ if ($registrar) {
Branch: 1 branch
BranchTrueFalseTotal
if ($registrar) { } 3 30 33
502 # avoid recursing infinitely
503 3 $registrar = undef;
504  
505 3 ▶ if (!$link) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $link) { } 0 3 3
506 0 $package->display($object, $indent);
507  
508 } else {
509 3 my $result = $rdap->fetch($link);
510  
511 3 ▶ if ($result->isa('Net::RDAP::Error')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->isa('Net::RDAP::Error')) { } 0 3 3
512 0 $package->display($result, $indent, 1);
513  
514 0 $package->warning(_('Unable to retrieve registrar record, displaying the registry record...'));
515 0 $package->display($object, $indent);
516  
517 } else {
518 3 ▶ $package->display($object, $indent, 1) if ($both);
Branch: 1 branch
BranchTrueFalseTotal
if $both 0 3 3
519  
520 3 $package->display($result, $indent);
521  
522 }
523 }
524  
525 } else {
526 30 ▶ if ($raw) {
Branch: 2 branches
BranchTrueFalseTotal
if ($raw) { } 0 30 30
elsif ($object->isa('Net::RDAP::SearchResult')) { } 0 30 30
527 0 $out->print($json->encode($object));
528  
529 } elsif ($object->isa('Net::RDAP::SearchResult')) {
530 0 $package->display_search($object);
531  
532 } else {
533 30 $package->display_object($object, $indent);
534  
535 }
536 }
537 }
538 }
539  
540 30 ▶sub display_object {
Subroutine display_object: called CC=18 SCAR=29.8
Pod undocumented
541 30 my ($package, $object, $indent) = @_;
542  
543 30 ▶ $package->error(_("object does not include the 'objectClassName' properties")) unless ($object->class);
Branch: 1 branch
BranchTrueFalseTotal
unless $object->class 0 30 30
544 30 ▶ $package->error(_("unknown object type '[_1]'", $object->class)) unless ($funcs->{$object->class});
Branch: 1 branch
BranchTrueFalseTotal
unless $$funcs{$object->class} 0 30 30
545  
546 #
547 # generic properties
548 #
549 30 ▶ $package->print_kv(_('Object type'), $OBJECT_TYPE_DISPLAY_NAMES->{$object->class}, $indent) if ($indent < 1);
Branch: 1 branch
BranchTrueFalseTotal
if $indent < 1 6 24 30
550 30 ▶ $package->print_kv(_('URL'), u($object->self->href), $indent) if ($indent < 1 && $object->self);
Branch: 1 branch
BranchTrueFalseTotal
if $indent < 1 and $object->self 6 24 30
Condition66%2/3
$indent < 1 and $object->self
!ll&&!rl&&r
2406
MC/DC50%1/2
$indent < 1 and $object->self
$indent < 1 $object->self
Truth table66%2/3
A and B
A= $indent < 1B= $object->self
ABresult
0X0
100
111
551  
552 30 ▶ if ($object->can('name')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object->can("name")) 6 24 30
553 6 my $name = $object->name;
554 6 ▶ $name = $name->name if ($name->can('name'));
Branch: 1 branch
BranchTrueFalseTotal
if $name->can("name") 6 0 6
555  
556 6 ▶ my $xname = $object->can('unicodeName') ? $object->unicodeName || $name : $name;
Branch: 1 branch
BranchTrueFalseTotal
$object->can('unicodeName') ? : 6 0 6
Condition66%2/3
$object->unicodeName or $name
l!l&&r!l&&!r
330
MC/DC0%0/2
$object->unicodeName or $name
$object->unicodeName $name
Truth table66%2/3
A or B
A= $object->unicodeNameB= $name
ABresult
1X1
011
000
557  
558 6 ▶ if ($xname ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xname ne $name) { } 0 6 6
559 0 $package->print_kv(_('Name'), sprintf('%s (%s)', uc($xname), uc($name)));
560  
561 } else {
562 6 $package->print_kv(_('Name'), uc($name));
563  
564 }
565 }
566  
567 #
568 # object-specific properties
569 #
570 30 $funcs->{$object->class}->($object, $indent);
571  
572 #
573 # more generic properties
574 #
575 30 $package->print_events($object, $indent);
576 30 $package->print_status($object, $indent, ('domain' eq $object->class));
577  
578 30 $package->print_entities($object, $indent);
579  
580 #
581 # links, remarks, notices and redactions, unless --short has been passed
582 #
583 30 ▶ if (!$short) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($short) 30 0 30
584 30 foreach my $link (grep { 'self' ne $_->rel } $object->links) {
585 6 $package->print_link($link, $indent);
586 }
587  
588 30 foreach my $remark ($object->remarks) {
589 0 $package->print_remark_or_notice($remark, $indent);
590 }
591  
592 30 foreach my $notice ($object->notices) {
593 18 $package->print_remark_or_notice($notice, $indent);
594 }
595  
596 30 my @fields = $object->redactions;
597 30 ▶ if (scalar(@fields) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @fields > 0) 3 27 30
598 3 $package->print_kv(_('Redacted Fields'), '', $indent);
599 3 foreach my $field (@fields) {
600 3 $out->print(wrap(
601 (INDENT x ($indent + 1)),
602 (INDENT x ($indent + 2)),
603 sprintf("%s %s\n", b('*'), _("[_1] (reason: [_2])", $field->name, $field->reason))
604 ));
605 }
606 }
607 }
608  
609 30 ▶ $out->print("\n") if ($indent < 1);
Branch: 1 branch
BranchTrueFalseTotal
if $indent < 1 6 24 30
610 }
611  
612 0 ▶sub print_ip {
Subroutine print_ip: not called CC=9 SCAR=45.0
Pod undocumented
613 0 my ($package, $ip, $indent) = @_;
614  
615 0 ▶ $package->print_kv(_('Handle'), $ip->handle, $indent) if ($ip->handle);
Branch: 1 branch
BranchTrueFalseTotal
if $ip->handle 0 0 0
616 0 ▶ $package->print_kv(_('Version'), $ip->version, $indent) if ($ip->version);
Branch: 1 branch
BranchTrueFalseTotal
if $ip->version 0 0 0
617 0 ▶ $package->print_kv(_('Domain'), u($ip->domain->as_string), $indent) if ($ip->domain);
Branch: 1 branch
BranchTrueFalseTotal
if $ip->domain 0 0 0
618 0 ▶ $package->print_kv(_('Type'), $ip->type, $indent) if ($ip->type);
Branch: 1 branch
BranchTrueFalseTotal
if $ip->type 0 0 0
619 0 ▶ $package->print_kv(_('Country'), $ip->country, $indent) if ($ip->country);
Branch: 1 branch
BranchTrueFalseTotal
if $ip->country 0 0 0
620 0 ▶ $package->print_kv(_('Parent'), $ip->parentHandle, $indent) if ($ip->parentHandle);
Branch: 1 branch
BranchTrueFalseTotal
if $ip->parentHandle 0 0 0
621 0 ▶ $package->print_kv(_('Range'), $ip->range->prefix, $indent) if ($ip->range);
Branch: 1 branch
BranchTrueFalseTotal
if $ip->range 0 0 0
622  
623 0 foreach my $cidr ($ip->cidrs) {
624 0 $package->print_kv(_('CIDR'), $cidr->prefix, $indent);
625 }
626 }
627  
628 0 ▶sub print_asn {
Subroutine print_asn: not called CC=6 SCAR=37.4
Pod undocumented
629 0 my ($package, $asn, $indent) = @_;
630  
631 0 ▶ $package->print_kv(_('Handle'), $asn->handle, $indent) if ($asn->handle);
Branch: 1 branch
BranchTrueFalseTotal
if $asn->handle 0 0 0
632 0 ▶ $package->print_kv(_('Range'), sprintf('%u - %u', $asn->start, $asn->end), $indent) if ($asn->start > 0 && $asn->end > 0 && $asn->end > $asn->start);
Branch: 1 branch
BranchTrueFalseTotal
if $asn->start > 0 and $asn->end > 0 and $asn->end > $asn->start 0 0 0
Condition0%0/6
$asn->start > 0 and $asn->end > 0 and $asn->end > $asn->start
!ll&&!rl&&r
000
$asn->start > 0 and $asn->end > 0
!ll&&!rl&&r
000
MC/DC0%0/3
$asn->start > 0 and $asn->end > 0 and $asn->end > $asn->start
$asn->start > 0 $asn->end > 0 $asn->end > $asn->start
Truth table0%0/4
A and B and C
A= $asn->start > 0B= $asn->end > 0C= $asn->end > $asn->start
ABCresult
0XX0
10X0
1100
1111
633 0 ▶ $package->print_kv(_('Type'), $asn->type, $indent) if ($asn->type);
Branch: 1 branch
BranchTrueFalseTotal
if $asn->type 0 0 0
634 }
635  
636 6 ▶sub print_domain {
Subroutine print_domain: called CC=10 SCAR=24.8
Pod undocumented
637 6 my ($package, $domain, $indent) = @_;
638  
639 6 ▶ $package->print_kv(_('Handle'), $domain->handle, $indent) if ($domain->handle);
Branch: 1 branch
BranchTrueFalseTotal
if $domain->handle 3 3 6
640  
641 6 foreach my $ns (sort { lc($a->name->name) cmp lc($b->name->name) } $domain->nameservers) {
642 12 ▶ if ($short) {
Branch: 1 branch
BranchTrueFalseTotal
if ($short) { } 0 12 12
643 0 $package->print_kv(_('Nameserver'), uc($ns->name->name) . ' ' . join(' ', map { $_->short } $ns->addresses), $indent);
644  
645 } else {
646 12 $package->print_kv(_('Nameserver'), uc($ns->name->name), $indent);
647 12 $package->print_nameserver($ns, 1+$indent);
648 }
649 }
650  
651 6 foreach my $ds ($domain->ds) {
652 3 $package->print_kv(_('DS Record'), $ds->plain, $indent);
653 }
654  
655 6 foreach my $key ($domain->keys) {
656 0 $package->print_kv(_('DNSKEY Record'), $key->plain, $indent);
657 }
658  
659 6 ▶ $package->display_artRecord($domain->{'artRecord_record'}, $indent) if ($domain->{'artRecord_record'});
Branch: 1 branch
BranchTrueFalseTotal
if $domain->{"artRecord_record"} 0 6 6
660 6 ▶ $package->display_platform_nameservers($domain->{'platformNS_nameservers'}, $indent) if ($domain->{'platformNS_nameservers'});
Branch: 1 branch
BranchTrueFalseTotal
if $domain->{"platformNS_nameservers"} 0 6 6
661  
662 6 ▶ $package->print_kv(_('Registration Type'), $domain->{'regType_regType'}) if ($domain->{'regType_regType'});
Branch: 1 branch
BranchTrueFalseTotal
if $domain->{"regType_regType"} 0 6 6
663  
664 6 my @types = $domain->dns_ttl_types;
665 6 ▶ $package->display_ttl_values($domain, $indent) if (scalar(@types) > 0);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @types > 0 0 6 6
666 }
667  
668 0 ▶sub display_artRecord {
Subroutine display_artRecord: not called CC=2 SCAR=17.9
Pod undocumented
669 0 my ($package, $records, $indent) = @_;
670  
671 0 $package->print_kv(_('Art Record'), undef, $indent);
672  
673 0 foreach my $record (@{$records}) {
674 0 $package->print_kv($record->{'name'}, $record->{'value'}, 1+$indent);
675 }
676 }
677  
678 0 ▶sub display_platform_nameservers {
Subroutine display_platform_nameservers: not called CC=2 SCAR=17.9
Pod undocumented
679 0 my ($package, $nameservers, $indent) = @_;
680  
681 0 foreach my $ns (@{$nameservers}) {
682 0 $package->print_kv(_('Platform Nameserver'), uc(Net::RDAP::Object::Nameserver->new($ns)->name->name), $indent);
683 }
684 }
685  
686 24 ▶sub print_entity {
Subroutine print_entity: called CC=6 SCAR=19.3
Pod undocumented
687 24 my ($package, $entity, $indent) = @_;
688  
689 24 ▶ $package->print_kv(_('Handle'), $entity->handle, $indent) if ($entity->handle && $indent < 1);
Branch: 1 branch
BranchTrueFalseTotal
if $entity->handle and $indent < 1 0 24 24
Condition66%2/3
$entity->handle and $indent < 1
!ll&&!rl&&r
3210
MC/DC0%0/2
$entity->handle and $indent < 1
$entity->handle $indent < 1
Truth table66%2/3
A and B
A= $entity->handleB= $indent < 1
ABresult
0X0
100
111
690  
691 24 foreach my $id ($entity->ids) {
692 6 ▶ $package->print_kv($PUBLIC_ID_DISPLAY_NAME{$id->type} || $id->type, $id->identifier, $indent);
Condition33%1/3
$PUBLIC_ID_DISPLAY_NAME{$id->type} || $id->type
l!l&&r!l&&!r
600
MC/DC0%0/2
$PUBLIC_ID_DISPLAY_NAME{$id->type} || $id->type
$PUBLIC_ID_DISPLAY_NAME{$id->type} $id->type
Truth table33%1/3
A || B
A= $PUBLIC_ID_DISPLAY_NAME{$id->type}B= $id->type
ABresult
1X1
011
000
693 }
694  
695 24 my $jcard = $entity->jcard;
696 24 ▶ if ($jcard) {
Branch: 1 branch
BranchTrueFalseTotal
if ($jcard) 24 0 24
697 24 $package->print_jcard($jcard, $indent);
698 }
699 }
700  
701 24 ▶sub print_jcard {
Subroutine print_jcard: called CC=3 SCAR=11.0
Pod undocumented
702 24 my ($package, $jcard, $indent) = @_;
703  
704 24 foreach my $ptype (@VCARD_DISPLAY_ORDER) {
705 384 foreach my $property (grep { $_->value } $jcard->properties($ptype)) {
706 99 $package->print_jcard_property($property, $indent);
707 }
708 }
709 }
710  
711 99 ▶sub print_jcard_property {
Subroutine print_jcard_property: called CC=9 SCAR=22.5
Pod undocumented
712 99 my ($package, $property, $indent) = @_;
713  
714 99 ▶ if ('ADR' eq uc($property->type)) {
Branch: 1 branch
BranchTrueFalseTotal
if ('ADR' eq uc $property->type) { } 12 87 99
715 12 $package->print_jcard_adr($property, $indent);
716  
717 } else {
718 87 ▶ my $label = $VCARD_NODE_NAMES{uc($property->type)} || ucfirst(lc($property->type));
Condition33%1/3
$VCARD_NODE_NAMES{uc $property->type} || ucfirst lc $property->type
l!l&&r!l&&!r
8700
MC/DC0%0/2
$VCARD_NODE_NAMES{uc $property->type} || ucfirst lc $property->type
$VCARD_NODE_NAMES{uc $property->type} ucfirst lc $property->type
Truth table33%1/3
A || B
A= $VCARD_NODE_NAMES{uc $property->type}B= ucfirst lc $property->type
ABresult
1X1
011
000
719 87 my $value = $property->value;
720  
721 87 ▶ if ('KIND' eq uc($property->type)) {
Branch: 2 branches
BranchTrueFalseTotal
if ('KIND' eq uc $property->type) { } 18 69 87
elsif ('TEL' eq uc $property->type) { } 18 51 69
722 18 ▶ $value = $VCARD_KIND_DISPLAY_NAME{$value} || $value;
Condition33%1/3
$VCARD_KIND_DISPLAY_NAME{$value} || $value
l!l&&r!l&&!r
0180
MC/DC0%0/2
$VCARD_KIND_DISPLAY_NAME{$value} || $value
$VCARD_KIND_DISPLAY_NAME{$value} $value
Truth table33%1/3
A || B
A= $VCARD_KIND_DISPLAY_NAME{$value}B= $value
ABresult
1X1
011
000
723  
724 } elsif ('TEL' eq uc($property->type)) {
725 18 my $types = $property->param('type');
726 18 ▶ $types = [ $types ] if (q{ARRAY} ne ref($types));
Branch: 1 branch
BranchTrueFalseTotal
if "ARRAY" ne ref $types 3 15 18
727  
728 18 ▶ if (any { 'fax' eq lc($_) } @{$types}) {
Subroutine __ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { 'fax' eq lc $_; } , @{$types;})) { } 0 18 18
729 0 $label = _('Fax');
730  
731 } else {
732 18 $label = _('Phone');
733  
734 }
735 }
736  
737 $package->print_kv(
738 87 ▶ $label,
Branch: 1 branch
BranchTrueFalseTotal
$property->may_be_uri ? : 36 51 87
739 $property->may_be_uri ? u($value) : $value,
740 $indent
741 );
742 }
743 }
744  
745 12 ▶sub print_jcard_adr {
Subroutine print_jcard_adr: called CC=7 SCAR=22.4
Pod undocumented
746 12 my ($package, $property, $indent) = @_;
747  
748 12 $package->print_kv(_('Address'), '', $indent);
749  
750 12 ▶ if ($property->param('label')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($property->param('label')) { } 0 12 12
751 0 $out->print(wrap(
752 INDENT x ($indent + 1),
753 INDENT x ($indent + 1),
754 $property->param('label'),
755 )."\n");
756  
757 } else {
758 12 foreach my $i (@ADR_DISPLAY_ORDER) {
759 60 ▶ if ($property->value->[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($property->value->[$i]) 36 24 60
760 36 ▶ if ('ARRAY' eq ref($property->value->[$i])) {
Branch: 1 branch
BranchTrueFalseTotal
if ('ARRAY' eq ref $property->value->[$i]) { } 0 36 36
761 0 foreach my $v (grep { $_ } @{$property->value->[$i]}) {
762 0 $package->print_kv($ADR_DISPLAY_NAMES{$i}, $v, $indent+1);
763 }
764  
765 } else {
766 36 $package->print_kv($ADR_DISPLAY_NAMES{$i}, $property->value->[$i], $indent+1);
767  
768 }
769 }
770 }
771 }
772  
773 12 ▶ if ($property->param('cc')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($property->param("cc")) 12 0 12
774 12 $package->print_kv(_('Country'), $property->param('cc'), $indent+1);
775 }
776 }
777  
778 12 ▶sub print_nameserver {
Subroutine print_nameserver: called CC=4 SCAR=14.2
Pod undocumented
779 12 my ($package, $nameserver, $indent) = @_;
780  
781 12 ▶ $package->print_kv(_('Handle'), $nameserver->handle, $indent) if ($nameserver->handle);
Branch: 1 branch
BranchTrueFalseTotal
if $nameserver->handle 6 6 12
782  
783 12 foreach my $ip ($nameserver->addresses) {
784 0 $package->print_kv(_('IP Address'), $ip->short, $indent);
785 }
786  
787 12 my @types = $nameserver->dns_ttl_types;
788 12 ▶ $package->display_ttl_values($nameserver, $indent) if (scalar(@types) > 0);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @types > 0 0 12 12
789 }
790  
791 30 ▶sub print_events {
Subroutine print_events: called CC=4 SCAR=15.2
Pod undocumented
792 30 my ($package, $object, $indent) = @_;
793  
794 30 foreach my $event (sort { $EVENT_DISPLAY_ORDER{$a->action} - $EVENT_DISPLAY_ORDER{$b->action} } $object->events) {
795 42 ▶ my $action = $EVENT_DISPLAY_NAMES{$event->action} || ucfirst($event->action);
Condition33%1/3
$EVENT_DISPLAY_NAMES{$event->action} || ucfirst $event->action
l!l&&r!l&&!r
4200
MC/DC0%0/2
$EVENT_DISPLAY_NAMES{$event->action} || ucfirst $event->action
$EVENT_DISPLAY_NAMES{$event->action} ucfirst $event->action
Truth table33%1/3
A || B
A= $EVENT_DISPLAY_NAMES{$event->action}B= ucfirst $event->action
ABresult
1X1
011
000
796  
797 42 ▶ if ($event->actor) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->actor) { } 0 42 42
798 0 $package->print_kv($action, _('[_1] (by [_2])', scalar($event->date), $event->actor), $indent);
799  
800 } else {
801 42 $package->print_kv($action, scalar($event->date).$event->date_tz, $indent);
802  
803 }
804 }
805 }
806  
807 30 ▶sub print_status {
Subroutine print_status: called CC=7 SCAR=24.5
Pod undocumented
808 30 my ($package, $object, $indent, $is_domain) = @_;
809  
810 30 foreach my $status ($object->status) {
811  
812 9 my $epp = rdap2epp($status);
813 9 ▶ if ($epp && $is_domain && !$short) {
Branch: 1 branch
BranchTrueFalseTotal
if ($epp and $is_domain and not $short) { } 9 0 9
Condition33%2/6
$epp and $is_domain and not $short
!ll&&!rl&&r
009
$epp and $is_domain
!ll&&!rl&&r
009
MC/DC0%0/3
$epp and $is_domain and not $short
$epp $is_domain not $short
Truth table25%1/4
A and B and not(C)
A= $eppB= $is_domainC= not $short
ABCresult
0XX0
10X0
1100
1111
814 9 ▶ my $friendly = $STATUS_DISPLAY_NAMES{$status} || $status;
Condition33%1/3
$STATUS_DISPLAY_NAMES{$status} || $status
l!l&&r!l&&!r
900
MC/DC0%0/2
$STATUS_DISPLAY_NAMES{$status} || $status
$STATUS_DISPLAY_NAMES{$status} $status
Truth table33%1/3
A || B
A= $STATUS_DISPLAY_NAMES{$status}B= $status
ABresult
1X1
011
000
815 9 ▶ if ($friendly ne $status) {
Branch: 1 branch
BranchTrueFalseTotal
if ($friendly ne $status) { } 0 9 9
816 0 $package->print_kv(_('Status'), _('[_1] ([_2], EPP: [_3], [_4])', $friendly, $status, $epp, u(sprintf('https://icann.org/epp#%s', $epp))), $indent);
817  
818 } else {
819 9 $package->print_kv(_('Status'), _('[_1] (EPP: [_2], [_3])', $status, $epp, u(sprintf('https://icann.org/epp#%s', $epp))), $indent);
820  
821 }
822  
823 } else {
824 0 $package->print_kv(_('Status'), $status, $indent);
825  
826 }
827 }
828 }
829  
830 30 ▶sub print_entities {
Subroutine print_entities: called CC=9 SCAR=22.1
Pod undocumented
831 30 my ($package, $object, $indent) = @_;
832  
833 30 my @entities = $object->entities;
834  
835 30 my %seen;
836 30 foreach my $role (@ROLE_DISPLAY_NAMES_ORDER) {
837 330 ▶ for (my $i = 0 ; $i < scalar(@entities) ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @entities) 264 330 594
838 264 ▶ next if ($seen{$i});
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$i} 168 96 264
839  
840 96 my $entity = $entities[$i];
841 96 ▶ if (any { $role eq $_ } $entity->roles) {
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $role eq $_; } , $entity->roles)) 24 72 96
842 24 $seen{$i} = 1;
843  
844 24 ▶ my $rstring = join(', ', map { _('[_1] Contact', $ROLE_DISPLAY_NAMES{$_} || ucfirst($_)) } $entity->roles);
Condition33%1/3
$ROLE_DISPLAY_NAMES{$_} || ucfirst $_
l!l&&r!l&&!r
2400
MC/DC0%0/2
$ROLE_DISPLAY_NAMES{$_} || ucfirst $_
$ROLE_DISPLAY_NAMES{$_} ucfirst $_
Truth table33%1/3
A || B
A= $ROLE_DISPLAY_NAMES{$_}B= ucfirst $_
ABresult
1X1
011
000
845  
846 24 ▶ if ($entity->handle && 'not applicable' ne $entity->handle && 'HANDLE REDACTED FOR PRIVACY' ne $entity->handle) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entity->handle and 'not applicable' ne $entity->handle and 'HANDLE REDACTED FOR PRIVACY' ne $entity->handle) { } 21 3 24
Condition66%4/6
$entity->handle and "not applicable" ne $entity->handle and "HANDLE REDACTED FOR PRIVACY" ne $entity->handle
!ll&&!rl&&r
3021
$entity->handle and "not applicable" ne $entity->handle
!ll&&!rl&&r
3021
MC/DC33%1/3
$entity->handle and "not applicable" ne $entity->handle and "HANDLE REDACTED FOR PRIVACY" ne $entity->handle
$entity->handle "not applicable" ne $entity->handle "HANDLE REDACTED FOR PRIVACY" ne $entity->handle
Truth table50%2/4
A and B and C
A= $entity->handleB= "not applicable" ne $entity->handleC= "HANDLE REDACTED FOR PRIVACY" ne $entity->handle
ABCresult
0XX0
10X0
1100
1111
847 21 $package->print_kv($rstring, $entity->handle, $indent);
848  
849 } else {
850 3 $package->print_kv($rstring, undef, $indent);
851  
852 }
853  
854 24 eval {
855 24 $package->display($entity, 1+$indent, 1);
856 };
857 }
858 }
859 }
860 }
861  
862 18 ▶sub print_remark_or_notice {
Subroutine print_remark_or_notice: called CC=7 SCAR=27.8
Pod undocumented
863 18 my ($package, $thing, $indent) = @_;
864  
865 18 ▶ my $type = ($thing->isa('Net::RDAP::Notice') ? _('Notice') : _('Remark'));
Branch: 1 branch
BranchTrueFalseTotal
$thing->isa('Net::RDAP::Notice') ? : 18 0 18
866  
867 18 ▶ if (1 == scalar($thing->description)) {
Branch: 1 branch
BranchTrueFalseTotal
if (1 == scalar $thing->description) { } 18 0 18
868 18 ▶ $package->print_kv($thing->title || $type, ($thing->description)[0], $indent);
Condition33%1/3
$thing->title || $type
l!l&&r!l&&!r
1800
MC/DC0%0/2
$thing->title || $type
$thing->title $type
Truth table33%1/3
A || B
A= $thing->titleB= $type
ABresult
1X1
011
000
869  
870 } else {
871 0 ▶ $package->print_kv($thing->title || $NOTICE_REMARK_TYPE{$thing->type} || $type, , '', $indent);
Condition0%0/6
$thing->title || $NOTICE_REMARK_TYPE{$thing->type} || $type
l!l&&r!l&&!r
000
$thing->title or $NOTICE_REMARK_TYPE{$thing->type}
l!l&&r!l&&!r
000
MC/DC0%0/3
$thing->title || $NOTICE_REMARK_TYPE{$thing->type} || $type
$thing->title $NOTICE_REMARK_TYPE{$thing->type} $type
Truth table0%0/4
A or B || C
A= $thing->titleB= $NOTICE_REMARK_TYPE{$thing->type}C= $type
ABCresult
1XX1
01X1
0011
0000
872  
873 0 $out->print(fill(
874 (INDENT x (1+$indent)),
875 (INDENT x (1+$indent)),
876 $thing->description
877 )."\n");
878 }
879  
880 18 foreach my $link ($thing->links) {
881 18 $package->print_link($link, 1+$indent);
882 }
883 }
884  
885 24 ▶sub print_link {
Subroutine print_link: called CC=4 SCAR=15.2
Pod undocumented
886 24 my ($package, $link, $indent) = @_;
887  
888 24 ▶ $package->print_kv(
Branch: 1 branch
BranchTrueFalseTotal
'related' eq $link->rel ? : 12 12 24
Condition40%2/5
$link->title || ('related' eq $link->rel ? 'Link' : ucfirst $link->rel) || 'Link'
l!l
240
$link->title or "related" eq $link->rel ? "Link" : ucfirst $link->rel
l!l&&r!l&&!r
0240
MC/DC0%0/2
$link->title || ('related' eq $link->rel ? 'Link' : ucfirst $link->rel) || 'Link'
$link->title "related" eq $link->rel ? "Link" : ucfirst $link->rel
Truth table33%1/3
A or B
A= $link->titleB= "related" eq $link->rel ? "Link" : ucfirst $link->rel
ABresult
1X1
011
000
889 $link->title || ('related' eq $link->rel ? 'Link' : ucfirst($link->rel)) || 'Link',
890 u($link->href->as_string),
891 $indent,
892 );
893 }
894  
895 0 ▶sub display_ttl_values {
Subroutine display_ttl_values: not called CC=3 SCAR=24.8
Pod undocumented
896 0 my ($package, $object, $indent) = @_;
897  
898 0 $package->print_kv(_('DNS TTL Values'), '', $indent);
899  
900 0 foreach my $type ($object->dns_ttl_types) {
901 0 $package->print_kv($type, _('[_1]s', $object->dns_ttl($type)), 1+$indent);
902 }
903  
904 0 foreach my $remark ($object->dns_ttl_remarks) {
905 0 $package->print_remark_or_notice($remark, 1+$indent);
906 }
907 }
908  
909 315 ▶sub print_kv {
Subroutine print_kv: called CC=1 SCAR=0.0
Pod undocumented
910 315 my ($package, $name, $value, $indent) = @_;
911  
912 315 $out->print(wrap(
913 (INDENT x $indent),
914 (INDENT x ($indent + 1)),
915 sprintf("%s %s\n", b($name.':'), $value),
916 ));
917 }
918  
919 0 ▶sub debug {
Subroutine debug: not called CC=2 SCAR=17.9
Pod undocumented
920 0 my ($package, $fmt, @params) = @_;
921 0 ▶ if ($debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 0 0
922 0 my $str = sprintf(_("Debug: [_1]", $fmt), @params);
923 0 $err->say(colourise([qw(magenta)], $str));
924 }
925 }
926  
927 0 ▶sub info {
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
928 0 my ($package, $fmt, @params) = @_;
929 0 my $str = sprintf(_("Info: [_1]", $fmt), @params);
930 0 $err->say(colourise([qw(cyan)], $str));
931 }
932  
933 0 ▶sub warning {
Subroutine warning: not called CC=1 SCAR=6.9
Pod undocumented
934 0 my ($package, $fmt, @params) = @_;
935 0 my $str = sprintf(_("Warning: [_1]", $fmt), @params);
936 0 $err->say(colourise([qw(yellow)], $str));
937 }
938  
939 0 ▶sub error {
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
940 0 my ($package, $fmt, @params) = @_;
941 0 my $str = sprintf(_("Error: [_1]", $fmt), @params);
942 0 $err->say(colourise([qw(red)], $str));
943 0 exit 1;
944 }
945  
946 393 ▶sub colourise {
Subroutine colourise: called CC=3 SCAR=13.3
Pod undocumented
947 393 my ($cref, $str) = @_;
948  
949 393 ▶ if (-t $out && !$nocolor) {
Branch: 1 branch
BranchTrueFalseTotal
if (-t $out and not $nocolor) { } 0 393 393
Condition33%1/3
-t $out and not $nocolor
!ll&&!rl&&r
39300
MC/DC0%0/2
-t $out and not $nocolor
-t $out not $nocolor
Truth table33%1/3
A and not(B)
A= -t $outB= not $nocolor
ABresult
0X0
100
111
950 0 return colored($cref, $str);
951  
952 } else {
953 393 return $str;
954  
955 }
956 }
957  
958 75 ▶sub u { colourise([qw(underline)], shift) }
Subroutine u: called CC=1 SCAR=0.0
Pod undocumented
959 318 ▶sub b { colourise([qw(bold)], shift) }
Subroutine b: called CC=1 SCAR=0.0
Pod undocumented
960 350 ▶sub _ { decode($LH->encoding, $LH->maketext(@_)) }
Subroutine _: called CC=1 SCAR=0.0
961  
962 #
963 # this function uses PPI to parse this file, extract the messages passed to _()
964 # and prints a .po file on STDOUT.
965 #
966 0 ▶sub export_strings {
Subroutine export_strings: not called CC=7 SCAR=40.3
Pod undocumented
967 0 eval {
968 0 require PPI;
969  
970 0 my $doc = PPI::Document->new(__FILE__);
971 0 $doc->prune(q{PPI::Token::Comment});
972 0 $doc->prune(q{PPI::Token::Whitespace});
973  
974 0 my @msgs;
975  
976 0 ▶ my @nodes = @{$doc->find(sub { 1 })};
Subroutine __ANON__: not called CC=1 SCAR=6.9
977 0 ▶ for (my $i = 0 ; $i < scalar(@nodes) ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @nodes) 0 0 0
978 0 my $node = $nodes[$i];
979  
980 0 ▶ if ($node->isa(q{PPI::Token::Magic}) && q{_} eq $node->content) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("PPI::Token::Magic") and "_" eq $node->content) 0 0 0
Condition0%0/3
$node->isa("PPI::Token::Magic") and "_" eq $node->content
!ll&&!rl&&r
000
MC/DC0%0/2
$node->isa("PPI::Token::Magic") and "_" eq $node->content
$node->isa("PPI::Token::Magic") "_" eq $node->content
Truth table0%0/3
A and B
A= $node->isa("PPI::Token::Magic")B= "_" eq $node->content
ABresult
0X0
100
111
981 0 my $next = $nodes[$i+1];
982  
983 0 ▶ if ($next->isa(q{PPI::Structure::List})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next->isa("PPI::Structure::List")) 0 0 0
984 0 my $msg = ($next->tokens)[1];
985  
986 0 ▶ if (!$msg->isa(q{PPI::Token::Quote})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($msg->isa("PPI::Token::Quote")) 0 0 0
987 0 die(sprintf(
988 "%s: first argument to _() must be a string literal",
989 $msg->content,
990 ));
991 }
992  
993 0 push(@msgs, $msg->string);
994 }
995 }
996 }
997  
998 0 foreach my $msg (uniq(@msgs)) {
999 0 printf("msgid \"%s\"\nmsgstr \"\"\n\n", $msg);
1000 }
1001 };
1002  
1003 0 exit;
1004 }
1005  
1006 6 ▶sub encode_idn {
Subroutine encode_idn: called CC=1 SCAR=0.0
Pod undocumented
1007 6 my ($package, $name) = @_;
1008 6 return Net::IDN::PP->encode($name);
1009 }
1010  
1011 2 1;
1012  
1013 __END__
↑ Summary rdapper/l10n.pm »