The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

VERSION

Version 0.9.8

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 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.

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 = 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'
	}
);

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 = $media->getValue($key);

fill_object_from_xml

Fill the data section of the slackget10::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});

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

return the media info as an XML encoded string.

$xml = $media->to_XML();

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-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.

SUPPORT

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

perldoc slackget10

You can also look for information at:

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.