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.916.
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   204 use strict;
  35         80  
  35         1006  
28 35     35   191 use warnings;
  35         77  
  35         1072  
29 35     35   250 no warnings 'redefine';
  35         80  
  35         1658  
30              
31             our $BLOOM_FILTER_LOADED;
32              
33 35     35   200 use Scalar::Util qw(refaddr);
  35         88  
  35         2127  
34 35     35   201 use Log::Log4perl;
  35         74  
  35         316  
35              
36             use Module::Pluggable
37 35         300 search_path => [ __PACKAGE__ ],
38             require => 1,
39             inner => 1,
40             sub_name => 'function_sets',
41 35     35   29971 ;
  35         328527  
42              
43             ######################################################################
44              
45             our ($VERSION, $l);
46             BEGIN {
47 35     35   4678 $l = Log::Log4perl->get_logger("rdf.query.functions");
48 35         19955 $VERSION = '2.916';
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 4880 my $class = shift;
63 3220         7278 while (@_) {
64 3220         4074 my $uris = shift;
65 3220         3961 my $func = shift;
66 3220 100       12183 $RDF::Query::preferred_function_name{ refaddr($func) } = ref($uris) ? $uris->[0] : $uris;
67 3220 100       6539 foreach my $uri (ref($uris) ? @$uris : $uris) {
68 3535         16603 $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