line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::QueryX::Lazy; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
44672
|
use 5.010; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
66
|
|
4
|
2
|
|
|
2
|
|
1643
|
use common::sense; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
10
|
|
5
|
2
|
|
|
2
|
|
99
|
use constant { FALSE => 0, TRUE => 1 }; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
159
|
|
6
|
2
|
|
|
2
|
|
2068
|
use utf8; |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
9
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our (%Lazy); |
9
|
|
|
|
|
|
|
BEGIN { |
10
|
2
|
|
|
2
|
|
318
|
$RDF::QueryX::Lazy::AUTHORITY = 'cpan:TOBYINK'; |
11
|
2
|
|
|
|
|
3
|
$RDF::QueryX::Lazy::VERSION = '0.002'; |
12
|
|
|
|
|
|
|
|
13
|
56
|
50
|
|
|
|
321
|
%Lazy = |
14
|
2
|
|
|
|
|
80
|
map { /^PREFIX (.+?):/ ? ($1 => $_) : () } |
15
|
|
|
|
|
|
|
split /\r?\n/, <<'LAZY'; |
16
|
|
|
|
|
|
|
PREFIX bibo: <http://purl.org/ontology/bibo/> |
17
|
|
|
|
|
|
|
PREFIX bio: <http://purl.org/vocab/bio/0.1/> |
18
|
|
|
|
|
|
|
PREFIX cc: <http://creativecommons.org/ns#> |
19
|
|
|
|
|
|
|
PREFIX dc: <http://purl.org/dc/elements/1.1/> |
20
|
|
|
|
|
|
|
PREFIX doap: <http://usefulinc.com/ns/doap#> |
21
|
|
|
|
|
|
|
PREFIX foaf: <http://xmlns.com/foaf/0.1/> |
22
|
|
|
|
|
|
|
PREFIX frbr: <http://purl.org/vocab/frbr/core#> |
23
|
|
|
|
|
|
|
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> |
24
|
|
|
|
|
|
|
PREFIX gr: <http://purl.org/goodrelations/v1#> |
25
|
|
|
|
|
|
|
PREFIX ical: <http://www.w3.org/2002/12/cal/ical#> |
26
|
|
|
|
|
|
|
PREFIX og: <http://ogp.me/ns#> |
27
|
|
|
|
|
|
|
PREFIX org: <http://www.w3.org/ns/org#> |
28
|
|
|
|
|
|
|
PREFIX owl: <http://www.w3.org/2002/07/owl#> |
29
|
|
|
|
|
|
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
30
|
|
|
|
|
|
|
PREFIX rdfa: <http://www.w3.org/ns/rdfa#> |
31
|
|
|
|
|
|
|
PREFIX rdfg: <http://www.w3.org/2004/03/trix/rdfg-1/> |
32
|
|
|
|
|
|
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> |
33
|
|
|
|
|
|
|
PREFIX rev: <http://purl.org/stuff/rev#> |
34
|
|
|
|
|
|
|
PREFIX rss: <http://purl.org/rss/1.0/> |
35
|
|
|
|
|
|
|
PREFIX sioc: <http://rdfs.org/sioc/ns#> |
36
|
|
|
|
|
|
|
PREFIX skos: <http://www.w3.org/2004/02/skos/core#> |
37
|
|
|
|
|
|
|
PREFIX vann: <http://purl.org/vocab/vann/> |
38
|
|
|
|
|
|
|
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> |
39
|
|
|
|
|
|
|
PREFIX void: <http://rdfs.org/ns/void#> |
40
|
|
|
|
|
|
|
PREFIX wdrs: <http://www.w3.org/2007/05/powder-s#> |
41
|
|
|
|
|
|
|
PREFIX wot: <http://xmlns.com/wot/0.1/> |
42
|
|
|
|
|
|
|
PREFIX xhv: <http://www.w3.org/1999/xhtml/vocab#> |
43
|
|
|
|
|
|
|
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> |
44
|
|
|
|
|
|
|
LAZY |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
2
|
|
12
|
use Scalar::Util 0 qw[blessed refaddr]; |
|
2
|
|
|
|
|
49
|
|
|
2
|
|
|
|
|
272
|
|
48
|
2
|
|
|
2
|
|
2206
|
use RDF::Query 2.900; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use parent qw[RDF::Query]; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new |
53
|
|
|
|
|
|
|
{ |
54
|
|
|
|
|
|
|
my ($class, $query, @params) = @_; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $lazy = ''; |
57
|
|
|
|
|
|
|
$lazy .= join "\n", |
58
|
|
|
|
|
|
|
map { $Lazy{$_} } |
59
|
|
|
|
|
|
|
grep { $query =~ /$_:/ } |
60
|
|
|
|
|
|
|
keys %Lazy; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
if (exists $params[0] |
63
|
|
|
|
|
|
|
and ref $params[0] eq 'HASH' |
64
|
|
|
|
|
|
|
and ref $params[0]{lazy} eq 'HASH') |
65
|
|
|
|
|
|
|
{ |
66
|
|
|
|
|
|
|
my %more = %{ delete($params[0]{lazy}) // {} }; |
67
|
|
|
|
|
|
|
$lazy .= join "\n", |
68
|
|
|
|
|
|
|
map { sprintf('PREFIX %s: <%s>', $_, $more{$_}) } |
69
|
|
|
|
|
|
|
grep { $query =~ /$_:/ } |
70
|
|
|
|
|
|
|
keys %more; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return $class->SUPER::new($lazy.$query, @params); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
TRUE; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
RDF::QueryX::Lazy - yeah, all those PREFIX definitions get boring |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SYNOPSIS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $query = RDF::QueryX::Lazy->new(<<SPARQL); |
87
|
|
|
|
|
|
|
SELECT * |
88
|
|
|
|
|
|
|
WHERE { |
89
|
|
|
|
|
|
|
?person foaf:name ?name . |
90
|
|
|
|
|
|
|
OPTIONAL { ?person foaf:homepage ?page . } |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
SPARQL |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This is a fairly trivial subclass of L<RDF::Query> that auto-defines |
97
|
|
|
|
|
|
|
many prefixes for you, so you can be lazy. It should have most of the |
98
|
|
|
|
|
|
|
common ones in there. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Oh yeah, and if you want, you can pass a key 'lazy' in the RDF::Query |
101
|
|
|
|
|
|
|
C<< %options >> hash with additional prefix mappings. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 BUGS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Please report any bugs to |
106
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=RDF-QueryX-Lazy>. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SEE ALSO |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L<RDF::Query>. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Toby Inkster. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
121
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
126
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
127
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
128
|
|
|
|
|
|
|
|