File Coverage

blib/lib/App/Gnuget.pm
Criterion Covered Total %
statement 3 30 10.0
branch 0 14 0.0
condition 0 3 0.0
subroutine 1 8 12.5
pod 0 7 0.0
total 4 62 6.4


line stmt bran cond sub pod time code
1             package App::Gnuget;
2 1     1   40740 use Net::FTP;
  1         68128  
  1         443  
3              
4             our $VERSION = 1.935;
5              
6             sub new {
7 0     0 0   my $class = shift;
8 0   0       $class = ref($class) || $class;
9 0           my $self = { ftp => Net::FTP->new("ftp.gnu.org") };
10 0           return bless($self, $class);
11             }
12              
13             sub log {
14 0     0 0   my ($self, $msg) = @_;
15 0           print("[$$] $msg\n");
16             }
17              
18             sub buildFtpCnx {
19 0     0 0   my $self = shift;
20 0 0         $self->{ftp}->login("anonymous", '-anonymous@')
21             or die $self->{ftp}->message;
22 0           $self->log("connected to GNU ftp");
23 0 0         $self->{ftp}->cwd('/gnu') and $self->log("cwd() in gnu/");
24             }
25              
26             sub download {
27 0     0 0   my $self = shift;
28 0 0         $self->{ftp}->cwd($self->{software})
29             and $self->log("cwd() in $self->{software}/");
30 0 0         $self->{ftp}->get($self->{archive})
31             or $self->log("cannot download $self->{archive}");
32 0 0         exit(1) if (! -e $self->{archive});
33 0           $self->log("$self->{archive}'s download successful");
34             }
35              
36             sub populate {
37 0     0 0   my ($self, $name, $version) = @_;
38 0           $self->{software} = $name;
39 0           $self->{version} = $version;
40 0           $self->{archive} = $self->{software}."-".$self->{version}.".tar.gz";
41             }
42              
43              
44             sub clean {
45 0     0 0   my $self = shift;
46 0 0         unlink($self->{archive})
47             or $self->log("Cannot erase $self->{archive}");
48 0           $self->log("$self->{archive} cleaned");
49 0           $self->{ftp}->quit();
50 0           $self->log("disconnected from GNU ftp");
51             }
52              
53             sub uncompress {
54 0     0 0   my $self = shift;
55 0 0         system("tar xf $self->{archive} 2>/dev/null")
56             and $self->log("cannot unpack archive");
57 0           $self->log("$self->{archive} unpacked");
58             }
59              
60             1;
61              
62             __END__