File Coverage

blib/lib/DhMakePerl.pm
Criterion Covered Total %
statement 12 14 85.7
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 17 19 89.4


line stmt bran cond sub pod time code
1             package DhMakePerl;
2              
3 11     11   52538 use warnings;
  11         38  
  11         425  
4 11     11   68 use strict;
  11         19  
  11         251  
5 11     11   433 use 5.010; # we use smart matching
  11         69  
6              
7 11     11   72 use base 'Class::Accessor';
  11         21  
  11         4639  
8              
9             __PACKAGE__->mk_accessors( qw( cfg apt_contents ) );
10              
11             =head1 NAME
12              
13             DhMakePerl - create Debian source package from CPAN dist
14              
15             =head1 VERSION
16              
17             Version 0.90
18              
19             =cut
20              
21             our $VERSION = '0.96';
22              
23             =head1 SYNOPSIS
24              
25             use DhMakePerl;
26              
27             DhMakePerl->run;
28              
29             =head1 ACCESSORS
30              
31             =over
32              
33             =item apt_contents
34              
35             Stores the cached copy of L.
36              
37             =item cfg
38              
39             Stores the configuration, an instance of L
40              
41             =back
42              
43             =head1 CLASS METHODS
44              
45             =over
46              
47             =cut
48              
49 11     11   24161 use Debian::AptContents ();
  0            
  0            
50             use DhMakePerl::Config;
51             use version ();
52              
53             =item run( I<%init> )
54              
55             Runs DhMakePerl.
56              
57             Unless the %init contains an I member, constructs and instance of
58             L and assigns it to I<$init{cfg}>.
59              
60             Then determines the dh-make-perl command requested (via cfg->command), loads
61             the appropriate I class, constructs an instance
62             of it and calls its I method.
63              
64             =cut
65              
66             sub run {
67             my ( $class, %c ) = @_;
68              
69             unless ( $c{cfg} ) {
70             my $cfg = DhMakePerl::Config->new;
71             $cfg->parse_command_line_options;
72             $cfg->parse_config_file;
73             $c{cfg} = $cfg;
74             }
75              
76             my $cmd_mod = $c{cfg}->command;
77             $cmd_mod =~ s/-/_/g;
78             require "DhMakePerl/Command/$cmd_mod.pm";
79              
80             $cmd_mod =~ s{/}{::}g;
81             $cmd_mod = "DhMakePerl::Command::$cmd_mod";
82              
83             my $self = $cmd_mod->new( \%c );
84              
85             return $self->execute;
86             }
87              
88             =item get_apt_contents
89              
90             Returns (possibly cached) instance of L.
91              
92             =cut
93              
94             sub get_apt_contents {
95             my $self = shift;
96              
97             return $self->apt_contents
98             if $self->apt_contents;
99              
100             my $apt_c = Debian::AptContents->new(
101             { homedir => $self->cfg->home_dir,
102             dist => $self->cfg->dist,
103             verbose => $self->cfg->verbose,
104             }
105             );
106              
107             undef $apt_c unless $apt_c->cache;
108              
109             return $self->apt_contents($apt_c);
110             }
111              
112             =back
113              
114             =head1 COPYRIGHT & LICENSE
115              
116             =over
117              
118             =item Copyright (C) 2009, 2010 Damyan Ivanov
119              
120             =back
121              
122             This program is free software; you can redistribute it and/or modify it under
123             the terms of the GNU General Public License version 2 as published by the Free
124             Software Foundation.
125              
126             This program is distributed in the hope that it will be useful, but WITHOUT ANY
127             WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
128             PARTICULAR PURPOSE. See the GNU General Public License for more details.
129              
130             You should have received a copy of the GNU General Public License along with
131             this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
132             Street, Fifth Floor, Boston, MA 02110-1301 USA.
133              
134             =cut
135              
136             1; # End of DhMakePerl