blib/lib/WQS/SPARQL/Result.pm

filter: Statementstmt 93.1% 41 / 44 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 87.3% 55 / 63 SCAR 21.1
CC
8
Cov
85%
result
9.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.2
↑ Summary
1 package WQS::SPARQL::Result;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = 0.02;
11  
12 sub new {
13 3 ▶ my ($class, @params) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
14  
15 # Create object.
16 3 my $self = bless {}, $class;
17  
18 # Verbose mode.
19 3 $self->{'verbose'} = 0;
20  
21 # Process parameters.
22 3 set_params($self, @params);
23  
24 3 return $self;
25 }
26  
27 sub result {
28 2 ▶ my ($self, $result_hr, $vars_ar) = @_;
Subroutine result: called CC=8 SCAR=22.0
Pod documented
29  
30 2 ▶ if (! defined $vars_ar) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $vars_ar) 2 0 2
31 2 $vars_ar = $result_hr->{'head'}->{'vars'};
32 }
33  
34 2 ▶ if ($self->{'verbose'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verbose"}) 0 2 2
35 0 require Data::Printer;
36 0 Data::Printer::p($result_hr);
37 }
38  
39 2 my @res;
40 2 ▶ if (exists $result_hr->{'results'}->{'bindings'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result_hr->{"results"}{"bindings"}) 2 0 2
41 2 my @items = @{$result_hr->{'results'}->{'bindings'}};
42 2 foreach my $item_hr (@items) {
43 2 my $result_hr;
44 2 foreach my $var (@{$vars_ar}) {
45 2 ▶ if (! exists $item_hr->{$var}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $item_hr->{$var}) 0 2 2
46 0 next;
47 }
48  
49 # TODO Implement other values
50  
51 # QID.
52 # TODO Check real QID, could be another uri.
53 2 ▶ if ($item_hr->{$var}->{'type'} eq 'uri') {
Branch: 1 branch
BranchTrueFalseTotal
if ($item_hr->{$var}{"type"} eq "uri") 2 0 2
54 2 my $qid_uri = URI->new($item_hr->{$var}->{'value'});
55 2 my @segs = $qid_uri->path_segments;
56 2 $result_hr->{$var} = $segs[-1];
57 }
58 }
59 2 push @res, $result_hr;
60 }
61 }
62  
63 2 return @res;
64 }
65  
66 4 1;
67  
68 __END__
↑ Summary