File Coverage

blib/lib/DPKG/Parse/Packages.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 26 26 100.0


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             DPKG::Parse::Packages - Parse the Packages file
4              
5             =head1 SYNOPSIS
6              
7             use DPKG::Parse::Packages;
8              
9             my $packages = DPKG::Parse::Packages->new(
10             'filename' => '/usr/src/packages/Packages',
11             );
12             while (my $entry = $packages->next_package) {
13             print $entry->package . " " . $entry->version . "\n";
14             }
15              
16             my $postfix = $packages->get_package('name' => 'postfix');
17              
18             =head1 DESCRIPTION
19              
20             L parses a dpkg/apt style Packages file and turns
21             each entry into a L object.
22              
23             See L for more information on the get_package and next_package
24             methods.
25              
26             See L for more information on the entry objects.
27              
28             =head1 METHODS
29              
30             =over 4
31              
32             =cut
33              
34             package DPKG::Parse::Packages;
35              
36             our $VERSION = '0.03';
37              
38 2     2   23580 use Params::Validate qw(:all);
  2         7350  
  2         317  
39 2     2   470 use Class::C3;
  2         2206  
  2         11  
40 2     2   61 use base qw(DPKG::Parse);
  2         4  
  2         441  
41 2     2   8 use strict;
  2         4  
  2         46  
42 2     2   6 use warnings;
  2         3  
  2         159  
43              
44             =item new('filename' => '/usr/src/packages/Packages')
45              
46             Creates a new DPKG::Parse::Packages object. By default, it tries to open
47             /usr/src/packages/Packages.
48              
49             =cut
50             sub new {
51 2     2 1 66 my $pkg = shift;
52 2         79 my %p = validate(@_,
53             {
54             'filename' => { 'type' => SCALAR, 'default' => '/usr/src/packages/Packages', 'optional' => 1 },
55             }
56             );
57 2         21 my $ref = $pkg->next::method('filename' => $p{'filename'});
58 2         7 return $ref;
59             }
60              
61             1;
62              
63             __END__