| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Module::Install::Admin::RDF; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3661
|
use 5.008; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw(Module::Install::Base); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
83
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
18336
|
use Object::ID; |
|
|
1
|
|
|
|
|
18896
|
|
|
|
1
|
|
|
|
|
9
|
|
|
8
|
1
|
|
|
1
|
|
726
|
use RDF::Trine qw[]; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use URI::file qw[]; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.009'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $Model = {}; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub rdf_metadata |
|
16
|
|
|
|
|
|
|
{ |
|
17
|
|
|
|
|
|
|
my ($self) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $addr = object_id($self->_top); |
|
20
|
|
|
|
|
|
|
return $Model->{$addr} if defined $Model->{$addr}; |
|
21
|
|
|
|
|
|
|
my $model = $Model->{$addr} = RDF::Trine::Model->new; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $parser; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
while (<meta/*.{ttl,turtle,nt}>) |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
|
|
|
|
|
|
my $iri = URI::file->new_abs($_); |
|
28
|
|
|
|
|
|
|
$parser ||= RDF::Trine::Parser->new('Turtle'); |
|
29
|
|
|
|
|
|
|
$parser->parse_file_into_model("$iri", $_, $model); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$parser = undef; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
while (<meta/*.{rdf,rdfxml,rdfx}>) |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
|
|
|
|
|
|
my $iri = URI::file->new_abs($_); |
|
37
|
|
|
|
|
|
|
$parser ||= RDF::Trine::Parser->new('RDFXML'); |
|
38
|
|
|
|
|
|
|
$parser->parse_file_into_model("$iri", $_, $model); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$parser = undef; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
while (<meta/*.{pret,pretdsl}>) |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
|
|
|
|
|
|
my $iri = URI::file->new_abs($_); |
|
46
|
|
|
|
|
|
|
require RDF::TrineX::Parser::Pretdsl; |
|
47
|
|
|
|
|
|
|
$parser ||= RDF::TrineX::Parser::Pretdsl->new; |
|
48
|
|
|
|
|
|
|
$parser->parse_file_into_model("$iri", $_, $model); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $model; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub rdf_project_uri |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
|
|
|
|
|
|
my ($self) = @_; |
|
57
|
|
|
|
|
|
|
my $model = $self->rdf_metadata; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my @candidates = $model->subjects( |
|
60
|
|
|
|
|
|
|
RDF::Trine::iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), |
|
61
|
|
|
|
|
|
|
RDF::Trine::iri('http://usefulinc.com/ns/doap#Project'), |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
return $candidates[0] if scalar @candidates == 1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my %counts = map { |
|
66
|
|
|
|
|
|
|
$_ => $model->count_statements($_, undef, undef); |
|
67
|
|
|
|
|
|
|
} @candidates; |
|
68
|
|
|
|
|
|
|
my @best = sort { $counts{$b} <=> $counts{$a} } @candidates; |
|
69
|
|
|
|
|
|
|
return $best[0] if @best; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return undef; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub write_meta_ttl |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
|
|
|
|
|
|
no warnings; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my ($self, $file) = @_; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my %NS = qw( |
|
81
|
|
|
|
|
|
|
rdf http://www.w3.org/1999/02/22-rdf-syntax-ns# |
|
82
|
|
|
|
|
|
|
rdfs http://www.w3.org/2000/01/rdf-schema# |
|
83
|
|
|
|
|
|
|
foaf http://xmlns.com/foaf/0.1/ |
|
84
|
|
|
|
|
|
|
doap http://usefulinc.com/ns/doap# |
|
85
|
|
|
|
|
|
|
cpan http://purl.org/NET/cpan-uri/person/ |
|
86
|
|
|
|
|
|
|
dcs http://ontologi.es/doap-changeset# |
|
87
|
|
|
|
|
|
|
bugs http://ontologi.es/doap-bugs# |
|
88
|
|
|
|
|
|
|
deps http://ontologi.es/doap-deps# |
|
89
|
|
|
|
|
|
|
cpant http://purl.org/NET/cpan-uri/terms# |
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $prj = $self->rdf_project_uri; |
|
93
|
|
|
|
|
|
|
$NS{dist} = $1 if defined $prj && $prj->uri =~ m{^(http://purl\.org/NET/cpan-uri/dist/.+/)project}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $ser = eval { |
|
96
|
|
|
|
|
|
|
require RDF::TrineX::Serializer::MockTurtleSoup; |
|
97
|
|
|
|
|
|
|
"RDF::TrineX::Serializer::MockTurtleSoup"->new( |
|
98
|
|
|
|
|
|
|
abbreviate => qr{/NET/cpan-uri/}, |
|
99
|
|
|
|
|
|
|
colspace => 17, |
|
100
|
|
|
|
|
|
|
indent => "\t", |
|
101
|
|
|
|
|
|
|
labelling => [ |
|
102
|
|
|
|
|
|
|
"$NS{rdfs}label", |
|
103
|
|
|
|
|
|
|
"$NS{foaf}name", |
|
104
|
|
|
|
|
|
|
"$NS{doap}name", |
|
105
|
|
|
|
|
|
|
], |
|
106
|
|
|
|
|
|
|
namespaces => \%NS, |
|
107
|
|
|
|
|
|
|
priorities => sub { |
|
108
|
|
|
|
|
|
|
my ($ser, $n, $m) = @_; |
|
109
|
|
|
|
|
|
|
return 100 if $m->count_statements( |
|
110
|
|
|
|
|
|
|
$n, |
|
111
|
|
|
|
|
|
|
RDF::Trine::iri("$NS{rdf}type"), |
|
112
|
|
|
|
|
|
|
RDF::Trine::iri("$NS{doap}Project"), |
|
113
|
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
return 80 if $m->count_statements( |
|
115
|
|
|
|
|
|
|
$n, |
|
116
|
|
|
|
|
|
|
RDF::Trine::iri("$NS{rdf}type"), |
|
117
|
|
|
|
|
|
|
RDF::Trine::iri("$NS{doap}Version"), |
|
118
|
|
|
|
|
|
|
); |
|
119
|
|
|
|
|
|
|
return 60 if $m->count_statements( |
|
120
|
|
|
|
|
|
|
$n, |
|
121
|
|
|
|
|
|
|
RDF::Trine::iri("$NS{rdf}type"), |
|
122
|
|
|
|
|
|
|
RDF::Trine::iri("$NS{foaf}Person"), |
|
123
|
|
|
|
|
|
|
); |
|
124
|
|
|
|
|
|
|
return 40 if $m->count_statements( |
|
125
|
|
|
|
|
|
|
$n, |
|
126
|
|
|
|
|
|
|
RDF::Trine::iri("$NS{foaf}name"), |
|
127
|
|
|
|
|
|
|
undef, |
|
128
|
|
|
|
|
|
|
); |
|
129
|
|
|
|
|
|
|
return 0; |
|
130
|
|
|
|
|
|
|
}, |
|
131
|
|
|
|
|
|
|
repeats => 1, |
|
132
|
|
|
|
|
|
|
); |
|
133
|
|
|
|
|
|
|
} || do { |
|
134
|
|
|
|
|
|
|
"RDF::Trine::Serializer::Turtle"->new( |
|
135
|
|
|
|
|
|
|
namespaces => \%NS, |
|
136
|
|
|
|
|
|
|
); |
|
137
|
|
|
|
|
|
|
}; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
open my $out, ">", $file or die "Could not open '$file': $!"; |
|
140
|
|
|
|
|
|
|
$ser->serialize_model_to_file($out, $self->rdf_metadata); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |
|
146
|
|
|
|
|
|
|
=head1 NAME |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Module::Install::Admin::RDF - internals for Module::Install::RDF |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Code that only runs on the module author's machine. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 BUGS |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Please report any bugs to L<http://rt.cpan.org/>. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L<Module::Install::RDF>. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Copyright (C) 2011-2013 by Toby Inkster |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
|
171
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
|
176
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
|
177
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |