File Coverage

blib/lib/RDF/Query/Functions.pm
Criterion Covered Total %
statement 27 27 100.0
branch 4 4 100.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 40 40 100.0


line stmt bran cond sub pod time code
1             # RDF::Query::Functions
2             # -----------------------------------------------------------------------------
3              
4             =head1 NAME
5              
6             RDF::Query::Functions - Standard Extension Functions
7              
8             =head1 VERSION
9              
10             This document describes RDF::Query::Functions version 2.918.
11              
12             =head1 DESCRIPTION
13              
14             This stub module simply loads all other modules named
15             C<< RDF::Query::Functions::* >>. Each of those modules
16             has an C<install> method that simply adds coderefs
17             to C<< %RDF::Query::functions >>.
18              
19             =head1 METHODS
20              
21             =over 4
22              
23             =cut
24              
25             package RDF::Query::Functions;
26              
27 35     35   153 use strict;
  35         54  
  35         951  
28 35     35   124 use warnings;
  35         49  
  35         858  
29 35     35   114 no warnings 'redefine';
  35         51  
  35         1330  
30              
31             our $BLOOM_FILTER_LOADED;
32              
33 35     35   129 use Scalar::Util qw(refaddr);
  35         47  
  35         1737  
34 35     35   147 use Log::Log4perl;
  35         42  
  35         240  
35              
36             use Module::Pluggable
37 35         250 search_path => [ __PACKAGE__ ],
38             require => 1,
39             inner => 1,
40             sub_name => 'function_sets',
41 35     35   16486 ;
  35         213875  
42              
43             ######################################################################
44              
45             our ($VERSION, $l);
46             BEGIN {
47 35     35   3745 $l = Log::Log4perl->get_logger("rdf.query.functions");
48 35         14687 $VERSION = '2.918';
49             }
50              
51             ######################################################################
52              
53             =item C<< install_function ( $uri, \&func ) >>
54              
55             =item C<< install_function ( \@uris, \&func ) >>
56              
57             Install the supplied CODE reference as the implementation for the given function URI(s).
58              
59             =cut
60              
61             sub install_function {
62 3220     3220 1 2465 my $class = shift;
63 3220         4075 while (@_) {
64 3220         2179 my $uris = shift;
65 3220         1946 my $func = shift;
66 3220 100       7020 $RDF::Query::preferred_function_name{ refaddr($func) } = ref($uris) ? $uris->[0] : $uris;
67 3220 100       3562 foreach my $uri (ref($uris) ? @$uris : $uris) {
68 3535         9189 $RDF::Query::functions{$uri} = $func;
69             }
70             }
71             }
72              
73             foreach my $function_set (__PACKAGE__->function_sets) {
74             $function_set->install;
75             }
76              
77             1;
78              
79             __END__
80              
81             =back
82              
83             =head1 SEE ALSO
84              
85             L<RDF::Query::Functions::SPARQL>,
86             L<RDF::Query::Functions::Xpath>,
87             L<RDF::Query::Functions::Jena>,
88             L<RDF::Query::Functions::Geo>,
89             L<RDF::Query::Functions::Kasei>.
90              
91             =head1 AUTHOR
92              
93             Gregory Williams <gwilliams@cpan.org>,
94             Toby Inkster <tobyink@cpan.org>.
95              
96             =cut