Slackget/SpecialFileContainer.pm

filter: Statementstmt 23.7% 14 / 59 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 28.5% 2 / 7 Podpod 100% 5 / 5 totaltotal 19.6% 21 / 107 CC 16 SCAR 49.1
CC
16
Cov
16%
new
210.0
compile
12.0
id
2.0
CRAP 135.6
« Slackget/Search.pm ↑ Summary Slackget.pm »
1 package Slackware::Slackget::SpecialFileContainer;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 require Slackware::Slackget::SpecialFiles::PACKAGES ;
7 2 require Slackware::Slackget::SpecialFiles::FILELIST ;
8 2 require Slackware::Slackget::SpecialFiles::CHECKSUMS ;
9 2 require Slackware::Slackget::PackageList;
10 2 require Slackware::Slackget::Package ;
11  
12 =head1 NAME
13  
14 Slackware::Slackget::SpecialFileContainer - A class to class, sort and compil the PACKAGES.TXT, CHECKSUMS.md5 and FILELIST.TXT
15  
16 =head1 VERSION
17  
18 Version 1.0.0
19  
20 =cut
21  
22 2 our $VERSION = '1.0.0';
23 2 our $DEBUG=0;
24  
25 =head1 SYNOPSIS
26  
27 This class is a front-end for the 3 sub-class Slackware::Slackget::SpecialFiles::PACKAGES , Slackware::Slackget::SpecialFiles::CHECKSUMS and Slackware::Slackget::SpecialFiles::FILELIST.
28  
29 Act as a container but also make a treatment (the compilation of the 3 subclasses in one sol object)
30  
31 =head1 CONSTRUCTOR
32  
33 =head2 new
34  
35 take the following arguments :
36  
37 a unique id
38 FILELIST => the FILELIST.TXT filename
39 PACKAGES => the PACKAGES.TXT filename
40 CHECKSUMS => the CHECKSUMS.md5 filename
41 config => a Slackware::Slackget::Config object.
42  
43 use Slackware::Slackget::SpecialFileContainer;
44  
45 my $container = Slackware::Slackget::SpecialFileContainer->new(
46 'slackware',
47 config => $config,
48 FILELIST => /home/packages/update_files/FILELIST.TXT,
49 PACKAGES => /home/packages/update_files/PACKAGES.TXT,
50 CHECKSUMS => /home/packages/update_files/CHECKSUMS.md5
51 );
52  
53 =cut
54  
55 sub new
56 0 ▶{
Subroutine new: not called CC=14 SCAR=53.5
Pod documented
57 0 my ($class,$root,%args) = @_ ;
58 0 ▶ print "[Slackware::Slackget::SpecialFileContainer] [debug] about to create a new instance\n" if($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $Slackware::Slackget::SpecialFileContainer::DEBUG 0 0 0
59 0 ▶ return undef unless(defined($root));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $root 0 0 0
60 0 my $self={};
61 0 $self->{ROOT} = $root;
62 0 ▶ unless($args{FILELIST} or $args{PACKAGES} or $args{CHECKSUMS}){
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"FILELIST"} or $args{"PACKAGES"} or $args{"CHECKSUMS"}) 0 0 0
Condition0%0/6
$args{"FILELIST"} or $args{"PACKAGES"} or $args{"CHECKSUMS"}
l!l&&r!l&&!r
000
$args{"FILELIST"} or $args{"PACKAGES"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args{"FILELIST"} or $args{"PACKAGES"} or $args{"CHECKSUMS"}
$args{"FILELIST"} $args{"PACKAGES"} $args{"CHECKSUMS"}
Truth table0%0/4
A or B or C
A= $args{"FILELIST"}B= $args{"PACKAGES"}C= $args{"CHECKSUMS"}
ABCresult
1XX1
01X1
0011
0000
63 0 warn "[Slackware::Slackget::SpecialFileContainer] Required parameter FILELIST, PACKAGES or CHECKSUMS not found in the contructor\n";
64 0 return undef;
65 }
66 0 ▶ $self->{DATA}->{config} = $args{config} if(defined($args{config}) && ref($args{config}) eq 'Slackware::Slackget::Config');
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"config"} and ref $args{"config"} eq "Slackware::Slackget::Config" 0 0 0
Condition0%0/3
defined $args{"config"} and ref $args{"config"} eq "Slackware::Slackget::Config"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"config"} and ref $args{"config"} eq "Slackware::Slackget::Config"
defined $args{"config"} ref $args{"config"} eq "Slackware::Slackget::Config"
Truth table0%0/3
A and B
A= defined $args{"config"}B= ref $args{"config"} eq "Slackware::Slackget::Config"
ABresult
0X0
100
111
67 0 ▶ $self->{DATA}->{FILELIST} = Slackware::Slackget::SpecialFiles::FILELIST->new($args{FILELIST},$self->{DATA}->{config},$root) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"DATA"}{"FILELIST"} = "Slackware::Slackget::SpecialFiles::FILELIST"->new($args{"FILELIST"}, $self->{"DATA"}{"config"}, $root) or return undef 0 0 0
68 0 ▶ print "[Slackware::Slackget::SpecialFileContainer] [debug] FILELIST instance : $self->{DATA}->{FILELIST}\n" if($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $Slackware::Slackget::SpecialFileContainer::DEBUG 0 0 0
69 0 ▶ $self->{DATA}->{PACKAGES} = Slackware::Slackget::SpecialFiles::PACKAGES->new($args{PACKAGES},$self->{DATA}->{config},$root) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"DATA"}{"PACKAGES"} = "Slackware::Slackget::SpecialFiles::PACKAGES"->new($args{"PACKAGES"}, $self->{"DATA"}{"config"}, $root) or return undef 0 0 0
70 0 ▶ print "[Slackware::Slackget::SpecialFileContainer] [debug] PACKAGES instance : $self->{DATA}->{PACKAGES}\n" if($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $Slackware::Slackget::SpecialFileContainer::DEBUG 0 0 0
71 0 ▶ $self->{DATA}->{CHECKSUMS} = Slackware::Slackget::SpecialFiles::CHECKSUMS->new($args{CHECKSUMS},$self->{DATA}->{config},$root) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"DATA"}{"CHECKSUMS"} = "Slackware::Slackget::SpecialFiles::CHECKSUMS"->new($args{"CHECKSUMS"}, $self->{"DATA"}{"config"}, $root) or return undef 0 0 0
72 0 ▶ print "[Slackware::Slackget::SpecialFileContainer] [debug] CHECKSUMS instance : $self->{DATA}->{CHECKSUMS}\n" if($DEBUG);
Branch: 1 branch
BranchTrueFalseTotal
if $Slackware::Slackget::SpecialFileContainer::DEBUG 0 0 0
73 0 bless($self);#,$class
74 0 return $self;
75 }
76  
77 =head1 FUNCTIONS
78  
79 =head2 compile
80  
81 Mainly call the compile() method of the special files.
82  
83 $container->compile();
84  
85 =cut
86  
87 0 ▶sub compile {
Subroutine compile: not called CC=3 SCAR=24.8
Pod documented
88 0 my $self = shift;
89 # printf("compiling FILELIST...");
90 0 $|++;
91 0 $self->{DATA}->{FILELIST}->compile ;
92 # print "ok\n";
93 # printf("compiling PACKAGES...");
94 0 $self->{DATA}->{PACKAGES}->compile ;
95 # print "ok\n";
96 # printf("compiling CHECKSUMS...");
97 0 $self->{DATA}->{CHECKSUMS}->compile ;
98 # print "ok\n";
99 # printf("merging data...");
100 0 $self->{DATA}->{PACKAGELIST} = undef;
101 0 ▶ my $packagelist = Slackware::Slackget::PackageList->new('no-root-tag' => 1) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $packagelist = "Slackware::Slackget::PackageList"->new("no-root-tag", 1) or return undef 0 0 0
102 0 my $r_list = $self->{DATA}->{FILELIST}->get_file_list ;
103 0 foreach my $pkg_name (keys(%{$r_list})){
104 # print "[DEBUG] Getting info on $pkg_name\n";
105 0 my $r_pack = $self->{DATA}->{PACKAGES}->get_package($pkg_name);
106 0 my $r_chk = $self->{DATA}->{CHECKSUMS}->get_package($pkg_name);
107 0 my $r_list = $self->{DATA}->{FILELIST}->get_package($pkg_name);
108 0 my $pack = new Slackware::Slackget::Package ($pkg_name);
109 0 $pack->merge($r_pack);
110 0 $pack->merge($r_chk);
111 0 $pack->merge($r_list);
112 0 $packagelist->add($pack);
113 # $pack->print_restricted_info ;
114 }
115 0 $packagelist->index_list ;
116 0 $self->{DATA}->{PACKAGELIST} = $packagelist ;
117 # my $total_size = 0;
118 # foreach (@{$packagelist->get_all})
119 # {
120 # $total_size += $_->compressed_size ;
121 # }
122 # print "TOTAL SIZE: $total_size ko\n";
123 ## WARNING: DEBUG ONLY
124 # use Slackware::Slackget::File;
125 #
126 # my $file = new Slackware::Slackget::File ();
127 # $file->Write("debug/specialfilecontainer_$self->{ROOT}.xml",$self->to_XML) ;
128 # $file->Close;
129 # print "ok\n";
130 }
131  
132 =head2 id
133  
134 Return the id of the SpecialFileContainer object id (like: 'slackware', 'linuxpackages', etc.)
135  
136 my $id = $container->id ;
137  
138 =cut
139  
140 0 ▶sub id {
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
141 0 my $self = shift;
142 0 return $self->{ROOT} ;
143 }
144  
145 =head2 to_XML (deprecated)
146  
147 Same as to_xml(), provided for backward compatibility.
148  
149 =cut
150  
151 0 ▶sub to_XML {
Subroutine to_XML: not called CC=1 SCAR=6.9
Pod documented
152 0 return to_xml(@_);
153 }
154  
155 =head2 to_xml
156  
157 return a string XML encoded which represent the compilation of PACKAGES, FILELIST, CHECKSUMS constructor parameters.
158  
159 my $string = $container->to_xml();
160  
161 =cut
162  
163 0 ▶sub to_xml {
Subroutine to_xml: not called CC=1 SCAR=6.9
Pod documented
164 0 my $self = shift;
165 0 my $xml = " <$self->{ROOT}>\n";
166 # print "\t[$self] XMLization of the $self->{DATA}->{PACKAGELIST} packagelist\n";
167 0 $xml .= $self->{DATA}->{PACKAGELIST}->to_XML ;
168 0 $xml .= " </$self->{ROOT}>\n";
169 0 return $xml;
170 }
171  
172 =head1 AUTHOR
173  
174 DUPUIS Arnaud, C<< <a.dupuis@infinityperl.org> >>
175  
176 =head1 BUGS
177  
178 Please report any bugs or feature requests to
179 C<bug-Slackware-Slackget@rt.cpan.org>, or through the web interface at
180 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget>.
181 I will be notified, and then you'll automatically be notified of progress on
182 your bug as I make changes.
183  
184 =head1 SUPPORT
185  
186 You can find documentation for this module with the perldoc command.
187  
188 perldoc Slackware::Slackget::SpecialFileContainer
189  
190  
191 You can also look for information at:
192  
193 =over 4
194  
195 =item * Infinity Perl website
196  
197 L<http://www.infinityperl.org/category/slack-get>
198  
199 =item * slack-get specific website
200  
201 L<http://slackget.infinityperl.org>
202  
203 =item * RT: CPAN's request tracker
204  
205 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget>
206  
207 =item * AnnoCPAN: Annotated CPAN documentation
208  
209 L<http://annocpan.org/dist/Slackware-Slackget>
210  
211 =item * CPAN Ratings
212  
213 L<http://cpanratings.perl.org/d/Slackware-Slackget>
214  
215 =item * Search CPAN
216  
217 L<http://search.cpan.org/dist/Slackware-Slackget>
218  
219 =back
220  
221 =head1 ACKNOWLEDGEMENTS
222  
223 Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation.
224  
225 =head1 COPYRIGHT & LICENSE
226  
227 Copyright 2005 DUPUIS Arnaud, All Rights Reserved.
228  
229 This program is free software; you can redistribute it and/or modify it
230 under the same terms as Perl itself.
231  
232 =cut
233  
234 2 1; # End of Slackware::Slackget::SpecialFileContainer
« Slackget/Search.pm ↑ Summary Slackget.pm »