Trine/Serializer/Notation3.pm

filter: Statementstmt 39.1% 18 / 46 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod n/a totaltotal 37.1% 23 / 62 CC 7 SCAR 22.0
CC
7
Cov
33%
_formula_as_string
20.0
_node_as_string
12.0
BEGIN
2.0
CRAP 9.0
« Trine/Parser/Notation3.pm ↑ Summary Trine/Node/Formula.pm »
1 package RDF::Trine::Serializer::Notation3;
2  
3 3 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use parent qw(RDF::Trine::Serializer::NTriples);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 ######################################################################
9  
10 3 our ($VERSION);
11 3 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
12 3 $VERSION = '0.206';
13 3 $RDF::Trine::Serializer::serializer_names{ 'notation3' } = __PACKAGE__;
14 3 $RDF::Trine::Serializer::serializer_names{ 'notation 3' } = __PACKAGE__;
15 3 foreach my $type (qw(text/n3)) {
16 3 $RDF::Trine::Serializer::media_types{ $type } = __PACKAGE__;
17 }
18 }
19  
20 ######################################################################
21  
22 # these are inherited from RDF::Trine::Serializer::NTriples.
23  
24 0 ▶sub _node_as_string {
Subroutine _node_as_string: not called CC=3 SCAR=24.8
25 0 my $self = shift;
26 0 my $node = shift;
27
28 0 ▶ return $self->_formula_as_string($node)
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("RDF::Trine::Node::Formula") 0 0 0
29 if $node->isa('RDF::Trine::Node::Formula');
30  
31 0 ▶ return $node->as_string
Branch: 1 branch
BranchTrueFalseTotal
if $node->is_variable 0 0 0
32 if $node->is_variable;
33
34 0 return $node->as_ntriples;
35 }
36  
37 0 ▶sub _statement_as_string {
Subroutine _statement_as_string: not called CC=1 SCAR=6.9
38 0 my $self = shift;
39 0 my $st = shift;
40 0 return join(' ', map { $self->_node_as_string($_) } @{[$st->nodes]}[0..2]) . " .\n";
41 }
42  
43 0 ▶sub _formula_as_string {
Subroutine _formula_as_string: not called CC=4 SCAR=30.0
44 0 my $self = shift;
45 0 my $node = shift;
46 0 my $rv = '';
47
48 0 ▶ if ($node->forAll) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->forAll) 0 0 0
49 0 $rv .= "\t";
50 0 $rv .= '@forAll ' . join ', ', map {$self->_node_as_string($_) } $node->forAll;
51 0 $rv .= " .\n";
52 }
53  
54 0 ▶ if ($node->forSome) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->forSome) 0 0 0
55 0 $rv .= "\t";
56 0 $rv .= '@forSome ' . join ', ', map {$self->_node_as_string($_) } $node->forSome;
57 0 $rv .= " .\n";
58 }
59  
60 0 foreach my $st ($node->pattern->triples) {
61 0 my $x = $self->_statement_as_string($st);
62 0 $x =~ s/^/\t/mg; # pretty
63 0 $rv .= $x;
64 }
65
66 0 return "{\n$rv}";
67 }
68  
69 3 1;
70  
71 __END__
« Trine/Parser/Notation3.pm ↑ Summary Trine/Node/Formula.pm »