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

NAME

Slackware::Slackget::Media - A class to represent a Media from the medias.xml file.

VERSION

Version 0.9.9

SYNOPSIS

This class is used by slack-get to represent a media store in the medias.xml file. In this class (and in the related MediaList), the word "media" is used to describe an update source, a media entity of the medias.xml file.

    use Slackware::Slackget::Media;

    my $Media = Slackware::Slackget::Media->new('slackware');
    my $xml = XML::Simple::XMLin($medias_file,,KeyAttr => {'media' => 'id'});
    $media->fill_object_from_xml($xml->{'slackware'});
    $media->set_value('description','The official Slackware web site');

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

CONSTRUCTOR

new

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 medias.xml file. For example for the faster mirror (the one you want you use for this Media object) :
        
        my $media = Slackware::Slackget::Media->new('slackware','update-repository' => {faster => http://ftp.belnet.be/packages/slackware/slackware-10.1/}); 

Some examples:

        # the simpliest and recommended way
        my $media = Slackware::Slackget::Media->new('slackware'); 
        $media->fill_object_from_xml($xml_simple_hashref);
        
        or 
        
        # The harder and realy not recommended unless you know what you are doing.
        
        my $media = Slackware::Slackget::Media->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/'}
                'files' => {
                        'filelist' => 'FILELIST.TXT',
                        'checksums' => 'CHECKSUMS.md5',
                        'packages' => 'PACKAGES.TXT.gz'
                }
        );

FUNCTIONS

set_value

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

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

Return the value you just tried to set (usefull for integrity checks).

setValue (deprecated)

Same as set_value(), provided for backward compatibility.

getValue (deprecated)

Same as get_value(), provided for backward compatibility.

get_value

Return the value of a key :

        $string = $media->get_value($key);

fill_object_from_xml

Fill the data section of the Slackware::Slackget::Media object with information from a medias.xml section.

        $media->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 medias.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 medias.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});

add_slow_host( <string> )

Add an host to the slow section of the current media.

        $media->add_slow_host("ftp://ftp.fe.up.pt/disk1/ftp.slackware.com/pub/slackware/slackware-current/");

add_fast_host( <string> )

Add an host to the fast section of the current media.

        $media->add_fast_host("http://mirror.switch.ch/ftp/mirror/slackware/slackware-current/");

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 = $media->next_host ;

return undef if no new host is found

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

        $media->print_info ;

to_string

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

        my $string = $media->to_string ;

ACCESSORS

Some accessors for the current object.

host

return the current host :

        my $host = $media->host

description

return the description of the media.

        my $descr = $media->description ;

url

return the URL of the website for the media.

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

shortname

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

        my $id = $media->shortname ;

set_fast_medias_array

...not yet implemented...

FORMATTED OUTPUT

Different methods to properly output a media.

to_XML (deprecated)

Same as to_xml(), provided for backward compatibility.

to_xml

return the media info as an XML encoded string.

        $xml = $media->to_xml();

to_HTML (deprecated)

Same as to_html(), provided for backward compatibility.

to_html

return the media info as an HTML encoded string.

        $xml = $media->to_html();

AUTHOR

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

BUGS

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

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Slackware::Slackget::Media

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation.

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.