File Coverage

blib/lib/DPKG/Parse/Packages.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


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