File: RDQL.pm

package info (click to toggle)
libapp-perlrdf-command-query-perl 0.004-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 172 kB
  • sloc: perl: 433; makefile: 2; sh: 1
file content (55 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package App::perlrdf::Command::RDQL;

use 5.010;
use strict;
use warnings;
use utf8;

BEGIN {
	$App::perlrdf::Command::RDQL::AUTHORITY = 'cpan:TOBYINK';
	$App::perlrdf::Command::RDQL::VERSION   = '0.004';
}

use base 'App::perlrdf::Command::Query';
use namespace::clean;

use constant abstract      => q (query stores, files or remote endpoints with RDQL);
use constant command_names => qw( rdql );
use constant description   => <<'DESCRIPTION';
Use RDQL to query:

	* an RDF::Trine::Store;
	* a remote SPARQL Protocol (1.0/1.1) endpoint; or
	* one or more input files;

But not a combination of the above.
DESCRIPTION

sub opt_spec
{
	map {
		$_->[0] =~ s/sparql/rdql/ if @$_;
		$_;
	} shift->SUPER::opt_spec
}

sub validate_args
{
	my ($self, $opt, $arg) = @_;
	$self->usage_error("Must not provide both 'rdql_file' and 'execute' options.")
		if exists $opt->{rdql_file} && exists $opt->{execute};
	$self->SUPER::validate_args($opt, $arg);
}

sub _sparql
{
	require RDF::Query;
	my ($self, $opt, $arg) = @_;
	my $rdql  = $self->SUPER::_sparql($opt, $arg);
	my $query = RDF::Query::->new($rdql, { lang => 'rdql' })
		or die RDF::Query->error;
	return $query->as_sparql;
}

1;