line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Install::Admin::DOAP; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
15934
|
use 5.008; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
6
|
use base qw(Module::Install::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
118
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
574
|
use Module::Install::Admin::RDF 0.003; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use RDF::Trine; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.006'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use RDF::Trine::Namespace qw[RDF RDFS OWL XSD]; |
13
|
|
|
|
|
|
|
my $CPAN = RDF::Trine::Namespace->new('http://purl.org/NET/cpan-uri/terms#'); |
14
|
|
|
|
|
|
|
my $DC = RDF::Trine::Namespace->new('http://purl.org/dc/terms/'); |
15
|
|
|
|
|
|
|
my $DOAP = RDF::Trine::Namespace->new('http://usefulinc.com/ns/doap#'); |
16
|
|
|
|
|
|
|
my $DEPS = RDF::Trine::Namespace->new('http://ontologi.es/doap-deps#'); |
17
|
|
|
|
|
|
|
my $FOAF = RDF::Trine::Namespace->new('http://xmlns.com/foaf/0.1/'); |
18
|
|
|
|
|
|
|
my $NFO = RDF::Trine::Namespace->new('http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#'); |
19
|
|
|
|
|
|
|
my $SKOS = RDF::Trine::Namespace->new('http://www.w3.org/2004/02/skos/core#'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub doap_metadata |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
my ($self, $uri) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
unless (defined $uri) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
$uri = Module::Install::Admin::RDF::rdf_project_uri($self); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
unless (ref $uri) |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
$uri = RDF::Trine::Node::Resource->new($uri); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $metadata = sub { |
35
|
|
|
|
|
|
|
$self->_top->call(@_); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $model = Module::Install::Admin::RDF::rdf_metadata($self); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $name; |
41
|
|
|
|
|
|
|
NAME: foreach ($model->objects_for_predicate_list($uri, $DOAP->name, $FOAF->name, $RDFS->label)) |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
next NAME unless $_->is_literal; |
44
|
|
|
|
|
|
|
$name = $_->literal_value; |
45
|
|
|
|
|
|
|
$metadata->(name => $_->literal_value); |
46
|
|
|
|
|
|
|
last NAME; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $mname; |
50
|
|
|
|
|
|
|
MNAME: foreach ($model->objects_for_predicate_list($uri, $CPAN->module_name)) |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
next MNAME unless $_->is_literal; |
53
|
|
|
|
|
|
|
$mname = $_->literal_value; |
54
|
|
|
|
|
|
|
$metadata->(module_name => $_->literal_value); |
55
|
|
|
|
|
|
|
last MNAME; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
if (defined $name and !defined $mname) |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
$mname = $name; |
60
|
|
|
|
|
|
|
$mname =~ s/-/::/g; |
61
|
|
|
|
|
|
|
$metadata->(module_name => $mname); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
DESC: foreach ($model->objects_for_predicate_list($uri, $DOAP->shortdesc, $DC->abstract)) |
65
|
|
|
|
|
|
|
{ |
66
|
|
|
|
|
|
|
next DESC unless $_->is_literal; |
67
|
|
|
|
|
|
|
$metadata->(abstract => $_->literal_value); |
68
|
|
|
|
|
|
|
last DESC; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
LICENSE: foreach ($model->objects_for_predicate_list($uri, $DOAP->license, $DC->license)) |
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
next LICENSE unless $_->is_resource; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $license_code = { |
76
|
|
|
|
|
|
|
'http://www.gnu.org/licenses/agpl-3.0.txt' => 'open_source', |
77
|
|
|
|
|
|
|
'http://www.apache.org/licenses/LICENSE-1.1' => 'apache_1_1', |
78
|
|
|
|
|
|
|
'http://www.apache.org/licenses/LICENSE-2.0' => 'apache', |
79
|
|
|
|
|
|
|
'http://www.apache.org/licenses/LICENSE-2.0.txt' => 'apache', |
80
|
|
|
|
|
|
|
'http://www.perlfoundation.org/artistic_license_1_0' => 'artistic', |
81
|
|
|
|
|
|
|
'http://opensource.org/licenses/artistic-license.php' => 'artistic', |
82
|
|
|
|
|
|
|
'http://www.perlfoundation.org/artistic_license_2_0' => 'artistic_2', |
83
|
|
|
|
|
|
|
'http://opensource.org/licenses/artistic-license-2.0.php' => 'artistic_2', |
84
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/bsd-license.php' => 'bsd', |
85
|
|
|
|
|
|
|
'http://creativecommons.org/publicdomain/zero/1.0/' => 'unrestricted', |
86
|
|
|
|
|
|
|
'http://www.freebsd.org/copyright/freebsd-license.html' => 'open_source', |
87
|
|
|
|
|
|
|
'http://www.gnu.org/copyleft/fdl.html' => 'open_source', |
88
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/gpl-license.php' => 'gpl', |
89
|
|
|
|
|
|
|
'http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt' => 'gpl', |
90
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/gpl-2.0.php' => 'gpl2', |
91
|
|
|
|
|
|
|
'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt' => 'gpl2', |
92
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/gpl-3.0.html' => 'gpl3', |
93
|
|
|
|
|
|
|
'http://www.gnu.org/licenses/gpl-3.0.txt' => 'gpl3', |
94
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/lgpl-license.php' => 'lgpl', |
95
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/lgpl-2.1.php' => 'lgpl2', |
96
|
|
|
|
|
|
|
'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt' => 'lgpl2', |
97
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/lgpl-3.0.html' => 'lgpl3', |
98
|
|
|
|
|
|
|
'http://www.gnu.org/licenses/lgpl-3.0.txt' => 'lgpl3', |
99
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/mit-license.php' => 'mit', |
100
|
|
|
|
|
|
|
'http://www.mozilla.org/MPL/MPL-1.0.txt' => 'mozilla', |
101
|
|
|
|
|
|
|
'http://www.mozilla.org/MPL/MPL-1.1.txt' => 'mozilla', |
102
|
|
|
|
|
|
|
'http://opensource.org/licenses/mozilla1.1.php' => 'mozilla', |
103
|
|
|
|
|
|
|
'http://www.openssl.org/source/license.html' => 'open_source', |
104
|
|
|
|
|
|
|
'http://dev.perl.org/licenses/' => 'perl', |
105
|
|
|
|
|
|
|
'http://www.opensource.org/licenses/postgresql' => 'open_source', |
106
|
|
|
|
|
|
|
'http://trolltech.com/products/qt/licenses/licensing/qpl' => 'open_source', |
107
|
|
|
|
|
|
|
'http://h71000.www7.hp.com/doc/83final/BA554_90007/apcs02.html' => 'unrestricted', |
108
|
|
|
|
|
|
|
'http://www.openoffice.org/licenses/sissl_license.html' => 'open_source', |
109
|
|
|
|
|
|
|
'http://www.zlib.net/zlib_license.html' => 'open_source', |
110
|
|
|
|
|
|
|
}->{ $_->uri } || undef; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$metadata->(license => $license_code); |
113
|
|
|
|
|
|
|
last LICENSE; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my %resources; |
117
|
|
|
|
|
|
|
($resources{license}) = |
118
|
|
|
|
|
|
|
map { $_->uri } |
119
|
|
|
|
|
|
|
grep { $_->is_resource } |
120
|
|
|
|
|
|
|
$model->objects_for_predicate_list($uri, $DOAP->license, $DC->license); |
121
|
|
|
|
|
|
|
($resources{homepage}) = |
122
|
|
|
|
|
|
|
map { $_->uri } |
123
|
|
|
|
|
|
|
grep { $_->is_resource } |
124
|
|
|
|
|
|
|
$model->objects_for_predicate_list($uri, $DOAP->homepage, $FOAF->homepage, $FOAF->page); |
125
|
|
|
|
|
|
|
($resources{bugtracker}) = |
126
|
|
|
|
|
|
|
map { $_->uri } |
127
|
|
|
|
|
|
|
grep { $_->is_resource } |
128
|
|
|
|
|
|
|
$model->objects($uri, $DOAP->uri('bug-database')); |
129
|
|
|
|
|
|
|
REPO: foreach my $repo ($model->objects($uri, $DOAP->repository)) |
130
|
|
|
|
|
|
|
{ |
131
|
|
|
|
|
|
|
next REPO if $repo->is_literal; |
132
|
|
|
|
|
|
|
($resources{repository}) = |
133
|
|
|
|
|
|
|
map { $_->uri } |
134
|
|
|
|
|
|
|
grep { $_->is_resource } |
135
|
|
|
|
|
|
|
$model->objects($repo, $DOAP->uri('browse')); |
136
|
|
|
|
|
|
|
last REPO if $resources{repository}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
($resources{MailingList}) = |
139
|
|
|
|
|
|
|
map { $_->uri } |
140
|
|
|
|
|
|
|
grep { $_->is_resource } |
141
|
|
|
|
|
|
|
$model->objects($uri, $DOAP->uri('mailing-list')); |
142
|
|
|
|
|
|
|
($resources{Wiki}) = |
143
|
|
|
|
|
|
|
map { $_->uri } |
144
|
|
|
|
|
|
|
grep { $_->is_resource } |
145
|
|
|
|
|
|
|
$model->objects($uri, $DOAP->uri('wiki')); |
146
|
|
|
|
|
|
|
$metadata->(resources => %resources); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my %keywords; |
149
|
|
|
|
|
|
|
CATEGORY: foreach my $cat ($model->objects_for_predicate_list($uri, $DOAP->category, $DC->subject)) |
150
|
|
|
|
|
|
|
{ |
151
|
|
|
|
|
|
|
if ($cat->is_literal) |
152
|
|
|
|
|
|
|
{ |
153
|
|
|
|
|
|
|
$keywords{ uc $cat->literal_value } = $cat->literal_value; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
else |
156
|
|
|
|
|
|
|
{ |
157
|
|
|
|
|
|
|
LABEL: foreach my $label ($model->objects_for_predicate_list($cat, $SKOS->prefLabel, $RDFS->label, $DOAP->name, $FOAF->name)) |
158
|
|
|
|
|
|
|
{ |
159
|
|
|
|
|
|
|
next LABEL unless $label->is_literal; |
160
|
|
|
|
|
|
|
$keywords{ uc $label->literal_value } = $label->literal_value; |
161
|
|
|
|
|
|
|
next CATEGORY; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
$metadata->(keywords => sort values %keywords); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
my %authors; |
168
|
|
|
|
|
|
|
AUTHOR: foreach my $author ($model->objects_for_predicate_list($uri, $DOAP->developer, $DOAP->maintainer, $FOAF->maker, $DC->creator)) |
169
|
|
|
|
|
|
|
{ |
170
|
|
|
|
|
|
|
my ($name) = |
171
|
|
|
|
|
|
|
map { $_->literal_value } |
172
|
|
|
|
|
|
|
grep { $_->is_literal } |
173
|
|
|
|
|
|
|
$model->objects_for_predicate_list($author, $FOAF->name, $RDFS->label); |
174
|
|
|
|
|
|
|
my ($mbox) = |
175
|
|
|
|
|
|
|
map { my $x = $_->uri; $x =~ s/^mailto://i; $x; } |
176
|
|
|
|
|
|
|
grep { $_->is_resource } |
177
|
|
|
|
|
|
|
$model->objects_for_predicate_list($author, $FOAF->mbox); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $str = do |
180
|
|
|
|
|
|
|
{ |
181
|
|
|
|
|
|
|
if ($name and $mbox) |
182
|
|
|
|
|
|
|
{ "$name <$mbox>"; } |
183
|
|
|
|
|
|
|
elsif ($name) |
184
|
|
|
|
|
|
|
{ $name; } |
185
|
|
|
|
|
|
|
elsif ($mbox) |
186
|
|
|
|
|
|
|
{ $mbox; } |
187
|
|
|
|
|
|
|
else |
188
|
|
|
|
|
|
|
{ "$author"; } |
189
|
|
|
|
|
|
|
}; |
190
|
|
|
|
|
|
|
$authors{uc $str} = $str; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
$metadata->(authors => sort values %authors); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
{ |
195
|
|
|
|
|
|
|
my @terms = qw(requires build_requires configure_requires test_requires recommends provides); |
196
|
|
|
|
|
|
|
foreach my $term (@terms) |
197
|
|
|
|
|
|
|
{ |
198
|
|
|
|
|
|
|
foreach my $dep ($model->objects($uri, $CPAN->$term)) |
199
|
|
|
|
|
|
|
{ |
200
|
|
|
|
|
|
|
warn "$term is deprecated in favour of http://ontologi.es/doap-deps#"; |
201
|
|
|
|
|
|
|
if ($dep->is_literal) |
202
|
|
|
|
|
|
|
{ |
203
|
|
|
|
|
|
|
my ($mod, $ver) = split /\s+/, $dep->literal_value; |
204
|
|
|
|
|
|
|
$ver ||= 0; |
205
|
|
|
|
|
|
|
$metadata->($term => $mod => $ver); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
else |
208
|
|
|
|
|
|
|
{ |
209
|
|
|
|
|
|
|
warn "Dunno what to do with ${dep}... we'll figure something out eventually."; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
foreach my $phase (qw/ configure build test runtime develop /) |
216
|
|
|
|
|
|
|
{ |
217
|
|
|
|
|
|
|
foreach my $level (qw/ requirement recommendation suggestion /) |
218
|
|
|
|
|
|
|
{ |
219
|
|
|
|
|
|
|
my $term = "${phase}-${level}"; |
220
|
|
|
|
|
|
|
my $mi_term = { |
221
|
|
|
|
|
|
|
'configure-requirement' => 'configure_requires', |
222
|
|
|
|
|
|
|
'build-requirement' => 'build_requires', |
223
|
|
|
|
|
|
|
'test-requirement' => 'test_requires', |
224
|
|
|
|
|
|
|
'runtime-requirement' => 'requires', |
225
|
|
|
|
|
|
|
'build-recommendation' => 'recommends', |
226
|
|
|
|
|
|
|
'test-recommendation' => 'recommends', |
227
|
|
|
|
|
|
|
'runtime-recommendation' => 'recommends', |
228
|
|
|
|
|
|
|
}->{$term} or next; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
foreach my $dep ( $model->objects($uri, $DEPS->uri($term)) ) |
231
|
|
|
|
|
|
|
{ |
232
|
|
|
|
|
|
|
if ($dep->is_literal) |
233
|
|
|
|
|
|
|
{ |
234
|
|
|
|
|
|
|
warn $DEPS->$term . " expects a resource, not literal $dep!"; |
235
|
|
|
|
|
|
|
next; |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
foreach my $ident ( $model->objects($dep, $DEPS->on) ) |
239
|
|
|
|
|
|
|
{ |
240
|
|
|
|
|
|
|
unless ($ident->is_literal |
241
|
|
|
|
|
|
|
and $ident->has_datatype |
242
|
|
|
|
|
|
|
and $ident->literal_datatype eq $DEPS->CpanId->uri) |
243
|
|
|
|
|
|
|
{ |
244
|
|
|
|
|
|
|
warn "Dunno what to do with ${ident}... we'll figure something out eventually."; |
245
|
|
|
|
|
|
|
next; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
my ($mod, $ver) = split /\s+/, $ident->literal_value; |
249
|
|
|
|
|
|
|
$ver ||= 0; |
250
|
|
|
|
|
|
|
$metadata->($mi_term => $mod => $ver); |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
{ |
257
|
|
|
|
|
|
|
my @terms = qw(abstract_from author_from license_from perl_version_from readme_from requires_from version_from |
258
|
|
|
|
|
|
|
no_index install_script requires_external_bin); |
259
|
|
|
|
|
|
|
TERM: foreach my $term (@terms) |
260
|
|
|
|
|
|
|
{ |
261
|
|
|
|
|
|
|
foreach my $val ($model->objects($uri, $CPAN->$term)) |
262
|
|
|
|
|
|
|
{ |
263
|
|
|
|
|
|
|
if ($val->is_literal) |
264
|
|
|
|
|
|
|
{ |
265
|
|
|
|
|
|
|
$metadata->($term => $val->literal_value); |
266
|
|
|
|
|
|
|
next TERM; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
else |
269
|
|
|
|
|
|
|
{ |
270
|
|
|
|
|
|
|
foreach my $name ($model->objects($val, $NFO->fileName)) |
271
|
|
|
|
|
|
|
{ |
272
|
|
|
|
|
|
|
if ($name->is_literal) |
273
|
|
|
|
|
|
|
{ |
274
|
|
|
|
|
|
|
$metadata->($term => $name->literal_value); |
275
|
|
|
|
|
|
|
next TERM; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
1; |