DRI/Protocol/Whois/Domain/PT.pm

filter: Statementstmt 15.4% 13 / 84 Branchbran 0.0% 0 / 34 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 12.5% 17 / 136 CC 20 SCAR 40.5
CC
20
Cov
11%
parse_contacts
132.0
parse_ns
30.0
info_parse
20.0
CRAP 57.1
« DRI/Protocol/EPP/Extensions/CentralNic/Pricing.pm ↑ Summary DRI/Protocol/EPP/Extensions/AT/Domain.pm »
1 ## Domain Registry Interface, Whois commands for .SE (RFC3912)
2 ##
3 ## Copyright (c) 2009,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::Whois::Domain::PT;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 =pod
24  
25 =head1 NAME
26  
27 Net::DRI::Protocol::Whois::Domain::PT - .PT Whois commands (RFC3912) for Net::DRI
28  
29 =head1 DESCRIPTION
30  
31 Please see the README file for details.
32  
33 =head1 SUPPORT
34  
35 For now, support questions should be sent to:
36  
37 E<lt>netdri@dotandco.comE<gt>
38  
39 Please also see the SUPPORT file in the distribution.
40  
41 =head1 SEE ALSO
42  
43 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
44  
45 =head1 AUTHOR
46  
47 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
48  
49 =head1 COPYRIGHT
50  
51 Copyright (c) 2009,2013 Patrick Mevzek <netdri@dotandco.com>.
52 All rights reserved.
53  
54 This program is free software; you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
56 the Free Software Foundation; either version 2 of the License, or
57 (at your option) any later version.
58  
59 See the LICENSE file that comes with this distribution for more details.
60  
61 =cut
62  
63 ####################################################################################################
64  
65 sub register_commands
66 {
67 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
68 0 return { 'domain' => { info => [ \&info, \&info_parse ] } };
69 }
70  
71 sub info
72 {
73 0 ▶ my ($po,$domain,$rd)=@_;
Subroutine info: not called CC=2 SCAR=17.9
Pod undocumented
74 0 my $mes=$po->message();
75 0 ▶ Net::DRI::Exception->die(1,'protocol/whois',10,'Invalid domain name: '.$domain) unless Net::DRI::Util::is_hostname($domain);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_hostname($domain) 0 0 0
76 0 $mes->command(lc $domain);
77 0 return;
78 }
79  
80 sub info_parse
81 {
82 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=4 SCAR=30.0
Pod undocumented
83 0 my $mes=$po->message();
84 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
85  
86 0 my $rr=$mes->response();
87 0 my $rd=$mes->response_raw();
88 0 my ($domain,$exist)=parse_domain($po,$rr,$rd,$rinfo);
89 0 ▶ $domain=lc($oname) unless defined($domain);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $domain 0 0 0
90 0 $rinfo->{domain}->{$domain}->{exist}=$exist;
91 0 $rinfo->{domain}->{$domain}->{action}='info';
92  
93 0 ▶ return unless $exist;
Branch: 1 branch
BranchTrueFalseTotal
unless $exist 0 0 0
94  
95 0 parse_dates($po,$domain,$rr,$rinfo);
96 0 parse_contacts($po,$domain,$rr,$rd,$rinfo);
97 0 parse_ns($po,$domain,$rr,$rinfo);
98 0 return;
99 }
100  
101 sub parse_domain
102 {
103 0 ▶ my ($po,$rr,$rd,$rinfo)=@_;
Subroutine parse_domain: not called CC=2 SCAR=17.9
Pod undocumented
104 0 my ($dom,$e);
105  
106 0 ▶ if (exists($rr->{"Nome de dom\x{ED}nio / Domain Name"}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rr->{"Nome de dom\355nio / Domain Name"}) { } 0 0 0
107 {
108 0 $e=1;
109 0 $dom=lc($rr->{"Nome de dom\x{ED}nio / Domain Name"}->[0]);
110 } else
111 {
112 0 $e=0;
113 }
114 0 return ($dom,$e);
115 }
116  
117 sub parse_dates
118 {
119 0 ▶ my ($po,$domain,$rr,$rinfo)=@_;
Subroutine parse_dates: not called CC=1 SCAR=6.9
Pod undocumented
120 0 my $strp=$po->build_strptime_parser(pattern => '%d/%m/%Y', time_zone => 'Europe/Lisbon');
121 0 $rinfo->{domain}->{$domain}->{crDate}=$strp->parse_datetime($rr->{'Data de registo / Creation Date (dd/mm/yyyy)'}->[0]);
122 0 return;
123 }
124  
125 sub parse_contacts
126 {
127 0 ▶ my ($po,$domain,$rr,$rd,$rinfo)=@_;
Subroutine parse_contacts: not called CC=11 SCAR=48.8
Pod undocumented
128 0 my $cs=$po->create_local_object('contactset');
129 0 my @m=qw/name street city pc cc email/;
130 0 my @t=qw/billing admin tech/;
131 0 my $c;
132  
133 0 foreach my $l (@$rd)
134 {
135 0 $l=~s/^\s+//;
136 0 $l=~s/\s+$//;
137  
138 0 ▶ if (($l=~m!Titular / Registrant!)..($l=~m/^\s*$/))
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ m[Titular / Registrant] .. $l =~ /^\s*$/) 0 0 0
139 {
140 0 ▶ next if ($l eq 'Titular / Registrant');
Branch: 1 branch
BranchTrueFalseTotal
if $l eq "Titular / Registrant" 0 0 0
141 0 ▶ if ($l=~m/^\s*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /^\s*$/) 0 0 0
142 {
143 0 $cs->add($c,'registrant');
144 0 $c=undef;
145 0 next;
146 }
147 0 $l=~s/^Email:\s+//;
148 0 ▶ $c=$po->create_local_object('contact') unless defined $c;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $c 0 0 0
149 0 my $m=shift(@m);
150 0 ▶ $c->$m($m eq 'street'? [$l] : $l);
Branch: 1 branch
BranchTrueFalseTotal
$m eq 'street' ? : 0 0 0
151 }
152 0 ▶ if (($l=~m!^(Entidade Gestora / Billing Contact|Respons\x{E1}vel Administrativo / Admin Contact|Respons\x{E1}vel T\x{E9}cnico / Tech Contact)$!)..($l=~m/^\s*$/))
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ m[^(Entidade Gestora / Billing Contact|Respons\x{E1}vel Administrativo / Admin Contact|Respons\x{E1}vel T\x{E9}cnico / Tech Contact)$] .. $l =~ /^\s*$/) 0 0 0
153 {
154 0 ▶ next if $l=~m! / \S+ Contact$!;
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ m[ / \S+ Contact$] 0 0 0
155 0 ▶ if ($l=~m/^\s*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /^\s*$/) 0 0 0
156 {
157 0 $cs->add($c,shift(@t));
158 0 $c=undef;
159 0 next;
160 }
161 0 ▶ if ($l=~s/^Email:\s+//)
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ s/^Email:\s+//) { } 0 0 0
162 {
163 0 $c->email($l);
164 } else
165 {
166 0 $c=$po->create_local_object('contact');
167 0 $c->name($l);
168 }
169 }
170 }
171 0 $rinfo->{domain}->{$domain}->{contact}=$cs;
172 0 return;
173 }
174  
175 sub parse_ns
176 {
177 0 ▶ my ($po,$domain,$rr,$rinfo)=@_;
Subroutine parse_ns: not called CC=5 SCAR=34.0
Pod undocumented
178 0 ▶ return unless (exists($rr->{Nameserver}));
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rr->{"Nameserver"} 0 0 0
179 0 my $h=$po->create_local_object('hosts');
180 0 ▶ foreach my $ns (grep { defined($_) && $_ } @{$rr->{Nameserver}})
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and $_ 0 0 0
181 {
182 0 $h->add($ns);
183 }
184 0 ▶ $rinfo->{domain}->{$domain}->{ns}=$h unless $h->is_empty();
Branch: 1 branch
BranchTrueFalseTotal
unless $h->is_empty 0 0 0
185 0 return;
186 }
187  
188 ####################################################################################################
189 1 1;
« DRI/Protocol/EPP/Extensions/CentralNic/Pricing.pm ↑ Summary DRI/Protocol/EPP/Extensions/AT/Domain.pm »