DRI/Protocol/Whois/Message.pm

filter: Statementstmt 40.0% 20 / 50 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 54.5% 6 / 11 Podpod 20.0% 1 / 5 totaltotal 31.4% 27 / 86 CC 9 SCAR 24.4
CC
9
Cov
30%
parse
30.0
new
12.0
is_success
6.0
CRAP 11.5
« DRI/Protocol/EPP/Extensions/EURid/Message.pm ↑ Summary DRI/Protocol/BookMyName/WS/Message.pm »
1 ## Domain Registry Interface, Whois Message
2 ##
3 ## Copyright (c) 2007-2010,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::Message;
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::Protocol::ResultStatus;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use base qw(Class::Accessor::Chained::Fast Net::DRI::Protocol::Message);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 __PACKAGE__->mk_accessors(qw(version errcode errmsg errlang command cltrid response response_raw));
26  
27 =pod
28  
29 =head1 NAME
30  
31 Net::DRI::Protocol::Whois::Message - Whois Message for Net::DRI
32  
33 =head1 DESCRIPTION
34  
35 Please see the README file for details.
36  
37 =head1 SUPPORT
38  
39 For now, support questions should be sent to:
40  
41 E<lt>netdri@dotandco.comE<gt>
42  
43 Please also see the SUPPORT file in the distribution.
44  
45 =head1 SEE ALSO
46  
47 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
48  
49 =head1 AUTHOR
50  
51 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
52  
53 =head1 COPYRIGHT
54  
55 Copyright (c) 2007-2010,2013 Patrick Mevzek <netdri@dotandco.com>.
56 All rights reserved.
57  
58 This program is free software; you can redistribute it and/or modify
59 it under the terms of the GNU General Public License as published by
60 the Free Software Foundation; either version 2 of the License, or
61 (at your option) any later version.
62  
63 See the LICENSE file that comes with this distribution for more details.
64  
65 =cut
66  
67 ####################################################################################################
68  
69 sub new
70 0 ▶{
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
71 0 my ($class,$trid)=@_;
72 0 my $self={
73 errcode => -1000,
74 response => {},
75 };
76  
77 0 bless($self,$class);
78 0 ▶ $self->cltrid($trid) if (defined($trid) && $trid);
Branch: 1 branch
BranchTrueFalseTotal
if defined $trid and $trid 0 0 0
Condition0%0/3
defined $trid and $trid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $trid and $trid
defined $trid $trid
Truth table0%0/3
A and B
A= defined $tridB= $trid
ABresult
0X0
100
111
79 0 return $self;
80 }
81  
82 0 ▶sub is_success { return (shift->errcode()==0)? 1 : 0; }
Subroutine is_success: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
(shift())->errcode == 0 ? : 0 0 0
83  
84 sub result_status
85 0 ▶{
Subroutine result_status: not called CC=2 SCAR=17.9
Pod undocumented
86 0 my $self=shift;
87 0 my %C=( 0 => 1500, ## Command successful + connection closed
88 );
89 0 my $c=$self->errcode();
90 0 ▶ my $rs=Net::DRI::Protocol::ResultStatus->new('whois',$c,exists($C{$c})? $C{$c} : 'COMMAND_FAILED',$self->is_success(),$self->errmsg(),$self->errlang(),undef);
Branch: 1 branch
BranchTrueFalseTotal
exists $C{$c} ? : 0 0 0
91 0 $rs->_set_trid([ $self->cltrid(),undef ]);
92 0 return $rs;
93 }
94  
95 sub as_string
96 0 ▶{
Subroutine as_string: not called CC=1 SCAR=6.9
Pod undocumented
97 0 my ($self)=@_;
98 0 my $s=sprintf("%s\x0d\x0a",$self->command());
99 0 return $s;
100 }
101  
102 sub parse
103 0 ▶{
Subroutine parse: not called CC=5 SCAR=34.0
Pod undocumented
104 0 my ($self,$dc,$rinfo)=@_;
105 0 my @d=$dc->as_array();
106 0 my %info;
107 0 foreach my $l (grep { /:/ } @d)
108 {
109 0 my ($k,$v)=($l=~m/^\s*(\S[^:]*\S)\s*:\s*(\S.*\S)\s*$/);
110 0 ▶ next unless ($k && $v);
Branch: 1 branch
BranchTrueFalseTotal
unless $k and $v 0 0 0
Condition0%0/3
$k and $v
!ll&&!rl&&r
000
MC/DC0%0/2
$k and $v
$k $v
Truth table0%0/3
A and B
A= $kB= $v
ABresult
0X0
100
111
111 0 ▶ if (exists($info{$k}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info{$k}) { } 0 0 0
112 {
113 0 push @{$info{$k}},$v;
114 } else
115 {
116 0 $info{$k}=[$v];
117 }
118 }
119  
120 0 $self->errcode(0);
121 0 $self->response(\%info);
122 0 $self->response_raw(\@d);
123 0 return;
124 }
125  
126 ####################################################################################################
127 1 1;
« DRI/Protocol/EPP/Extensions/EURid/Message.pm ↑ Summary DRI/Protocol/BookMyName/WS/Message.pm »