line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
109341
|
use 5.010; |
|
2
|
|
|
|
|
19
|
|
2
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
40
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
137
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package RDF::DOAP; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.104'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1159
|
use Moose; |
|
2
|
|
|
|
|
950394
|
|
|
2
|
|
|
|
|
14
|
|
11
|
|
|
|
|
|
|
extends 'RDF::DOAP::Resource'; |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
16290
|
use RDF::Trine; |
|
2
|
|
|
|
|
1961369
|
|
|
2
|
|
|
|
|
112
|
|
14
|
2
|
|
|
2
|
|
1093
|
use RDF::DOAP::Project; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
122
|
|
15
|
2
|
|
|
2
|
|
23
|
use RDF::DOAP::Types -types; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
24
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
11501
|
use RDF::Trine::Namespace qw(rdf rdfs owl xsd); |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
19
|
|
18
|
|
|
|
|
|
|
my $doap = 'RDF::Trine::Namespace'->new('http://usefulinc.com/ns/doap#'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has projects => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => ArrayRef[Project], |
23
|
|
|
|
|
|
|
default => sub { [] }, |
24
|
|
|
|
|
|
|
coerce => 1, |
25
|
|
|
|
|
|
|
init_arg => '_projects', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub from_url |
29
|
|
|
|
|
|
|
{ |
30
|
0
|
|
|
0
|
1
|
0
|
require RDF::Trine; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
my $class = shift; |
33
|
0
|
|
|
|
|
0
|
my ($url) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
my $model = 'RDF::Trine::Model'->new; |
36
|
0
|
|
|
|
|
0
|
'RDF::Trine::Parser'->parse_url_into_model("$url", $model); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
return $class->from_model($model, { rdf_about => $url }); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub from_file |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
0
|
1
|
0
|
require RDF::Trine; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
my $class = shift; |
46
|
0
|
|
|
|
|
0
|
my ($fh, $base) = @_; |
47
|
0
|
|
0
|
|
|
0
|
$base //= 'http://localhost/'; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
my $model = 'RDF::Trine::Model'->new; |
50
|
0
|
|
|
|
|
0
|
'RDF::Trine::Parser'->parse_file_into_model($base, $fh, $model); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
return $class->from_model($model); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub from_model |
56
|
|
|
|
|
|
|
{ |
57
|
1
|
|
|
1
|
1
|
790618
|
my $class = shift; |
58
|
1
|
|
|
|
|
4
|
my ($model, $args) = @_; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# required for coercion to work! |
61
|
1
|
|
|
|
|
12
|
local $RDF::DOAP::Resource::MODEL = $model; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$class->new( |
64
|
1
|
50
|
|
|
|
6
|
%{ $args || {} }, |
|
1
|
|
|
|
|
29
|
|
65
|
|
|
|
|
|
|
rdf_model => $model, |
66
|
|
|
|
|
|
|
_projects => [ $model->subjects($rdf->type, $doap->Project) ], |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub project |
71
|
|
|
|
|
|
|
{ |
72
|
1
|
|
|
1
|
1
|
903
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
5
|
my @projects = @{$self->projects}; |
|
1
|
|
|
|
|
27
|
|
75
|
1
|
50
|
|
|
|
8
|
return $projects[0] if @projects <= 1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my @sorted = |
78
|
|
|
|
|
|
|
map $_->[0], |
79
|
0
|
0
|
0
|
|
|
|
sort { $b->[1] <=> $a->[1] } |
|
0
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
map [ |
81
|
|
|
|
|
|
|
$_, |
82
|
|
|
|
|
|
|
$_->has_rdf_model && $_->has_rdf_about |
83
|
|
|
|
|
|
|
? $_->rdf_model->count_statements($_->rdf_about, undef, undef) |
84
|
|
|
|
|
|
|
: 0 |
85
|
|
|
|
|
|
|
], @projects; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return $sorted[0]; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=encoding utf-8 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=begin stopwords |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
rdfs:Resource |
101
|
|
|
|
|
|
|
doap:Project |
102
|
|
|
|
|
|
|
doap:Repository |
103
|
|
|
|
|
|
|
foaf:Person |
104
|
|
|
|
|
|
|
doap:Version |
105
|
|
|
|
|
|
|
dcs:ChangeSet |
106
|
|
|
|
|
|
|
dcs:Change |
107
|
|
|
|
|
|
|
dbug:Issue |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=end stopwords |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 NAME |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
RDF::DOAP - an object-oriented interface for DOAP (Description of a Project) data |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SYNOPSIS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
use feature 'say'; |
118
|
|
|
|
|
|
|
use RDF::DOAP; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $url = 'http://api.metacpan.org/source/DOY/Moose-2.0604/doap.rdf'; |
121
|
|
|
|
|
|
|
my $doap = 'RDF::DOAP'->from_url($url); |
122
|
|
|
|
|
|
|
my $proj = $doap->project; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
say $proj->name; # "Moose" |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
say $_->name |
127
|
|
|
|
|
|
|
for @{ $proj->maintainer }; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 DESCRIPTION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
A little sparsely documented right now. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The RDF::DOAP class itself is mostly a wrapper for parsing RDF |
134
|
|
|
|
|
|
|
and building objects. Most of the interesting stuff is in the |
135
|
|
|
|
|
|
|
L</Bundled Classes>. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 Constructors |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item C<< new(%attrs) >> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
You don't want to use this. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item C<< from_url($url) >> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Parse the RDF at the given URL and construct an RDF::DOAP object. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item C<< from_file($fh, $base) >> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Parse a file handle or file name. A base URL may be provided for |
152
|
|
|
|
|
|
|
resolving relative URI references; if omitted the base is assumed |
153
|
|
|
|
|
|
|
to be C<< http://localhost/ >> which is almost certainly wrong. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item C<< from_model($model) >> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Read DOAP from an existing L<RDF::Trine::Model>. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 Attributes |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item C<< projects >> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
An arrayref; the list of software projects found in the input data. |
168
|
|
|
|
|
|
|
This cannot be provided in the constructor. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=back |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 Methods |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=over |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item C<< project >> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
If C<< projects >> contains only one project, returns it. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Otherwise, tries to guess which of the projects the input data was |
181
|
|
|
|
|
|
|
mostly trying to describe. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 Bundled Classes |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Within each of these classes, the attributes correspond roughly to |
188
|
|
|
|
|
|
|
the properties defined for them in the DOAP schema; however hyphens |
189
|
|
|
|
|
|
|
in property URIs become underscores in attribute names. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=over |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item B<< L<RDF::DOAP::Resource> >> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Correponds roughly to the I<< rdfs:Resource >> class, excluding |
196
|
|
|
|
|
|
|
literals. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item B<< L<RDF::DOAP::Project> >> |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Correponds to I<< doap:Project >>. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item B<< L<RDF::DOAP::Repository> >> |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Correponds to I<< doap:Repository >>. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item B<< L<RDF::DOAP::Person> >> |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Correponds to I<< foaf:Person >>. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item B<< L<RDF::DOAP::Version> >> |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Correponds to I<< doap:Version >>. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item B<< L<RDF::DOAP::ChangeSet> >> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Correponds to I<< dcs:ChangeSet >>. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item B<< L<RDF::DOAP::Change> >> |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Correponds to I<< dcs:Change >>. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item B<< L<RDF::DOAP::Issue> >> |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Correponds to I<< dbug:Issue >>. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=back |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 BUGS |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Please report any bugs to |
231
|
|
|
|
|
|
|
L<https://github.com/kjetilk/p5-rdf-doap/issues>. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 SEE ALSO |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=over |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Edd Dumbill's series of articles on DOAP's design: |
240
|
|
|
|
|
|
|
L<part 1|http://www.ibm.com/developerworks/xml/library/x-osproj/>, |
241
|
|
|
|
|
|
|
L<part 2|http://www.ibm.com/developerworks/xml/library/x-osproj2/>, |
242
|
|
|
|
|
|
|
L<part 3|http://www.ibm.com/developerworks/xml/library/x-osproj4/> and |
243
|
|
|
|
|
|
|
L<part 4|http://www.ibm.com/developerworks/xml/library/x-osproj3/> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item * |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
L<The DOAP Schema|http://usefulinc.com/ns/doap#>. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item * |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
L<The DOAP Change Sets Schema|http://ontologi.es/doap-changeset#>. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item * |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
L<The DOAP Bugs Schema|http://ontologi.es/doap-bugs#>. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=back |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 AUTHOR |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
262
|
|
|
|
|
|
|
Kjetil Kjernsmo E<lt>kjetilk@cpan.orgE<gt>. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Toby Inkster, 2017 by Kjetil Kjernsmo. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
269
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
274
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
275
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
276
|
|
|
|
|
|
|
|