ARIN/Network.pm

filter: Statementstmt 41.1% 21 / 51 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 100% 3 / 3 totaltotal 49.3% 36 / 73 CC 9 SCAR 21.2
CC
9
Cov
45%
dump
20.0
AUTOLOAD
5.9
contacts
2.0
CRAP 8.3
« ARIN.pm ↑ Summary ARIN/Customer.pm »
1 package Net::Whois::ARIN::Network;
2  
3 =head1 NAME
4  
5 Net::Whois::ARIN::Network - ARIN whois Network record class
6  
7 =head1 SYNOPSIS
8  
9 use Net::Whois::ARIN::Network;
10  
11 my $net = Net::Whois::ARIN::Network->new(
12 OrgName => 'Electric Lightwave Inc',
13 OrgID => 'ELIX',
14 Address => '4400 NE 77th Ave',
15 City => 'Vancouver',
16 StateProv => 'WA',
17 PostalCode => '98662',
18 Country => 'US',
19 RegDate => '1995-07-25',
20 Updated => '2001-05-17',
21 NetRange => '207.173.0.0 - 207.173.255.255',
22 CIDR => '207.173.0.0/16',
23 NetName => 'ELI-NETBLK5',
24 NetHandle => 'NET-207-173-0-0-1',
25 Parent => 'NET-207-0-0-0-0',
26 NetType => 'Direct Allocation',
27 NameServer => 'NS.ELI.NET',
28 Comment => 'ADDRESSES WITHIN THIS BLOCK ARE NON-PORTABLE',
29 );
30  
31 printf "%s was given a %s of %s by ARIN.\n",
32 $net->OrgName,
33 lc $net->NetType,
34 $net->CIDR;
35  
36 =head1 DESCRIPTION
37  
38 The Net::Whois::ARIN::Network module is simple class which is used to store the attributes of an Network record in ARIN's Whois server. Each attribute of the Network record has an accessor/mutator of the same name.
39  
40 =cut
41  
42 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 7 ▶use Carp "croak";
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 7 our $AUTOLOAD;
46  
47 =head1 METHODS
48  
49 =over 4
50  
51 =item B<new> - create a Net::Whois::ARIN::Network object
52  
53 =cut
54  
55 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
56 1 my $class = shift;
57 1 return bless { _contacts => [], @_ }, $class;
58 }
59  
60 =item B<contacts> - get/set Net::Whois::ARIN::Contact records
61  
62 This method accepts a list of Net::Whois::ARIN::Contact instances and associates these objects with the Network record. If no arguments are specified, the method returns a list of Net::Whois::ARIN::Contact objects.
63  
64 =back
65  
66 =cut
67  
68 2 ▶sub contacts {
Subroutine contacts: called CC=2 SCAR=6.9
Pod documented
69 2 my $self = shift;
70 2 ▶ $self->{_contacts} = [ @_ ] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 1 2
71 2 return @{ $self->{_contacts} };
72 }
73  
74 =over 4
75  
76 =item B<dump> - return the current whois record
77  
78 print $o->dump;
79  
80 =back
81  
82 =cut
83  
84 0 ▶sub dump {
Subroutine dump: not called CC=4 SCAR=30.0
Pod documented
85 0 my $self = shift;
86 0 my $record = sprintf "\nOrgName: %s\n", $self->OrgName;
87 0 $record .= sprintf "OrgID: %s\n",$self->OrgID;
88 0 $record .= sprintf("Address: %s\n", $_) for @{ $self->Address };
89 0 $record .= sprintf "City: %s\n",$self->City;
90 0 $record .= sprintf "StateProv: %s\n",$self->StateProv;
91 0 $record .= sprintf "PostalCode: %s\n",$self->PostalCode;
92 0 $record .= sprintf "Country: %s\n",$self->Country;
93 0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
94 0 $record .= sprintf "Updated: %s\n\n",$self->Updated;
95  
96 0 $record .= sprintf "NetRange: %s\n",$self->NetRange;
97 0 $record .= sprintf "CIDR: %s\n",$self->CIDR;
98 0 $record .= sprintf "NetName: %s\n",$self->NetName;
99 0 $record .= sprintf "NetHandle: %s\n",$self->NetHandle;
100 0 $record .= sprintf "Parent: %s\n",$self->Parent;
101 0 $record .= sprintf "NetType: %s\n",$self->NetType;
102 0 $record .= sprintf("NameServer: %s\n", $_) for @{ $self->NameServer };
103 0 $record .= sprintf "Comment: %s\n",$self->Comment;
104 0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
105 0 $record .= sprintf "Updated: %s\n",$self->Updated;
106  
107 0 foreach my $contact ( $self->contacts ) {
108 0 $record .= sprintf "%sHandle: %s\n", $contact->Type, $contact->Handle;
109 0 $record .= sprintf "%sName: %s\n", $contact->Type, $contact->Name;
110 0 $record .= sprintf "%sPhone: %s\n", $contact->Type, $contact->Phone;
111 0 $record .= sprintf "%sEmail: %s\n", $contact->Type, $contact->Email;
112 }
113  
114 0 return $record;
115 }
116  
117 =head1 ATTRIBUTES
118  
119 These methods are the accessors/mutators for the fields found in the Whois record.
120  
121 =over 4
122  
123 =item B<OrgName> - get/set the organization name
124  
125 =item B<OrgID> - get/set the organization id
126  
127 =item B<Address> - get/set the address
128  
129 =item B<City> - get/set the city
130  
131 =item B<StateProv> - get/set the state or province
132  
133 =item B<PostalCode> - get/set the postal code
134  
135 =item B<Country> - get/set the country
136  
137 =item B<RegDate> - get/set the registration date
138  
139 =item B<Updated> - get/set the last updated date
140  
141 =item B<NetRange> - get/set the network range
142  
143 =item B<CIDR> - get/set the CIDR netblock
144  
145 =item B<NetName> - get/set the network name
146  
147 =item B<NetHandle> - get/set the network handle
148  
149 =item B<Parent> - get/set the parent network handle
150  
151 =item B<NetType> - get/set the network type
152  
153 =item B<NameServer> - get/set the name servers
154  
155 =item B<Comment> - get/set the public comment
156  
157 =back
158  
159 =cut
160  
161 17 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=5 SCAR=17.8
162 17 my $self = shift;
163 17 my $name = $AUTOLOAD;
164 17 $name =~ s/.*://;
165  
166 17 ▶ return if $name eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "DESTROY" 1 16 17
167  
168 16 ▶ if ($name !~ /^_/ && exists $self->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $name =~ /^_/ and exists $self->{$name}) 16 0 16
Condition33%1/3
not $name =~ /^_/ and exists $self->{$name}
!ll&&!rl&&r
0016
MC/DC0%0/2
not $name =~ /^_/ and exists $self->{$name}
not $name =~ /^_/ exists $self->{$name}
Truth table33%1/3
not(A) and B
A= not $name =~ /^_/B= exists $self->{$name}
ABresult
0X0
100
111
169 16 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 16 16
170 0 return $self->{$name} = shift;
171 } else {
172 16 return $self->{$name};
173 }
174 }
175  
176 0 croak "Undefined subroutine \&$AUTOLOAD called";
177 }
178  
179 =head1 AUTHOR
180  
181 Todd Caine <todd.caine at gmail.com>
182  
183 =head1 COPYRIGHT AND LICENSE
184  
185 Copyright (c) 2004 Todd Caine. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
186  
187 =cut
188  
189 7 1;
190 __END__
« ARIN.pm ↑ Summary ARIN/Customer.pm »