File Coverage

blib/lib/DPKG/Parse/Available.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::Available - Parse the "available" file
4              
5             =head1 SYNOPSIS
6              
7             use DPKG::Parse::Available;
8              
9             my $available = DPKG::Parse::Available->new;
10             while (my $entry = $available->next_package) {
11             print $entry->package . " " . $entry->version . "\n";
12             }
13              
14             my $postfix = $available->get_package('name' => 'postfix');
15              
16             =head1 DESCRIPTION
17              
18             L parses a dpkg "available" file and turns
19             each entry into a L object. By default, it uses
20             the Debian default location of "/var/lib/dpkg/available".
21              
22             See L for more information on the get_package and next_package
23             methods.
24              
25             See L for more information on the entry objects.
26              
27             =head1 METHODS
28              
29             =over 4
30              
31             =cut
32              
33             package DPKG::Parse::Available;
34              
35             our $VERSION = '0.02'; # TRIAL
36              
37 2     2   24713 use Params::Validate qw(:all);
  2         7459  
  2         365  
38 2     2   488 use Class::C3;
  2         2593  
  2         9  
39 2     2   63 use base qw(DPKG::Parse);
  2         2  
  2         450  
40 2     2   9 use strict;
  2         3  
  2         48  
41 2     2   15 use warnings;
  2         2  
  2         162  
42              
43             =item new('filename' => '/var/lib/dpkg/available')
44              
45             Creates a new DPKG::Parse::Available object. By default, it tries to open
46             /var/lib/dpkg/available.
47              
48             =cut
49             sub new {
50 2     2 1 58 my $pkg = shift;
51 2         84 my %p = validate(@_,
52             {
53             'filename' => { 'type' => SCALAR, 'default' => '/var/lib/dpkg/available', 'optional' => 1 },
54             }
55             );
56 2         17 my $ref = $pkg->next::method('filename' => $p{'filename'});
57 2         6 return $ref;
58             }
59              
60             1;
61              
62             __END__