blib/lib/Net/FreeDB2/Connection.pm

filter: Statementstmt 22.0% 24 / 109 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 11.3% 5 / 44 Podpod 97.3% 37 / 38 totaltotal 31.2% 66 / 211 CC 9 SCAR 23.7
CC
9
Cov
19%
_initialize
58.3
new
6.0
connect
2.0
CRAP 10.7
« blib/lib/Net/FreeDB2/Connection/HTTP.pm ↑ Summary blib/lib/Net/FreeDB2/Match.pm »
1 package Net::FreeDB2::Connection;
2  
3 # Copyright 2002, Vincenzo Zocca.
4  
5 # See LICENSE section for usage and distribution rights.
6  
7 3 require 5.005_62;
8 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Error qw (:try);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 require Exporter;
13 3 ▶use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 our @ISA = qw(Exporter);
16  
17 # Items to export into callers namespace by default. Note: do not export
18 # names by default without a very good reason. Use EXPORT_OK instead.
19 # Do not simply export all your public functions/methods/constants.
20  
21 # This allows declaration use Net::FreeDB2::Connection ':all';
22 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
23 # will save memory.
24 3 our %EXPORT_TAGS = ( 'all' => [ qw(
25
26 ) ] );
27  
28 3 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
29  
30 3 our @EXPORT = qw(
31
32 );
33 3 our ( $VERSION ) = '$Revision: 0.8.2.4 $ ' =~ /\$Revision:\s+([^\s]+)/;
34  
35 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
36  
37 0 my $class = shift;
38  
39 0 my $self = {};
40 0 ▶ bless ($self, (ref($class) || $class));
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
41 0 return ($self->_initialize (@_));
42 }
43  
44 0 ▶sub _initialize {
Subroutine _initialize: not called CC=8 SCAR=40.7
45 0 my $self = shift;
46 0 ▶ my $opt = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
47  
48 # Set client_name and client_version
49 0 ▶ defined ($opt->{client_name}) || throw Error::Simple ('ERROR: Net::FreeDB2::Connection::_initialize, mandatory option \'client_name\' missing.');
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->{"client_name"} or "Error::Simple"->throw("ERROR: Net::FreeDB2::Connection::_initialize, mandatory option 'client_name' missing.") 0 0 0
50 0 $self->setClientName ($opt->{client_name});
51 0 ▶ defined ($opt->{client_version}) || throw Error::Simple ('ERROR: Net::FreeDB2::Connection::_initialize, mandatory option \'client_version\' missing.');
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->{"client_version"} or "Error::Simple"->throw("ERROR: Net::FreeDB2::Connection::_initialize, mandatory option 'client_version' missing.") 0 0 0
52 0 $self->setClientVersion ($opt->{client_version});
53  
54 # Set client_host
55 0 ▶ if ($opt->{client_host}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{'client_host'}) { } 0 0 0
56 0 $self->setClientHost ($opt->{client_host});
57 } else {
58 3 ▶ use Sys::Hostname;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 0 $self->setClientHost (&Sys::Hostname::hostname ());
60 }
61  
62 # Set client_user
63 0 ▶ if ($opt->{client_user}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{'client_user'}) { } 0 0 0
64 0 $self->setClientUser ($opt->{client_user});
65 } else {
66 0 $self->setClientUser (scalar (getpwuid ($>)));
67 }
68  
69 # Set freedb_host
70 0 ▶ if ($opt->{freedb_host}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{'freedb_host'}) { } 0 0 0
71 0 $self->setFreeDBHost ($opt->{freedb_host});
72 } else {
73 0 $self->setFreeDBHost ('freedb.freedb.org');
74 }
75  
76 # Set freedb_port
77 0 $self->setFreeDBPort ($opt->{freedb_port});
78  
79 # Set proxy_host
80 0 $self->setProxyHost ($opt->{proxy_host});
81  
82 # Set proxy_port
83 0 $self->setProxyPort ($opt->{proxy_port});
84  
85 # Set proxy_user
86 0 $self->setProxyUser ($opt->{proxy_user});
87  
88 # Set proxy_passwd
89 0 $self->setProxyPasswd ($opt->{proxy_passwd});
90  
91 # Connect
92 0 ▶ exists ($opt->{no_connect}) || $self->connect ();
Branch: 1 branch
BranchTrueFalseTotal
exists $opt->{"no_connect"} or $self->connect 0 0 0
93  
94 # Return instance
95 0 return ($self);
96 }
97  
98 0 ▶sub connect {
Subroutine connect: not called CC=1 SCAR=6.9
Pod documented
99 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::connect, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
100 }
101  
102 0 ▶sub lscat {
Subroutine lscat: not called CC=1 SCAR=6.9
Pod documented
103 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::lscat, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
104 }
105  
106 0 ▶sub query {
Subroutine query: not called CC=1 SCAR=6.9
Pod documented
107 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::query, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
108 }
109  
110 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
Pod documented
111 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::read, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
112 }
113  
114 0 ▶sub write {
Subroutine write: not called CC=1 SCAR=6.9
Pod documented
115 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::write, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
116 }
117  
118 0 ▶sub help {
Subroutine help: not called CC=1 SCAR=6.9
Pod undocumented
119 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::help, oh come on, RTFM!!!");
120 }
121  
122 0 ▶sub log {
Subroutine log: not called CC=1 SCAR=6.9
Pod documented
123 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::log, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
124 }
125  
126 0 ▶sub motd {
Subroutine motd: not called CC=1 SCAR=6.9
Pod documented
127 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::motd, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
128 }
129  
130 0 ▶sub discid {
Subroutine discid: not called CC=1 SCAR=6.9
Pod documented
131 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::discid, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
132 }
133  
134 0 ▶sub proto {
Subroutine proto: not called CC=1 SCAR=6.9
Pod documented
135 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::proto, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
136 }
137  
138 0 ▶sub sites {
Subroutine sites: not called CC=1 SCAR=6.9
Pod documented
139 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::sites, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
140 }
141  
142 0 ▶sub stat {
Subroutine stat: not called CC=1 SCAR=6.9
Pod documented
143 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::stat, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
144 }
145  
146 0 ▶sub ver {
Subroutine ver: not called CC=1 SCAR=6.9
Pod documented
147 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::ver, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
148 }
149  
150 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
Pod documented
151 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::update, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
152 }
153  
154 0 ▶sub whom {
Subroutine whom: not called CC=1 SCAR=6.9
Pod documented
155 0 throw Error::Simple ("ERROR: Net::FreeDB2::Connection::whom, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP.");
156 }
157  
158 0 ▶sub setClientName {
Subroutine setClientName: not called CC=1 SCAR=6.9
Pod documented
159 0 my $self = shift;
160  
161 # Set client name
162 0 $self->{Net_FreeDB2_Connection}{client_name} = shift;
163 }
164  
165 0 ▶sub getClientName {
Subroutine getClientName: not called CC=1 SCAR=6.9
Pod documented
166 0 my $self = shift;
167  
168 # Return client version
169 0 return ($self->{Net_FreeDB2_Connection}{client_name});
170 }
171  
172 0 ▶sub setClientVersion {
Subroutine setClientVersion: not called CC=1 SCAR=6.9
Pod documented
173 0 my $self = shift;
174  
175 # Set client version
176 0 $self->{Net_FreeDB2_Connection}{client_version} = shift;
177 }
178  
179 0 ▶sub getClientVersion {
Subroutine getClientVersion: not called CC=1 SCAR=6.9
Pod documented
180 0 my $self = shift;
181  
182 # Return client name
183 0 return ($self->{Net_FreeDB2_Connection}{client_version});
184 }
185  
186 0 ▶sub setClientHost {
Subroutine setClientHost: not called CC=1 SCAR=6.9
Pod documented
187 0 my $self = shift;
188  
189 # Set client host
190 0 $self->{Net_FreeDB2_Connection}{client_host} = shift;
191 }
192  
193 0 ▶sub getClientHost {
Subroutine getClientHost: not called CC=1 SCAR=6.9
Pod documented
194 0 my $self = shift;
195  
196 # Return client host
197 0 return ($self->{Net_FreeDB2_Connection}{client_host});
198 }
199  
200 0 ▶sub setClientUser {
Subroutine setClientUser: not called CC=1 SCAR=6.9
Pod documented
201 0 my $self = shift;
202  
203 # Set client user
204 0 $self->{Net_FreeDB2_Connection}{client_user} = shift;
205 }
206  
207 0 ▶sub getClientUser {
Subroutine getClientUser: not called CC=1 SCAR=6.9
Pod documented
208 0 my $self = shift;
209  
210 # Return client user
211 0 return ($self->{Net_FreeDB2_Connection}{client_user});
212 }
213  
214 0 ▶sub setFreeDBHost {
Subroutine setFreeDBHost: not called CC=1 SCAR=6.9
Pod documented
215 0 my $self = shift;
216  
217 # Set freedb/cddb host
218 0 $self->{Net_FreeDB2_Connection}{freedb_host} = shift;
219 }
220  
221 0 ▶sub getFreeDBHost {
Subroutine getFreeDBHost: not called CC=1 SCAR=6.9
Pod documented
222 0 my $self = shift;
223  
224 # Return freedb/cddb host
225 0 return ($self->{Net_FreeDB2_Connection}{freedb_host});
226 }
227  
228 0 ▶sub setFreeDBPort {
Subroutine setFreeDBPort: not called CC=1 SCAR=6.9
Pod documented
229 0 my $self = shift;
230  
231 # Set freedb/cddb port
232 0 $self->{Net_FreeDB2_Connection}{freedb_port} = shift;
233 }
234  
235 0 ▶sub getFreeDBPort {
Subroutine getFreeDBPort: not called CC=1 SCAR=6.9
Pod documented
236 0 my $self = shift;
237  
238 # Return freedb/cddb port
239 0 return ($self->{Net_FreeDB2_Connection}{freedb_port});
240 }
241  
242 0 ▶sub setProxyHost {
Subroutine setProxyHost: not called CC=1 SCAR=6.9
Pod documented
243 0 my $self = shift;
244  
245 # Set proxy host
246 0 $self->{Net_FreeDB2_Connection}{proxy_host} = shift;
247 }
248  
249 0 ▶sub getProxyHost {
Subroutine getProxyHost: not called CC=1 SCAR=6.9
Pod documented
250 0 my $self = shift;
251  
252 # Return proxy host
253 0 return ($self->{Net_FreeDB2_Connection}{proxy_host});
254 }
255  
256 0 ▶sub setProxyPort {
Subroutine setProxyPort: not called CC=1 SCAR=6.9
Pod documented
257 0 my $self = shift;
258  
259 # Set proxy port
260 0 $self->{Net_FreeDB2_Connection}{proxy_port} = shift;
261 }
262  
263 0 ▶sub getProxyPort {
Subroutine getProxyPort: not called CC=1 SCAR=6.9
Pod documented
264 0 my $self = shift;
265  
266 # Return proxy port
267 0 return ($self->{Net_FreeDB2_Connection}{proxy_port});
268 }
269  
270 0 ▶sub setProxyUser {
Subroutine setProxyUser: not called CC=1 SCAR=6.9
Pod documented
271 0 my $self = shift;
272  
273 # Set proxy user
274 0 $self->{Net_FreeDB2_Connection}{proxy_user} = shift;
275 }
276  
277 0 ▶sub getProxyUser {
Subroutine getProxyUser: not called CC=1 SCAR=6.9
Pod documented
278 0 my $self = shift;
279  
280 # Return proxy user
281 0 return ($self->{Net_FreeDB2_Connection}{proxy_user});
282 }
283  
284 0 ▶sub setProxyPasswd {
Subroutine setProxyPasswd: not called CC=1 SCAR=6.9
Pod documented
285 0 my $self = shift;
286  
287 # Set proxy passwd
288 0 $self->{Net_FreeDB2_Connection}{proxy_passwd} = shift;
289 }
290  
291 0 ▶sub getProxyPasswd {
Subroutine getProxyPasswd: not called CC=1 SCAR=6.9
Pod documented
292 0 my $self = shift;
293  
294 # Return proxy passwd
295 0 return ($self->{Net_FreeDB2_Connection}{proxy_passwd});
296 }
297  
298 0 ▶sub setConnection {
Subroutine setConnection: not called CC=1 SCAR=6.9
Pod documented
299 0 my $self = shift;
300  
301 # Set connection
302 0 $self->{Net_FreeDB2_Connection}{connection} = shift;
303 }
304  
305 0 ▶sub getConnection {
Subroutine getConnection: not called CC=1 SCAR=6.9
Pod documented
306 0 my $self = shift;
307  
308 # Return connection
309 0 return ($self->{Net_FreeDB2_Connection}{connection});
310 }
311  
312 3 1;
313 __END__
« blib/lib/Net/FreeDB2/Connection/HTTP.pm ↑ Summary blib/lib/Net/FreeDB2/Match.pm »