line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Module::MetaInfo::ModList.pm - get meta information from the modlist |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 DESCRIPTION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This uses the 03modlist.data file from CPAN to get meta information |
8
|
|
|
|
|
|
|
about perl modules. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 FUNCTIONS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 new(filename) |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Creates an object and reads the modlist file if needed. At present |
15
|
|
|
|
|
|
|
the module list is read in for every ModList object created. This may |
16
|
|
|
|
|
|
|
change in future for greater efficiency, e.g. by doing it once and |
17
|
|
|
|
|
|
|
storing the result in a hash in the class. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package Module::MetaInfo::ModList; |
22
|
2
|
|
|
2
|
|
1454
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
79
|
|
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
2046
|
use Symbol; |
|
2
|
|
|
|
|
1724
|
|
|
2
|
|
|
|
|
177
|
|
25
|
2
|
|
|
2
|
|
16
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2403
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _read_modlist { |
28
|
5
|
|
|
5
|
|
12
|
my $self=shift; |
29
|
5
|
|
|
|
|
10
|
my $file=shift; |
30
|
5
|
|
|
|
|
57
|
my $fh = Symbol::gensym(); |
31
|
5
|
|
|
|
|
165
|
my $data; |
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
357
|
open $fh, "<$file"; |
34
|
|
|
|
|
|
|
|
35
|
5
|
|
|
|
|
30
|
my $contents=""; |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
162
|
while (<$fh>) { |
38
|
125
|
100
|
|
|
|
405
|
m/^\s*\$cols/ and do { |
39
|
5
|
|
|
|
|
11
|
$contents .=$_; |
40
|
5
|
|
|
|
|
16
|
last; |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
5
|
|
|
|
|
47
|
while (<$fh>) { |
44
|
107105
|
|
|
|
|
238622
|
$contents .=$_; |
45
|
|
|
|
|
|
|
} |
46
|
5
|
|
|
|
|
479582
|
eval $contents; |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
695
|
$self->{array}=$data; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# # We hardwire the column into the code here. Argument is that since |
51
|
|
|
|
|
|
|
# # it's the first column it's unlikely to change, |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# $col=0; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
22
|
my $col; |
56
|
5
|
|
|
|
|
19
|
my $primary = "modid"; |
57
|
5
|
|
|
|
|
15
|
my %colhash=(); |
58
|
|
|
|
|
|
|
|
59
|
5
|
|
|
|
|
2619
|
for (my $i=0;$i <= $#$cols; $i++) { |
60
|
40
|
|
|
|
|
166
|
$colhash{$cols->[$i]}=$i; |
61
|
40
|
100
|
|
|
|
138
|
$cols->[$i] eq $primary and do { |
62
|
5
|
|
|
|
|
22
|
$col=$i; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
|
|
23
|
$self->{colhash}=\%colhash; |
67
|
|
|
|
|
|
|
|
68
|
5
|
50
|
|
|
|
22
|
die "undefined column $primary" unless defined $col; |
69
|
|
|
|
|
|
|
|
70
|
5
|
|
|
|
|
11
|
my %hash; |
71
|
5
|
|
|
|
|
25
|
foreach (@$data) { |
72
|
10705
|
|
|
|
|
24647
|
$hash{$_->[$col]} = $_; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
5
|
|
|
|
|
172
|
$self->{hash}=\%hash; |
76
|
|
|
|
|
|
|
|
77
|
5
|
50
|
|
|
|
26
|
die "Failed eval contents of modlist file: $@" if $@; |
78
|
5
|
50
|
|
|
|
22
|
die "\$data variable empty after modlist file" unless $data; |
79
|
5
|
50
|
|
|
|
301
|
die "\$data is not an aray ref" unless (ref $data) =~ m/ARRAY/; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub new { |
84
|
5
|
|
|
5
|
0
|
58
|
my $s = shift; |
85
|
5
|
|
|
|
|
15
|
my $dist_name = shift; |
86
|
5
|
|
|
|
|
19
|
my $mod_file_name = shift; |
87
|
|
|
|
|
|
|
|
88
|
5
|
50
|
33
|
|
|
77
|
croak "usage \$thing->new " |
89
|
|
|
|
|
|
|
if (not $mod_file_name) or @_; |
90
|
|
|
|
|
|
|
|
91
|
5
|
|
33
|
|
|
61
|
my $class = ref($s) || $s; |
92
|
5
|
|
|
|
|
20
|
my $self={}; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
5
|
|
|
|
|
13
|
my $name=$dist_name; |
96
|
5
|
50
|
|
|
|
39
|
die "dist file name can't end in /" if $name=~m,/$,; |
97
|
5
|
|
|
|
|
76
|
$name =~ s,^.*/,,; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# checking the complete list teaches us that all module versions have |
100
|
|
|
|
|
|
|
# a number in them but they can have a letter at any point including |
101
|
|
|
|
|
|
|
# as the first character of the version... Which is not helpful. |
102
|
|
|
|
|
|
|
|
103
|
5
|
50
|
|
|
|
71
|
$name =~ s/-[^-][^0-9][^-]*(.tar.gz)?$// |
104
|
|
|
|
|
|
|
or warn "lack of version in package name: $name"; |
105
|
|
|
|
|
|
|
|
106
|
5
|
|
|
|
|
33
|
$name =~ s/-/::/g; |
107
|
|
|
|
|
|
|
|
108
|
5
|
50
|
|
|
|
22
|
croak "failed to get package name" unless $name; |
109
|
|
|
|
|
|
|
|
110
|
5
|
|
|
|
|
38
|
$self->{name}=$name; |
111
|
5
|
|
|
|
|
30
|
$self->{dist_name}=$dist_name; |
112
|
|
|
|
|
|
|
|
113
|
5
|
|
|
|
|
24
|
bless $self, $class; |
114
|
|
|
|
|
|
|
|
115
|
5
|
|
|
|
|
29
|
$self->_read_modlist($mod_file_name); |
116
|
|
|
|
|
|
|
|
117
|
5
|
|
|
|
|
76
|
return $self; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _return_col { |
122
|
7
|
|
|
7
|
|
25
|
my $self=shift; |
123
|
7
|
|
|
|
|
20
|
my $col=shift; |
124
|
7
|
|
|
|
|
68
|
return $self->{hash}->{$self->{name}}->[$self->{colhash}->{$col}]; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 FUNCTIONS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 development_stage() support_level() |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
these functions return the development stage / support level as |
132
|
|
|
|
|
|
|
defined in the perl modules list using the coding defined in the |
133
|
|
|
|
|
|
|
modules list. This is an interface which is almost certain to change. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub development_stage { |
138
|
2
|
|
|
2
|
1
|
28
|
return shift->_return_col("statd"); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub support_level { |
142
|
2
|
|
|
2
|
1
|
85
|
return shift->_return_col("stats"); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 description() summary() |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
these functions return the description from the modules list. This |
148
|
|
|
|
|
|
|
isn't really a very good description, but is better than nothing. As |
149
|
|
|
|
|
|
|
a summary though it's fine. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub description { |
154
|
|
|
|
|
|
|
#FIXME; add a slightly more verbose explanation that this is a perl module. |
155
|
3
|
|
|
3
|
0
|
23
|
return shift->_return_col("description"); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub summary { |
159
|
0
|
|
|
0
|
0
|
|
return shift->_return_col("description"); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 author() |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This returns the pause userid of the author of the module. This can |
165
|
|
|
|
|
|
|
normally be converted into an email address by adding C<@cpan.org> at |
166
|
|
|
|
|
|
|
the end of it. Please don't put that on any web pages without using |
167
|
|
|
|
|
|
|
web trawler poison. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub author { |
172
|
0
|
|
|
0
|
1
|
|
return shift->_return_col("userid"); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |