line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
CPAN::YACSmoke::Plugin::Recent - Recent list for Yet Another CPAN Smoke Tester
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use CPAN::YACSmoke;
|
8
|
|
|
|
|
|
|
my $config = {
|
9
|
|
|
|
|
|
|
list_from => 'Recent',
|
10
|
|
|
|
|
|
|
recent_list_path => '.', # defaults to CPANPLUS base directory
|
11
|
|
|
|
|
|
|
recent_list_age => 1 # max age of file (*)
|
12
|
|
|
|
|
|
|
};
|
13
|
|
|
|
|
|
|
my $foo = CPAN::YACSmoke->new(config => $config);
|
14
|
|
|
|
|
|
|
my @list = $foo->download_list();
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# (*) defaults to always getting a fresh file
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This module provides the backend ability to access the list of current
|
21
|
|
|
|
|
|
|
modules in the F file from a CPAN Mirror.
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This module should be used together with L.
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package CPAN::YACSmoke::Plugin::Recent;
|
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
3
|
|
5847
|
use 5.006001;
|
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
131
|
|
30
|
3
|
|
|
3
|
|
16
|
use strict;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
87
|
|
31
|
3
|
|
|
3
|
|
16
|
use warnings;
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
139
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $VERSION = '0.03';
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# -------------------------------------
|
36
|
|
|
|
|
|
|
# Library Modules
|
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
3
|
|
14
|
use CPAN::YACSmoke;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
207
|
|
39
|
3
|
|
|
3
|
|
17
|
use LWP::Simple;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
33
|
|
40
|
3
|
|
|
3
|
|
1449
|
use URI;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
76
|
|
41
|
3
|
|
|
3
|
|
14
|
use Path::Class;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
155
|
|
42
|
|
|
|
|
|
|
# use File::Spec::Functions qw( catfile );
|
43
|
3
|
|
|
3
|
|
15
|
use IO::File;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
580
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# -------------------------------------
|
46
|
|
|
|
|
|
|
# Constants
|
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
3
|
|
20
|
use constant RECENT_FILE => 'RECENT';
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1750
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# -------------------------------------
|
51
|
|
|
|
|
|
|
# The Subs
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 CONSTRUCTOR
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item new()
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Creates the plugin object.
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=back
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub new {
|
66
|
2
|
|
50
|
2
|
1
|
13137
|
my $class = shift || __PACKAGE__;
|
67
|
2
|
|
|
|
|
5
|
my $hash = shift;
|
68
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
10
|
my $self = {
|
70
|
|
|
|
|
|
|
recent_list_age => 1
|
71
|
|
|
|
|
|
|
};
|
72
|
2
|
|
|
|
|
8
|
foreach my $field (qw( smoke force recent_list_path recent_list_age )) {
|
73
|
8
|
100
|
|
|
|
35
|
$self->{$field} = $hash->{$field} if(exists $hash->{$field});
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
11
|
bless $self, $class;
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHODS
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over 4
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item download_list()
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Return the list of distributions recorded in the latest RECENT file.
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub download_list {
|
90
|
2
|
|
|
2
|
1
|
1409
|
my $self = shift;
|
91
|
|
|
|
|
|
|
|
92
|
2
|
|
33
|
|
|
16
|
my $path = $self->{recent_list_path} || $self->{smoke}->basedir();
|
93
|
2
|
|
|
|
|
16
|
my $local = file( $path, RECENT_FILE ); # catfile
|
94
|
|
|
|
|
|
|
|
95
|
2
|
100
|
33
|
|
|
536
|
if ((!$self->{force}) && $self->{recent_list_age} &&
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
96
|
|
|
|
|
|
|
(-e $local) && ((-M $local) < $self->{recent_list_age}) ) {
|
97
|
|
|
|
|
|
|
# no need to download
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} else {
|
100
|
1
|
|
|
|
|
114
|
my $hosts = $self->{smoke}->{conf}->get_conf('hosts');
|
101
|
1
|
|
|
|
|
256
|
my $h_ind = 0;
|
102
|
|
|
|
|
|
|
|
103
|
1
|
|
|
|
|
7
|
while ($h_ind < @$hosts) {
|
104
|
1
|
|
|
|
|
17
|
my $remote = URI->new( $hosts->[$h_ind]->{scheme} . '://' .
|
105
|
|
|
|
|
|
|
$hosts->[$h_ind]->{host} . $hosts->[$h_ind]->{path} . RECENT_FILE );
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# $self->{smoke}->msg("Downloading $remote to $local", $self->{smoke}->{verbose});
|
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
10428
|
my $status = mirror( $remote, $local );
|
110
|
1
|
50
|
|
|
|
921979
|
last if ($status == RC_OK);
|
111
|
0
|
|
|
|
|
0
|
$h_ind++;
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
|
114
|
1
|
50
|
|
|
|
9
|
return () if(@$hosts == $h_ind); # no host accessible
|
115
|
|
|
|
|
|
|
}
|
116
|
|
|
|
|
|
|
|
117
|
2
|
|
|
|
|
161
|
my @testlist;
|
118
|
2
|
50
|
|
|
|
30
|
my $fh = IO::File->new($local)
|
119
|
|
|
|
|
|
|
or croak("Cannot access local RECENT file [$local]: $!\n");
|
120
|
2
|
|
|
|
|
418
|
while (<$fh>) {
|
121
|
13180
|
100
|
|
|
|
48370
|
next unless(/^authors/);
|
122
|
8798
|
100
|
|
|
|
46042
|
next unless(/\.(tar\.gz|tgz|tar\.bz2|zip)\n$/);
|
123
|
1160
|
|
|
|
|
3823
|
s!authors/id/!!;
|
124
|
1160
|
|
|
|
|
1714
|
chomp;
|
125
|
|
|
|
|
|
|
# $self->{smoke}->msg("RECENT $_", $self->{smoke}->{debug});
|
126
|
|
|
|
|
|
|
# print STDERR $_, "\n";
|
127
|
1160
|
|
|
|
|
5183
|
push @testlist, $_;
|
128
|
|
|
|
|
|
|
}
|
129
|
|
|
|
|
|
|
|
130
|
2
|
|
|
|
|
405
|
return @testlist;
|
131
|
|
|
|
|
|
|
}
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1;
|
134
|
|
|
|
|
|
|
__END__
|