| 1 | package Slackware::Slackget::Media; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | Slackware::Slackget::Media - A class to represent a Media from the medias.xml file. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | Version 0.9.9 | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | our $VERSION = '0.9.9'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 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. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | use Slackware::Slackget::Media; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | my $Media = Slackware::Slackget::Media->new('slackware'); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | my $xml = XML::Simple::XMLin($medias_file,,KeyAttr => {'media' => 'id'}); | ||||||||||||||||||||||||||||||||||||||||||
| 26 | $media->fill_object_from_xml($xml->{'slackware'}); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | $media->set_value('description','The official Slackware web site'); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 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. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | =head1 CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | The constructor require the following argument : | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | - an id (stricly needed) | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | Additionnaly you can pass the followings : | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | description => a string which describe the mirror | ||||||||||||||||||||||||||||||||||||||||||
| 42 | web-link => a web site URL for the mirror. | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 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) : | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | my $media = Slackware::Slackget::Media->new('slackware','update-repository' => {faster => http://ftp.belnet.be/packages/slackware/slackware-10.1/}); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | Some examples: | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | # the simpliest and recommended way | ||||||||||||||||||||||||||||||||||||||||||
| 50 | my $media = Slackware::Slackget::Media->new('slackware'); | ||||||||||||||||||||||||||||||||||||||||||
| 51 | $media->fill_object_from_xml($xml_simple_hashref); | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | or | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # The harder and realy not recommended unless you know what you are doing. | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | my $media = Slackware::Slackget::Media->new('slackware', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 'description'=>'The official Slackware web site', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 'web-link' => 'http://www.slackware.com/', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 'update-repository' => {faster => 'http://ftp.belnet.be/packages/slackware/slackware-10.1/'} | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 'files' => { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 'filelist' => 'FILELIST.TXT', | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 'checksums' => 'CHECKSUMS.md5', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 'packages' => 'PACKAGES.TXT.gz' | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | my ($class,$id,%args) = @_ ; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | return undef unless(defined($id)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | my $self={}; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | $self->{ID} = $id ; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | $self->{DATA} = {%args}; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | $self->{DATA}->{hosts}->{old} = [] ; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | bless($self,$class); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | $self->set_value('host',$args{'update-repository'}->{'faster'}) if(defined($args{'update-repository'}->{'faster'})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | =head2 set_value | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | Set the value of a named key to the value passed in argument. | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | $package->set_value($key,$value); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | Return the value you just tried to set (usefull for integrity checks). | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 4 | ▶ | sub set_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | my ($self,$key,$value) = @_ ; | |||||||||||||||||||||||||||||||||||||||||
| 97 | # print "Setting $key=$value for $self\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | $self->{DATA}->{$key} = $value ; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | return $self->{DATA}->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | =head2 setValue (deprecated) | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | Same as set_value(), provided for backward compatibility. | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | sub setValue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setValue: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | return set_value(@_); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | =head2 getValue (deprecated) | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | Same as get_value(), provided for backward compatibility. | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | sub getValue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getValue: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | return get_value(@_); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | =head2 get_value | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | Return the value of a key : | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | $string = $media->get_value($key); | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | ▶ | sub get_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | my ($self,$key) = @_ ; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | return $self->{DATA}->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | =head2 fill_object_from_xml | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | Fill the data section of the Slackware::Slackget::Media object with information from a medias.xml section. | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | $media->fill_object_from_xml($xml->{'slackware'}); | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub fill_object_from_xml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fill_object_from_xml: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my ($self,$xml) = @_ ; | |||||||||||||||||||||||||||||||||||||||||
| 145 | # require Data::Dumper ; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | # print Data::Dumper::Dumper($xml); | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | defined($xml->{'description'}) ? $self->set_value('description',$xml->{'description'}) : $self->set_value('description','no description for this media.') ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | defined($xml->{'web-link'}) ? $self->set_value('web-link',$xml->{'web-link'}) : $self->set_value('web-link','no website for this media.'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | defined($xml->{'download-signature'}) ? $self->set_value('download-signature',$xml->{'download-signature'}) : $self->set_value('download-signature',0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if(defined($xml->{'files'})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->set_value('filelist',$xml->{'files'}->{'filelist'}); | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $self->set_value('packages',$xml->{'files'}->{'packages'}); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $self->set_value('checksums',$xml->{'files'}->{'checksums'}); | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | else | ||||||||||||||||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $self->set_value('filelist','FILELIST.TXT'); | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $self->set_value('packages','PACKAGES.TXT'); | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $self->set_value('checksums','CHECKSUMS.md5'); | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if(defined($xml->{'update-repository'})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if(defined($xml->{'update-repository'}->{faster})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | require Slackware::Slackget::Network::Connection; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | unless(Slackware::Slackget::Network::Connection::is_url(undef,$xml->{'update-repository'}->{faster})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | warn "[Slackware::Slackget::Media] the faster host of the update-repository section will not be accepted as a valid URL by Slackware::Slackget::Connection class !\n"; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | return undef unless(defined($xml->{'update-repository'}->{faster})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $self->set_value('host',$xml->{'update-repository'}->{faster}); | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if(defined($xml->{'update-repository'}->{fast}) && defined($xml->{'update-repository'}->{fast}->{li}) && ref($xml->{'update-repository'}->{fast}->{li}) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $xml->{"update-repository"}{"fast"} and defined $xml->{"update-repository"}{"fast"}{"li"} and ref $xml->{"update-repository"}{"fast"}{"li"} eq "ARRAY"
defined $xml->{"update-repository"}{"fast"} and defined $xml->{"update-repository"}{"fast"}{"li"}
MC/DC0%0/3
defined $xml->{"update-repository"}{"fast"} and defined $xml->{"update-repository"}{"fast"}{"li"} and ref $xml->{"update-repository"}{"fast"}{"li"} eq "ARRAY"
defined $xml->{"update-repository"}{"fast"}
defined $xml->{"update-repository"}{"fast"}{"li"}
ref $xml->{"update-repository"}{"fast"}{"li"} eq "ARRAY"
Truth table0%0/4
A and B and C
A= defined $xml->{"update-repository"}{"fast"}B= defined $xml->{"update-repository"}{"fast"}{"li"}C= ref $xml->{"update-repository"}{"fast"}{"li"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->_fill_fast_host_section($xml->{'update-repository'}->{fast}); | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | else | ||||||||||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $self->{DATA}->{hosts}->{fast} = [] ; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if(defined($xml->{'update-repository'}->{slow}) && defined($xml->{'update-repository'}->{slow}->{li}) && ref($xml->{'update-repository'}->{slow}->{li}) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $xml->{"update-repository"}{"slow"} and defined $xml->{"update-repository"}{"slow"}{"li"} and ref $xml->{"update-repository"}{"slow"}{"li"} eq "ARRAY"
defined $xml->{"update-repository"}{"slow"} and defined $xml->{"update-repository"}{"slow"}{"li"}
MC/DC0%0/3
defined $xml->{"update-repository"}{"slow"} and defined $xml->{"update-repository"}{"slow"}{"li"} and ref $xml->{"update-repository"}{"slow"}{"li"} eq "ARRAY"
defined $xml->{"update-repository"}{"slow"}
defined $xml->{"update-repository"}{"slow"}{"li"}
ref $xml->{"update-repository"}{"slow"}{"li"} eq "ARRAY"
Truth table0%0/4
A and B and C
A= defined $xml->{"update-repository"}{"slow"}B= defined $xml->{"update-repository"}{"slow"}{"li"}C= ref $xml->{"update-repository"}{"slow"}{"li"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->_fill_slow_host_section($xml->{'update-repository'}->{slow}); | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | else | ||||||||||||||||||||||||||||||||||||||||||
| 186 | { | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $self->{DATA}->{hosts}->{slow} = [] ; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | else | ||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | warn "[Slackware::Slackget::Media] no update-repository found for the update source '$self->{ID}'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | =head2 _fill_fast_host_section [PRIVATE] | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | fill the DATA section of the object (sub-section fast host), with a part of the XML tree of a medias.xml file. | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 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. | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | $self->_fill_fast_host_section($xml->{'update-repository'}->{fast}); | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | sub _fill_fast_host_section | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fill_fast_host_section: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my ($self,$xml) = @_ ; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if(defined($xml->{li}) && ref($xml->{li}) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $xml->{"li"} and ref $xml->{"li"} eq "ARRAY"
MC/DC0%0/2
defined $xml->{"li"} and ref $xml->{"li"} eq "ARRAY"
defined $xml->{"li"}
ref $xml->{"li"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $xml->{"li"}B= ref $xml->{"li"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->{DATA}->{hosts}->{fast} = $xml->{li} ; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | else | ||||||||||||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->{DATA}->{hosts}->{fast} = [] ; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | =head2 _fill_slow_host_section [PRIVATE] | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | fill the DATA section of the object (sub-section slow host), with a part of the XML tree of a medias.xml file. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 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. | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | $self->_fill_slow_host_section($xml->{'update-repository'}->{slow}); | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | sub _fill_slow_host_section | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fill_slow_host_section: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my ($self,$xml) = @_ ; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if(defined($xml->{li}) && ref($xml->{li}) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $xml->{"li"} and ref $xml->{"li"} eq "ARRAY"
MC/DC0%0/2
defined $xml->{"li"} and ref $xml->{"li"} eq "ARRAY"
defined $xml->{"li"}
ref $xml->{"li"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $xml->{"li"}B= ref $xml->{"li"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $self->{DATA}->{hosts}->{slow} = $xml->{li} ; | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | else | ||||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->{DATA}->{hosts}->{slow} = [] ; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | =head2 add_slow_host( <string> ) | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | Add an host to the slow section of the current media. | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | $media->add_slow_host("ftp://ftp.fe.up.pt/disk1/ftp.slackware.com/pub/slackware/slackware-current/"); | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | sub add_slow_host { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_slow_host: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my ($self,$url) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $self->{DATA}->{hosts}->{slow} = [] unless(exists($self->{DATA}->{hosts}->{slow})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | push @{$self->{DATA}->{hosts}->{slow}}, $url; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | =head2 add_fast_host( <string> ) | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | Add an host to the fast section of the current media. | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | $media->add_fast_host("http://mirror.switch.ch/ftp/mirror/slackware/slackware-current/"); | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub add_fast_host { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_fast_host: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my ($self,$url) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | $self->{DATA}->{hosts}->{fast} = [] unless(exists($self->{DATA}->{hosts}->{fast})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | push @{$self->{DATA}->{hosts}->{fast}}, $url; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | =head2 next_host | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 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. | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | my $host = $media->next_host ; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | return undef if no new host is found | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | sub next_host | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_host: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | push @{$self->{DATA}->{hosts}->{old}}, $self->host; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $self->{DATA}->{host} = undef ; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if(defined(my $host = shift(@{$self->{DATA}->{hosts}->{fast}}))) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->{DATA}->{host} = $host ; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | else | ||||||||||||||||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | warn "[Slackware::Slackget::Media] no more host in the 'fast' category for update source '$self->{ID}'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if(defined(my $host = shift(@{$self->{DATA}->{hosts}->{slow}}))) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $self->{DATA}->{host} = $host ; | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | else | ||||||||||||||||||||||||||||||||||||||||||
| 299 | { | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | warn "[Slackware::Slackget::Media] no more host in the 'slow' category for update source '$self->{ID}'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return $self->host ; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | =head2 print_info | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | This method is used to print the content of the current Media object. | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | $media->print_info ; | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | sub print_info | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_info: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $self = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | print "Information for the '$self->{ID}' update source :\n"; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if(defined($self->getValue('description'))) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | print "\tDescription: ".$self->getValue('description')."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | else | ||||||||||||||||||||||||||||||||||||||||||
| 324 | { | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | print "\tDescription: no descrition found\n"; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if(defined($self->getValue('web-link'))) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | print "\tWeb site: ".$self->getValue('web-link')."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | else | ||||||||||||||||||||||||||||||||||||||||||
| 332 | { | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | print "\tWeb site: no link found\n"; | |||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if(defined($self->getValue('host'))) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | print "\tCurrent host: ".$self->getValue('host')."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | else | ||||||||||||||||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | print "\tCurrent host: no current host configured !\n"; | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | =head2 to_string | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | return the same information that the print_info() method as a string. | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | my $string = $media->to_string ; | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | sub to_string | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $self = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $str = "Information for the '$self->{ID}' update source :\n"; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if(defined($self->getValue('description'))){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $str .= "\tDescription: ".$self->getValue('description')."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | else | ||||||||||||||||||||||||||||||||||||||||||
| 361 | { | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $str .= "\tDescription: no descrition found\n"; | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if(defined($self->getValue('web-link'))){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $str .= "\tWeb site: ".$self->getValue('web-link')."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | else | ||||||||||||||||||||||||||||||||||||||||||
| 368 | { | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $str .= "\tWeb site: no link found\n"; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if(defined($self->getValue('host'))){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $str .= "\tCurrent host: ".$self->getValue('host')."\n"; | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | else | ||||||||||||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $str .= "\tCurrent host: no current host configured !\n"; | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | return $str ; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | =head1 ACCESSORS | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | Some accessors for the current object. | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | =head2 host | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | return the current host : | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | my $host = $media->host | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 2 | ▶ | sub host { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 2 | return $_[0]->{DATA}->{host}; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | =head2 description | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | return the description of the media. | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | my $descr = $media->description ; | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub description { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
description: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | return $_[0]->{DATA}->{description}; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | =head2 url | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | return the URL of the website for the media. | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | system("$config->{common}->{'default-browser'} $media->url &"); | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | ▶ | sub url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 2 | return $_[0]->{DATA}->{'web-link'}; | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | =head2 shortname | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 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"> | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | my $id = $media->shortname ; | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 2 | ▶ | sub shortname { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shortname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 2 | return $_[0]->{ID}; | |||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | =head2 set_fast_medias_array | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | ...not yet implemented... | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | sub set_fast_medias_array {1;} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_fast_medias_array: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | =head1 FORMATTED OUTPUT | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | Different methods to properly output a media. | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | =head2 to_XML (deprecated) | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | Same as to_xml(), provided for backward compatibility. | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | sub to_XML { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_XML: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | return to_xml(@_); | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | =head2 to_xml | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | return the media info as an XML encoded string. | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | $xml = $media->to_xml(); | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | sub to_xml | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_xml: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | return undef unless(defined($self->{ID})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if($self->{DATA}->{hosts}->{old}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | { | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $self->{DATA}->{hosts}->{slow} = [@{$self->{DATA}->{hosts}->{slow}},@{$self->{DATA}->{hosts}->{old}}] ; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $self->{DATA}->{hosts}->{old} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | delete($self->{DATA}->{hosts}->{old}); | |||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $xml = "\t<media id=\"$self->{ID}\">\n"; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $xml .= "\t\t<web-link>".$self->url."</web-link>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $xml .= "\t\t<description>".$self->description."</description>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $xml .= "\t\t<update-repository>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $xml .= "\t\t\t<faster>".$self->host."</faster>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if(defined($self->{DATA}->{hosts}->{fast}) && defined($self->{DATA}->{hosts}->{fast}->[0])) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"DATA"}{"hosts"}{"fast"} and defined $self->{"DATA"}{"hosts"}{"fast"}[0]
MC/DC0%0/2
defined $self->{"DATA"}{"hosts"}{"fast"} and defined $self->{"DATA"}{"hosts"}{"fast"}[0]
defined $self->{"DATA"}{"hosts"}{"fast"}
defined $self->{"DATA"}{"hosts"}{"fast"}[0]
Truth table0%0/3
A and B
A= defined $self->{"DATA"}{"hosts"}{"fast"}B= defined $self->{"DATA"}{"hosts"}{"fast"}[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | { | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $xml .= "\t\t\t\t<fast>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | foreach my $serv (@{$self->{DATA}->{hosts}->{fast}}) | |||||||||||||||||||||||||||||||||||||||||
| 489 | { | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $xml .= "\t\t\t\t\t<li>$serv</li>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $xml .= "\t\t\t\t</fast>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | if(defined($self->{DATA}->{hosts}->{slow}) && defined($self->{DATA}->{hosts}->{slow}->[0])) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"DATA"}{"hosts"}{"slow"} and defined $self->{"DATA"}{"hosts"}{"slow"}[0]
MC/DC0%0/2
defined $self->{"DATA"}{"hosts"}{"slow"} and defined $self->{"DATA"}{"hosts"}{"slow"}[0]
defined $self->{"DATA"}{"hosts"}{"slow"}
defined $self->{"DATA"}{"hosts"}{"slow"}[0]
Truth table0%0/3
A and B
A= defined $self->{"DATA"}{"hosts"}{"slow"}B= defined $self->{"DATA"}{"hosts"}{"slow"}[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | { | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $xml .= "\t\t\t\t<slow>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | foreach my $serv (@{$self->{DATA}->{hosts}->{slow}}) | |||||||||||||||||||||||||||||||||||||||||
| 498 | { | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $xml .= "\t\t\t\t\t<li>$serv</li>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $xml .= "\t\t\t\t</slow>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $xml .= "\t\t</update-repository>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 504 | # foreach my $key (keys(%{$self->{DATA}})){ | ||||||||||||||||||||||||||||||||||||||||||
| 505 | # if($key eq 'update-repository') | ||||||||||||||||||||||||||||||||||||||||||
| 506 | # { | ||||||||||||||||||||||||||||||||||||||||||
| 507 | # foreach my $key2 (keys(%{$self->{DATA}->{'update-repository'}})) | ||||||||||||||||||||||||||||||||||||||||||
| 508 | # { | ||||||||||||||||||||||||||||||||||||||||||
| 509 | # if($key2 eq 'fast' or $key2 eq 'slow' && ref($self->{DATA}->{'update-repository'}->{$key2}) eq 'HASH' && defined($self->{DATA}->{'update-repository'}->{$key2}->{li}) && ref($self->{DATA}->{'update-repository'}->{$key2}->{li}) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 510 | # $xml .= "\t\t<$key2>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 511 | # foreach (@{$self->{DATA}->{'update-repository'}->{$key2}->{li}}){ | ||||||||||||||||||||||||||||||||||||||||||
| 512 | # $xml .= "\t\t\t<li>$_</li>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 513 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | # $xml .= "\t\t</$key2>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 515 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 518 | # else | ||||||||||||||||||||||||||||||||||||||||||
| 519 | # { | ||||||||||||||||||||||||||||||||||||||||||
| 520 | # $xml .= "\t\t<$key>$self->{DATA}->{$key}</$key>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 521 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $xml .= "\t</media>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | return $xml; | |||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | =head2 to_HTML (deprecated) | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | Same as to_html(), provided for backward compatibility. | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | sub to_HTML { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_HTML: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | return to_html(@_); | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | =head2 to_html | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | return the media info as an HTML encoded string. | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | $xml = $media->to_html(); | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | sub to_html | ||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_html: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | return undef unless(defined($self->{ID})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $host = $self->host ; | |||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | $host = "<font color='red'>not reachable</font>" unless($host); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | return "<li>current host for <a href='".$self->url."' target='_blank' title='".$self->description."'>$self->{ID}</a> is $host</li><br/>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | DUPUIS Arnaud, C<< <a.dupuis@infinityperl.org> >> | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||||||||||||||||
| 561 | C<bug-Slackware-Slackget@rt.cpan.org>, or through the web interface at | ||||||||||||||||||||||||||||||||||||||||||
| 562 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget>. | ||||||||||||||||||||||||||||||||||||||||||
| 563 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||||||||||||||||||||||||||||||||||
| 564 | your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | perldoc Slackware::Slackget::Media | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | =item * Infinity Perl website | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | L<http://www.infinityperl.org/category/slack-get> | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | =item * slack-get specific website | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | L<http://slackget.infinityperl.org> | ||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget> | ||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | L<http://annocpan.org/dist/Slackware-Slackget> | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | L<http://cpanratings.perl.org/d/Slackware-Slackget> | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | L<http://search.cpan.org/dist/Slackware-Slackget> | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | Copyright 2005 DUPUIS Arnaud, All Rights Reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 612 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 5 | 1; # End of Slackware::Slackget::Media | |||||||||||||||||||||||||||||||||||||||||