Package.pm

filter: Statementstmt 36.8% 14 / 38 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 4 / 12 Podpod 100% 7 / 7 totaltotal 42.3% 25 / 59 CC 2 SCAR 8.0
CC
2
Cov
35%
new
6.0
get_file
2.0
get_full_name
2.0
CRAP 2.2
« Package/Relationship.pm ↑ Summary
1 # $Id$
2 package Youri::Package;
3  
4 =head1 NAME
5  
6 Youri::Package - Abstract package class
7  
8 =head1 DESCRIPTION
9  
10 This abstract class defines Youri::Package interface.
11  
12 =cut
13  
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use version; our $VERSION = qv('0.2.9');
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 =head1 CLASS METHODS
21  
22 =head2 new(%args)
23  
24 Creates and returns a new Youri::Package object.
25  
26 Warning: do not call directly, call subclass constructor instead.
27  
28 =cut
29  
30 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
31 0 my $class = shift;
32 0 ▶ croak "Abstract class" if $class eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $class eq __PACKAGE__ 0 0 0
33  
34 0 my %options = (
35 @_
36 );
37  
38 0 my $self = bless {
39 }, $class;
40  
41 0 $self->_init(%options);
42  
43 0 return $self;
44 }
45  
46 0 ▶sub _init {
Subroutine _init: not called CC=1 SCAR=0.0
47 # do nothing
48 }
49  
50 =head2 get_pattern($name, $version, $release, $arch)
51  
52 Returns a pattern matching a file for a package, using available informations.
53 All meta characters in arguments are quoted.
54  
55 =head2 get_unquoted_pattern($name, $version, $release, $arch)
56  
57 Returns a pattern matching a file for a package, using available informations.
58 Meta characters in arguments are not quoted.
59  
60 =head2 compare_revisions($revision1, $revision2)
61  
62 Compares two revision tokens, and returns a numeric value:
63  
64 =over
65  
66 =item positive if first revision is higher
67  
68 =item null if both revisions are equal
69  
70 =item negative if first revision is lower
71  
72 =back
73  
74 =head2 check_ranges_compatibility($range1, $range2)
75  
76 Returns a true value if given revision ranges are compatible.
77  
78 =head1 INSTANCE METHODS
79  
80 =head2 as_file()
81  
82 Returns the file corresponding to this package.
83  
84 =head2 as_string()
85  
86 Returns a string representation of this package.
87  
88 =head2 as_formated_string(I<format>)
89  
90 Returns a string representation of this package, formated according to
91 I<format>. Format is a string, where each %{foo} token will get replaced by
92 equivalent tag value.
93  
94 =head2 get_name()
95  
96 Returns the name of this package.
97  
98 =head2 get_version()
99  
100 Returns the version of this package.
101  
102 =head2 get_release()
103  
104 Returns the release of this package.
105  
106 =head2 get_revision()
107  
108 Returns the revision of this package.
109  
110 =head2 get_arch()
111  
112 Returns the architecture of this package.
113  
114 =head2 get_file_name()
115  
116 Returns the file name of this package (name-version-release.arch.extension).
117  
118 =head2 is_source()
119  
120 Returns true if this package is a source package.
121  
122 =head2 is_binary()
123  
124 Returns true if this package is a binary package.
125  
126 =head2 is_debug()
127  
128 Returns true if this package is a debug package.
129  
130 =head2 get_type()
131  
132 Returns the type (binary/source) of this package.
133  
134 =head2 get_age()
135  
136 Returns the age of this package
137  
138 =head2 get_url()
139  
140 Returns the URL of this package
141  
142 =head2 get_summary()
143  
144 Returns the summary of this package
145  
146 =head2 get_description()
147  
148 Returns the description of this package
149  
150 =head2 get_packager()
151  
152 Returns the packager of this package.
153  
154 =head2 get_source_package()
155  
156 Returns the name of the source package of this package.
157  
158 =head2 get_tag($tag)
159  
160 Returns the value of tag $tag of this package.
161  
162 =head2 get_canonical_name()
163  
164 Returns the canonical name of this package, shared by its multiple components,
165 usually the one from the source package.
166  
167 =head2 get_canonical_revision()
168  
169 Returns the canonical revision of this package, shared by its multiple components,
170 usually the one from the source package.
171  
172 =head2 get_requires()
173  
174 Returns the list of dependencies required by this package, as an array of
175 L<Youri::Package::Relationship> objects.
176  
177 =head2 get_provides()
178  
179 Returns the list of dependencies provided by this package, as an array of
180 L<Youri::Package::Relationship> objects.
181  
182 =head2 get_obsoletes()
183  
184 Returns the list of other packages obsoleted by this one, as an array of
185 L<Youri::Package::Relationship> objects.
186  
187 =head2 get_conflicts()
188  
189 Returns the list of other packages conflicting with this one, as an array of
190 L<Youri::Package::Relationship> objects.
191  
192 =head2 get_files()
193  
194 Returns the list of files contained in this package, as an array of
195 L<Youri::Package::File> objects.
196  
197 =head2 get_gpg_key()
198  
199 Returns the gpg key id of package signature.
200  
201 =head2 get_information()
202  
203 Returns formated informations about the package.
204  
205 =head2 get_changes()
206  
207 Returns the list of changes for this package, as an array of
208 L<Youri::Package::Change> objects.
209  
210 =head2 get_last_change()
211  
212 Returns the last change for this package, as as structure described before.
213  
214 =head2 compare($package)
215  
216 Compares ordering with other package, according to their corresponding revision
217 tokens, and returns a numeric value:
218  
219 =over
220  
221 =item positive if this package is newer
222  
223 =item null if both have same revision
224  
225 =item negative if this package is older
226  
227 =back
228  
229 =head2 satisfy_range($range)
230  
231 Returns a true value if this package revision satisfies given revision range.
232  
233 =head2 sign($name, $path, $passphrase)
234  
235 Signs the package with given name, keyring path and passphrase.
236  
237 =head2 extract()
238  
239 Extract package content in local directory.
240  
241 =head1 SUBCLASSING
242  
243 All instances methods have to be implemented.
244  
245 =head1 COPYRIGHT AND LICENSE
246  
247 Copyright (C) 2002-2006, YOURI project
248  
249 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
250  
251 =head2 get_file()
252  
253 Deprecated in favor of as_file().
254  
255 =cut
256  
257 0 ▶sub get_file {
Subroutine get_file: not called CC=1 SCAR=6.9
Pod documented
258 0 my ($self) = @_;
259 0 carp "Deprecated method, use as_file() now";
260  
261 0 return $self->as_file();
262 }
263  
264 =head2 get_full_name()
265  
266 Deprecated in favor of as_string().
267  
268 =cut
269  
270 0 ▶sub get_full_name {
Subroutine get_full_name: not called CC=1 SCAR=6.9
Pod documented
271 0 my ($self) = @_;
272 0 carp "Deprecated method, use as_string now";
273  
274 0 return $self->as_string();
275 }
276  
277 =head2 compare_versions($version1, $version2)
278  
279 Deprecated in favor of compare_revisions().
280  
281 =cut
282  
283 0 ▶sub compare_versions {
Subroutine compare_versions: not called CC=1 SCAR=6.9
Pod documented
284 0 my ($self, $version1, $version2) = @_;
285 0 carp "Deprecated method, use compare_revisions now";
286  
287 0 return $self->compare_revisions($version1, $version2);
288 }
289  
290 =head2 compare_ranges($version1, $version2)
291  
292 Deprecated in favor of check_ranges_compatibility().
293  
294 =cut
295  
296 0 ▶sub compare_ranges {
Subroutine compare_ranges: not called CC=1 SCAR=6.9
Pod documented
297 0 my ($self, $range1, $range2) = @_;
298 0 carp "Deprecated method, use check_ranges_compatibility now";
299  
300 0 return $self->check_ranges_compatibility($range1, $range2);
301 }
302  
303 =head2 get_revision_name()
304  
305 Deprecated in favor of as_formated_string() with proper format string.
306  
307 =cut
308  
309 0 ▶sub get_revision_name {
Subroutine get_revision_name: not called CC=1 SCAR=6.9
Pod documented
310 0 my ($self) = @_;
311 0 carp "Deprecated method, use as_formated_string('%{name}-%{version}-%{release}') now";
312  
313 0 return $self->as_formated_string('%{name}-%{version}-%{release}');
314 }
315  
316 =head2 get_information()
317  
318 Deprecated in favor of as_formated_string() with proper pattern.
319  
320 =cut
321  
322 0 ▶sub get_information {
Subroutine get_information: not called CC=1 SCAR=6.9
Pod documented
323 0 my ($self) = @_;
324 0 carp "Deprecated method, use as_formated_string() with proper format string now";
325  
326 0 return $self->as_formated_string(<<EOF);
327 Name : %-27{NAME} Relocations: %|PREFIXES?{[%{PREFIXES} ]}:{(not relocatable)}|
328 Version : %-27{VERSION} Vendor: %{VENDOR}
329 Release : %-27{RELEASE} Build Date: %{BUILDTIME:date}
330 Install Date: %|INSTALLTIME?{%-27{INSTALLTIME:date}}:{(not installed) }| Build Host: %{BUILDHOST}
331 Group : %-27{GROUP} Source RPM: %{SOURCERPM}
332 Size : %-27{SIZE}%|LICENSE?{ License: %{LICENSE}}|
333 Signature : %|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|
334 %|PACKAGER?{Packager : %{PACKAGER}\n}|%|URL?{URL : %{URL}\n}|Summary : %{SUMMARY}
335 Description :\n%{DESCRIPTION}
336 EOF
337 }
338  
339  
340 1 1;
« Package/Relationship.pm ↑ Summary