Test
Analyse
- SPEED-UP NOTE
-
If protocol level
1is specified, theconnectmethod tries to use the highest available protocol level. To do so, it queries the FreeDB to find out exaclty which level is supported. OnCDDBPconnections this doesn't take that long. OnHTTPconnections it does. To speed upHTTPconnections specify a higherproto_level-say5.
Options for OPT_HASH_REF may include:
auto_connected-
Connect the created object just after instantiation. Defaults to
1. client_host-
The hostname of the client. Defaults to
&Sys::Hostname::hostname(). client_name-
Mandatory option to name the connecting client software.
client_user-
The user name of the client. Defaults to
scalar( getpwuid(\$>) ). client_version-
Mandatory option with the client software version string.
freedb_cgi*-
The FreeDB
cgito use. Defaults to~cddb/cddb.cgi. freedb_host-
The FreeDB host. Defaults to
freedb.freedb.org. freedb_port-
The port on the FreeDB host. Defaults to
80forHTTPand to888forCDDBPconnection types. protocol-
The protocol to use. Either
HTTPorCDDBP. Defaults toHTTP. proto_level-
The FreeDB protocol level. Defaults to 1.
proxy_host**-
The proxy host to use.
proxy_passwd**-
The proxy password to use.
proxy_port**-
The port on the proxy host. Defaults to 8080.
proxy_user**-
The proxy user name to use.
EOF body => <<'EOF', my $self = shift; my $opt = defined($_[0]) ? shift : {};
# Check $opt
ref($opt) eq 'HASH' ||
throw Error::Simple("ERROR: InfoSys::FreeDB::create_connection, first argument must be 'HASH' reference.");
# Set default values for $opt
$opt->{client_host} = &Sys::Hostname::hostname()
if (! $opt->{client_host} );
$opt->{client_user} = scalar( getpwuid($>) )
if (! $opt->{client_user} );
$opt->{freedb_host} = 'freedb.freedb.org'
if (! $opt->{freedb_host} );
# Set default value to protocol
$opt->{protocol} = 'HTTP' if ( ! $opt->{protocol} );
# Select the correct connection class
my $conn = undef;
if ( $opt->{protocol} eq 'HTTP' ) {
$opt->{freedb_port} = 80
if (! $opt->{freedb_port} );
require InfoSys::FreeDB::Connection::HTTP;
$conn = InfoSys::FreeDB::Connection::HTTP->new($opt);
}
elsif ( $opt->{protocol} eq 'CDDBP' ){
$opt->{freedb_port} = 888
if (! $opt->{freedb_port} );
require InfoSys::FreeDB::Connection::CDDBP;
$conn = InfoSys::FreeDB::Connection::CDDBP->new($opt);
}
else {
throw Error::Simple("ERROR: InfoSys::FreeDB::create_connection, protocol '$opt->{protocol}' is not supported. Only 'HTTP' and 'CDDBP' are.");
}
# Connect if necessary
$opt->{auto_connected} = 1 if ( !exists( $opt->{auto_connected} ) );
$opt->{auto_connected} && $conn->connect();
# Return the connection
return($conn);
EOF
},
],
use_opt => [
{
dependency_name => 'Sys::Hostname',
},
],
} );
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 24:
=back doesn't take any parameters, but you said =back EOF todo => <<EOF, =head2 Implement
- Around line 51:
=back doesn't take any parameters, but you said =back EOF }, attr_opt => [ ], constr_opt => [ ], meth_opt => [ { method_name => 'create_connection', parameter_description => 'OPT_HASH_REF', description => <<EOF, Creates a C<${pkg_connection}> object. C<OPT_HASH_REF> is a hash reference used to pass connection creation options. On error an exception C<Error::Simple> is thrown.