File Coverage

blib/lib/DhMakePerl/Command/locate.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             package DhMakePerl::Command::locate;
2              
3             =head1 NAME
4              
5             DhMakePerl::Command::locate - dh-make-perl locate implementation
6              
7             =head1 DESCRIPTION
8              
9             This module implements the I command of L.
10              
11             =cut
12              
13 1     1   2083858 use strict; use warnings;
  1     1   2  
  1         82  
  1         22  
  1         3  
  1         194  
14              
15             our $VERSION = '0.81';
16              
17 1     1   67 use base 'DhMakePerl';
  1         8  
  1         776  
18              
19             use DhMakePerl::Utils qw(is_core_module);
20              
21             =head1 METHODS
22              
23             =over
24              
25             =item execute
26              
27             Provides I command implementation.
28              
29             =cut
30              
31             sub execute {
32             my $self = shift;
33              
34             @ARGV >= 1
35             or die "locate command requires at least one non-option argument\n";
36              
37             my $apt_contents = $self->get_apt_contents;
38              
39             unless ($apt_contents) {
40             die <
41             Unable to locate module packages, because APT Contents files
42             are not available on the system.
43              
44             Install the 'apt-file' package, run 'apt-file update' as root
45             and retry.
46             EOF
47             }
48              
49             my $result = 0;
50             for my $mod (@ARGV) {
51             if ( defined( my $core_since = is_core_module($mod) ) ) {
52             print "$mod is in Perl core (package perl)";
53             print $core_since ? " since $core_since\n" : "\n";
54             }
55             elsif ( my $pkg = $apt_contents->find_perl_module_package($mod) ) {
56             print "$mod is in $pkg package\n";
57             }
58             else {
59             print "$mod is not found in any Debian package\n";
60             $result = 1;
61             }
62             }
63              
64             return $result;
65             }
66              
67             =back
68              
69             =cut
70              
71             1;
72              
73             =head1 COPYRIGHT & LICENSE
74              
75             =over
76              
77             =item Copyright (C) 2009 Franck Joncourt
78              
79             =item Copyright (C) 2009, 2010 Damyan Ivanov
80              
81             =back
82              
83             This program is free software; you can redistribute it and/or modify it under
84             the terms of the GNU General Public License version 2 as published by the Free
85             Software Foundation.
86              
87             This program is distributed in the hope that it will be useful, but WITHOUT ANY
88             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
89             PARTICULAR PURPOSE. See the GNU General Public License for more details.
90              
91             You should have received a copy of the GNU General Public License along with
92             this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
93             Street, Fifth Floor, Boston, MA 02110-1301 USA.
94              
95             =cut
96