The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

slackget10::Server - A to represent a server from the servers.xml file.

VERSION

Version 1.0.0

SYNOPSIS

This class is used by slack-get to represent a server store in the servers.xml file. In this class (and in the related ServerList), the word "server" is used to describe an update source, a server entity of the servers.xml file. This word is not use to describe a traditionnal TCP/IP server. A slackget10::Server object can contain many TCP/IP server, this allow it to switch when a FTP or HTTP host doesn't response.

    use slackget10::Server;

    my $server = slackget10::Server->new('slackware');
    my $xml = XML::Simple::XMLin($servers_file,,KeyAttr => {'server' => 'id'});
    $server->fill_object_from_xml($xml->{'slackware'});
    $server->setValue('description','The official Slackware web site');

This class' usage is mostly the same that the slackget10::Package one. There is one big difference with the package class : you must use the accessors for setting the fast and slow servers list.

The constructor require the following argument :

        - an id (stricly needed)

Additionnaly you can pass the followings :

        description => a string which describe the mirror
        web-link => a web site URL for the mirror.
        update-repository => A hash reference build on the model of the servers.xml file. For example for the faster mirror (the one you want you use for this Server object) :
        
        my $server = slackget10::Server->new('slackware','update-repository' => {faster => http://ftp.belnet.be/packages/slackware/slackware-10.1/}); 

Some examples:

        # the simpliest and recommended way
        my $server = slackget10::Server->new('slackware'); 
        $server->fill_object_from_xml($xml_simple_hashref);
        
        or 
        
        # The harder and realy not recommended unless you know what you are doing.
        
        my $server = slackget10::Server->new('slackware',
                'description'=>'The official Slackware web site',
                'web-link' => 'http://www.slackware.com/',
                'update-repository' => {faster => 'http://ftp.belnet.be/packages/slackware/slackware-10.1/'}
        ); 

CONSTRUCTOR

FUNCTIONS

setValue

Set the value of a named key to the value passed in argument.

        $package->setValue($key,$value);

getValue

Return the value of a key :

        $string = $server->getValue($key);

fill_object_from_xml

Fill the data section of the slackget10::Server object with information from a servers.xml section.

        $server->fill_object_from_xml($xml->{'slackware'});

_fill_fast_host_section [PRIVATE]

fill the DATA section of the object (sub-section fast host), with a part of the XML tree of a servers.xml file.

In normal use you don't have to use this method. In all case prefer pass all required argument to the constructor, and call the fill_object_from_xml() method.

        $self->_fill_fast_host_section($xml->{'update-repository'}->{fast});

_fill_slow_host_section [PRIVATE]

fill the DATA section of the object (sub-section slow host), with a part of the XML tree of a servers.xml file.

In normal use you don't have to use this method. In all case prefer pass all required argument to the constructor, and call the fill_object_from_xml() method.

        $self->_fill_slow_host_section($xml->{'update-repository'}->{slow});

next_host

This method have 3 functionnalities : return the next fastest host, set it as the current host, and add the old host to the old hosts list.

        my $host = $server->next_host ;

return undef if no new host is found

This method is used to print the content of the current Server object.

        $server->print_info ;

to_string

return the same information that the print_info() method as a string.

        my $string = $server->to_string ;

ACCESSORS

Some accessors for the current object/

host

return the current host :

        my $host = $server->host

description

return the description of the server.

        my $descr = $server->description ;

url

return the URL of the website for the server.

        system("$config->{common}->{'default-browser'} $server->url &");

shortname

Return the shortname of the server. The shortname is the name of the id attribute of the server tag in servers.xml => <server id="the_shortname">

        my $id = $server->shortname ;

set_fast_servers_array

...not yet implemented...

FORMATTED OUTPUT

Different methods to properly output a server.

to_XML

return the server info as an XML encoded string.

        $xml = $server->to_XML();

AUTHOR

DUPUIS Arnaud, <a.dupuis@infinityperl.org>

BUGS

Please report any bugs or feature requests to bug-slackget10-networking@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=slackget10. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2005 DUPUIS Arnaud, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 31:

Unknown directive: =CONSTRUCTOR