line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
7
|
|
|
7
|
|
57079
|
use warnings; |
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
177
|
|
4
|
7
|
|
|
7
|
|
41
|
use autodie; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
151
|
|
5
|
7
|
|
|
7
|
|
2941
|
use utf8; |
|
7
|
|
|
|
|
86825
|
|
|
7
|
|
|
|
|
33
|
|
6
|
7
|
|
|
7
|
|
39715
|
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
57
|
|
7
|
|
|
|
|
|
|
use IO::Uncompress::Gunzip qw( $GunzipError ); |
8
|
7
|
|
|
7
|
|
744
|
use OrePAN2 (); |
|
7
|
|
|
|
|
37488
|
|
|
7
|
|
|
|
|
758
|
|
9
|
7
|
|
|
7
|
|
1946
|
use version 0.9912; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
176
|
|
10
|
7
|
|
|
7
|
|
388
|
|
|
7
|
|
|
|
|
1713
|
|
|
7
|
|
|
|
|
57
|
|
11
|
|
|
|
|
|
|
my $class = shift; |
12
|
|
|
|
|
|
|
my %args = @_ == 1 ? %{ $_[0] } : @_; |
13
|
19
|
|
|
19
|
1
|
13751
|
bless { |
14
|
19
|
50
|
|
|
|
75
|
index => {}, |
|
0
|
|
|
|
|
0
|
|
15
|
19
|
|
|
|
|
112
|
%args, |
16
|
|
|
|
|
|
|
}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my ( $self, $fname ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $fh = do { |
22
|
6
|
|
|
6
|
1
|
46
|
if ( $fname =~ /\.gz\z/ ) { |
23
|
|
|
|
|
|
|
IO::Uncompress::Gunzip->new($fname) |
24
|
6
|
|
|
|
|
27
|
or die "gzip failed: $GunzipError\n"; |
25
|
6
|
100
|
|
|
|
43
|
} |
26
|
3
|
50
|
|
|
|
34
|
else { |
27
|
|
|
|
|
|
|
open my $fh, '<', $fname; |
28
|
|
|
|
|
|
|
$fh; |
29
|
|
|
|
|
|
|
} |
30
|
3
|
|
|
|
|
10
|
}; |
31
|
3
|
|
|
|
|
2423
|
|
32
|
|
|
|
|
|
|
# skip headers |
33
|
|
|
|
|
|
|
while (<$fh>) { |
34
|
|
|
|
|
|
|
last unless /\S/; |
35
|
|
|
|
|
|
|
} |
36
|
6
|
|
|
|
|
5286
|
|
37
|
48
|
100
|
|
|
|
1329
|
while (<$fh>) { |
38
|
|
|
|
|
|
|
if (/^(\S+)\s+(\S+)\s+(.*)$/) { |
39
|
|
|
|
|
|
|
$self->add_index( $1, $2 eq 'undef' ? undef : $2, $3 ); |
40
|
6
|
|
|
|
|
15
|
} |
41
|
22
|
50
|
|
|
|
436
|
} |
42
|
22
|
100
|
|
|
|
65
|
|
43
|
|
|
|
|
|
|
close $fh; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
66
|
my ( $self, $package ) = @_; |
47
|
|
|
|
|
|
|
if ( my $entry = $self->{index}->{$package} ) { |
48
|
|
|
|
|
|
|
return @$entry; |
49
|
|
|
|
|
|
|
} |
50
|
9
|
|
|
9
|
1
|
7834
|
return; |
51
|
9
|
100
|
|
|
|
29
|
} |
52
|
8
|
|
|
|
|
32
|
|
53
|
|
|
|
|
|
|
my ($self) = @_; |
54
|
1
|
|
|
|
|
4
|
sort { lc $a cmp lc $b } keys %{ $self->{index} }; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my ( $self, $package ) = @_; |
58
|
15
|
|
|
15
|
0
|
43
|
delete $self->{index}->{$package}; |
59
|
15
|
|
|
|
|
26
|
return; |
|
87
|
|
|
|
|
194
|
|
|
15
|
|
|
|
|
141
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Order of preference is last updated. So if some modules maintain the same |
63
|
1
|
|
|
1
|
1
|
2
|
# version number across multiple uploads, we'll point to the module in the |
64
|
1
|
|
|
|
|
3
|
# latest archive. |
65
|
1
|
|
|
|
|
2
|
|
66
|
|
|
|
|
|
|
my ( $self, $package, $version, $archive_file ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
if ( $self->{index}{$package} ) { |
69
|
|
|
|
|
|
|
my ($orig_ver) = @{ $self->{index}{$package} }; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
if ( version->parse($orig_ver) > version->parse($version) ) { |
72
|
|
|
|
|
|
|
$version //= 'undef'; |
73
|
72
|
|
|
72
|
1
|
205
|
print STDERR "[INFO] Not adding $package in $archive_file\n"; |
74
|
|
|
|
|
|
|
print STDERR |
75
|
72
|
100
|
|
|
|
248
|
"[INFO] Existing version $orig_ver is greater than $version\n"; |
76
|
9
|
|
|
|
|
34
|
return; |
|
9
|
|
|
|
|
23
|
|
77
|
|
|
|
|
|
|
} |
78
|
9
|
50
|
|
|
|
147
|
} |
79
|
0
|
|
0
|
|
|
0
|
$self->{index}->{$package} = [ $version, $archive_file ]; |
80
|
0
|
|
|
|
|
0
|
} |
81
|
0
|
|
|
|
|
0
|
|
82
|
|
|
|
|
|
|
my ( $self, $opts ) = @_; |
83
|
0
|
|
|
|
|
0
|
$opts ||= +{}; |
84
|
|
|
|
|
|
|
my $simple = $opts->{simple} || 0; |
85
|
|
|
|
|
|
|
|
86
|
72
|
|
|
|
|
521
|
my @buf; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
push @buf, |
89
|
|
|
|
|
|
|
( |
90
|
13
|
|
|
13
|
1
|
115
|
'File: 02packages.details.txt', |
91
|
13
|
|
100
|
|
|
64
|
'URL: http://www.perl.com/CPAN/modules/02packages.details.txt', |
92
|
13
|
|
100
|
|
|
93
|
'Description: DarkPAN', |
93
|
|
|
|
|
|
|
'Columns: package name, version, path', |
94
|
13
|
|
|
|
|
35
|
'Intended-For: Automated fetch routines, namespace documentation.', |
95
|
|
|
|
|
|
|
$simple |
96
|
13
|
100
|
|
|
|
101
|
? () |
97
|
|
|
|
|
|
|
: ( |
98
|
|
|
|
|
|
|
"Written-By: OrePAN2 $OrePAN2::VERSION", |
99
|
|
|
|
|
|
|
"Line-Count: @{[ scalar(keys %{$self->{index}}) ]}", |
100
|
|
|
|
|
|
|
"Last-Updated: @{[ scalar localtime ]}", |
101
|
|
|
|
|
|
|
), |
102
|
|
|
|
|
|
|
q{}, |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
for my $pkg ( $self->packages ) { |
106
|
|
|
|
|
|
|
my $entry = $self->{index}{$pkg}; |
107
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
77
|
|
108
|
9
|
|
|
|
|
508
|
# package name, version, path |
109
|
|
|
|
|
|
|
push @buf, sprintf '%-22s %-22s %s', $pkg, $entry->[0] || 'undef', |
110
|
|
|
|
|
|
|
$entry->[1]; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
return join( "\n", @buf ) . "\n"; |
113
|
13
|
|
|
|
|
109
|
} |
114
|
45
|
|
|
|
|
99
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
45
|
|
100
|
|
|
335
|
=head1 NAME |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
OrePAN2::Index - Index |
120
|
13
|
|
|
|
|
357
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This is a module to manipulate 02packages.details.txt. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 METHODS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over 4 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item C<< my $index = OrePAN2::Index->new(%attr) >> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item C<< $index->load($filename) >> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Load an existing 02.packages.details.txt |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item C<< my ($version, $path) = $index->lookup($package) >> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Perform a package lookup on the index. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item C<< $index->delete_index($package) >> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Delete a package from the index. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item C<< $index->add_index($package, $version, $path) >> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Add a new entry to the index. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item C<< $index->as_string() >> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Returns the content of the index as a string. Some of the index metadata can |
150
|
|
|
|
|
|
|
cause merge conflicts when multiple developers are working on the same project. |
151
|
|
|
|
|
|
|
You can avoid this problem by using a paring down the metadata. "simple" |
152
|
|
|
|
|
|
|
defaults to 0. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
$index->as_string( simple => 1 ); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Make index as string. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |