line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
4594
|
use 5.008001; |
|
3
|
|
|
|
|
13
|
|
2
|
3
|
|
|
3
|
|
20
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
71
|
|
3
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
147
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package CPAN::Common::Index::LocalPackage; |
6
|
|
|
|
|
|
|
# ABSTRACT: Search index via custom local CPAN package flatfile |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
20
|
use parent 'CPAN::Common::Index::Mirror'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
26
|
|
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
192
|
use Class::Tiny qw/source/; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
21
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
562
|
use Carp; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
152
|
|
15
|
3
|
|
|
3
|
|
16
|
use IO::Uncompress::Gunzip (); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
34
|
|
16
|
3
|
|
|
3
|
|
13
|
use File::Basename (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
35
|
|
17
|
3
|
|
|
3
|
|
15
|
use File::Copy (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
41
|
|
18
|
3
|
|
|
3
|
|
13
|
use File::Spec; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
50
|
|
19
|
3
|
|
|
3
|
|
1250
|
use File::stat (); |
|
3
|
|
|
|
|
17661
|
|
|
3
|
|
|
|
|
1159
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#pod =attr source (REQUIRED) |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod Path to a local file in the form of 02packages.details.txt. It may |
24
|
|
|
|
|
|
|
#pod be compressed with a ".gz" suffix or it may be uncompressed. |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod =attr cache |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod Path to a local directory to store a (possibly uncompressed) copy |
29
|
|
|
|
|
|
|
#pod of the source index. Defaults to a temporary directory if not |
30
|
|
|
|
|
|
|
#pod specified. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub BUILD { |
35
|
11
|
|
|
11
|
0
|
62
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
11
|
|
|
|
|
240
|
my $file = $self->source; |
38
|
11
|
100
|
|
|
|
243
|
if ( !defined $file ) { |
|
|
100
|
|
|
|
|
|
39
|
1
|
|
|
|
|
288
|
Carp::croak("'source' parameter must be provided"); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ( !-f $file ) { |
42
|
1
|
|
|
|
|
260
|
Carp::croak("index file '$file' does not exist"); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
9
|
|
|
|
|
39
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub cached_package { |
49
|
18
|
|
|
18
|
0
|
571
|
my ($self) = @_; |
50
|
18
|
|
|
|
|
391
|
my $package = File::Spec->catfile( |
51
|
|
|
|
|
|
|
$self->cache, File::Basename::basename($self->source) |
52
|
|
|
|
|
|
|
); |
53
|
18
|
|
|
|
|
1248
|
$package =~ s/\.gz$//; |
54
|
18
|
100
|
|
|
|
336
|
$self->refresh_index unless -r $package; |
55
|
18
|
|
|
|
|
71
|
return $package; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub refresh_index { |
59
|
3
|
|
|
3
|
1
|
1935
|
my ($self) = @_; |
60
|
3
|
|
|
|
|
63
|
my $source = $self->source; |
61
|
3
|
|
|
|
|
121
|
my $basename = File::Basename::basename($source); |
62
|
3
|
100
|
|
|
|
19
|
if ( $source =~ /\.gz$/ ) { |
63
|
1
|
|
|
|
|
8
|
( my $uncompressed = $basename ) =~ s/\.gz$//; |
64
|
1
|
|
|
|
|
30
|
$uncompressed = File::Spec->catfile( $self->cache, $uncompressed ); |
65
|
1
|
50
|
33
|
|
|
51
|
if ( !-f $uncompressed |
66
|
|
|
|
|
|
|
or File::stat::stat($source)->mtime > File::stat::stat($uncompressed)->mtime ) { |
67
|
1
|
50
|
|
|
|
6
|
IO::Uncompress::Gunzip::gunzip( map { "$_" } $source, $uncompressed ) |
|
2
|
|
|
|
|
15
|
|
68
|
|
|
|
|
|
|
or Carp::croak "gunzip failed: $IO::Uncompress::Gunzip::GunzipError\n"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
2
|
|
|
|
|
32
|
my $dest = File::Spec->catfile( $self->cache, $basename ); |
73
|
2
|
50
|
33
|
|
|
65
|
File::Copy::copy($source, $dest) |
74
|
|
|
|
|
|
|
if !-e $dest || File::stat::stat($source)->mtime > File::stat::stat($dest)->mtime; |
75
|
|
|
|
|
|
|
} |
76
|
3
|
|
|
|
|
4209
|
return 1; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
0
|
1
|
|
sub search_authors { return }; # this package handles packages only |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4 et: |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |