slackget10::Media - A class to represent a Media from the medias.xml file.
Version 0.9.8
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 slackget10::Media; my $Media = slackget10::Media->new('slackware'); my $xml = XML::Simple::XMLin($medias_file,,KeyAttr => {'media' => 'id'}); $media->fill_object_from_xml($xml->{'slackware'}); $media->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 medias 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 medias.xml file. For example for the faster mirror (the one you want you use for this Media object) : my $media = slackget10::Media->new('slackware','update-repository' => {faster => http://ftp.belnet.be/packages/slackware/slackware-10.1/});
Some examples:
# the simpliest and recommended way my $media = slackget10::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 = slackget10::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' } );
Set the value of a named key to the value passed in argument.
$package->setValue($key,$value);
Return the value of a key :
$string = $media->getValue($key);
Fill the data section of the slackget10::Media object with information from a medias.xml section.
$media->fill_object_from_xml($xml->{'slackware'});
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 the DATA section of the object (sub-section slow host), with a part of the XML tree of a medias.xml file.
$self->_fill_slow_host_section($xml->{'update-repository'}->{slow});
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 ;
return the same information that the print_info() method as a string.
my $string = $media->to_string ;
Some accessors for the current object/
return the current host :
my $host = $media->host
return the description of the media.
my $descr = $media->description ;
return the URL of the website for the media.
system("$config->{common}->{'default-browser'} $media->url &");
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 ;
...not yet implemented...
Different methods to properly output a media.
return the media info as an XML encoded string.
$xml = $media->to_XML();
return the media info as an HTML encoded string.
$xml = $media->to_HTML();
DUPUIS Arnaud, <a.dupuis@infinityperl.org>
<a.dupuis@infinityperl.org>
Please report any bugs or feature requests to bug-slackget10@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.
bug-slackget10@rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc slackget10
You can also look for information at:
Infinity Perl website
http://www.infinityperl.org
slack-get specific website
http://slackget.infinityperl.org
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=slackget10
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/slackget10
CPAN Ratings
http://cpanratings.perl.org/d/slackget10
Search CPAN
http://search.cpan.org/dist/slackget10
Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation.
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.
To install slackget10, copy and paste the appropriate command in to your terminal.
cpanm
cpanm slackget10
CPAN shell
perl -MCPAN -e shell install slackget10
For more information on module installation, please visit the detailed CPAN module installation guide.