| 1 | package Catmandu::Exporter::RDF; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use Catmandu::Sane; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use RDF::Trine::Serializer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use RDF::Trine::Model; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use RDF::aREF; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 5 | our $VERSION = '0.32'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 5 | with 'Catmandu::RDF'; | |||||||||||||||||||||||||||
| 13 | 5 | with 'Catmandu::Exporter'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # internal attributes | ||||||||||||||||||||||||||||
| 16 | 5 | has decoder => ( | |||||||||||||||||||||||||||
| 17 | is => 'lazy' | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 5 | has serializer => ( | |||||||||||||||||||||||||||
| 21 | is => 'lazy' | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 5 | has model => ( | |||||||||||||||||||||||||||
| 25 | is => 'lazy' | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 13 | ▶ | sub _build_decoder { | ||||||||||||||||||||||||||
|
Subroutine
_build_decoder: called CC=3 SCAR=17.3
| |||||||||||||||||||||||||||||
| 29 | 13 | ▶ | RDF::aREF::Decoder->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0]->ns // ($_[0]->ns eq 0 ? {} : "RDF::NS"->new)
MC/DC0%0/2
$_[0]->ns // ($_[0]->ns eq 0 ? {} : "RDF::NS"->new)
$_[0]->ns
($_[0]->ns eq 0 ? {} : "RDF::NS"->new)
Truth table33%1/3
A // B
A= $_[0]->nsB= ($_[0]->ns eq 0 ? {} : "RDF::NS"->new)
| |||||||||||||||||||||||||||||
| 30 | ns => $_[0]->ns // ($_[0]->ns eq 0 ? { } : RDF::NS->new), | ||||||||||||||||||||||||||||
| 31 | callback => $_[0]->model | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 13 | ▶ | sub _build_serializer { | ||||||||||||||||||||||||||
|
Subroutine
_build_serializer: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 36 | 13 | ▶ | RDF::Trine::Serializer->new($_[0]->type // 'ntriples'); | ||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]->type // "ntriples"
MC/DC100%1/1
$_[0]->type // "ntriples"
$_[0]->type
Truth table100%2/2
A
A= $_[0]->type
| |||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 13 | ▶ | sub _build_model { | ||||||||||||||||||||||||||
|
Subroutine
_build_model: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 40 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # Streaming output when we have type => NTriples | ||||||||||||||||||||||||||||
| 43 | 13 | ▶ | if (lc($self->type // 'ntriples') eq 'ntriples') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->type // "ntriples"
MC/DC100%1/1
$self->type // "ntriples"
$self->type
Truth table100%2/2
A
A= $self->type
| |||||||||||||||||||||||||||||
| 44 | 12 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 45 | 12 | require RDF::Trine::Statement; | |||||||||||||||||||||||||||
| 46 | 12 | eval { | |||||||||||||||||||||||||||
| 47 | 12 | my $st = RDF::aREF::Decoder::trine_statement(@_); | |||||||||||||||||||||||||||
| 48 | 12 | $self->fh->print($self->serializer->statement_as_string($st)); | |||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||
| 50 | 12 | ▶ | $self->decoder->error($@) if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 3 | }; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||
| 54 | 10 | RDF::Trine::Model->new; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 21 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 21 | my ($self, $aref) = @_; | |||||||||||||||||||||||||||
| 60 | 21 | $self->decoder->decode($aref, keep_bnode_map => 1); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 13 | ▶ | sub commit { | ||||||||||||||||||||||||||
|
Subroutine
commit: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 13 | my ($self) = @_; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 13 | ▶ | if (ref $self->model eq 'RDF::Trine::Model') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 10 | $self->model->end_bulk_ops; | |||||||||||||||||||||||||||
| 68 | 10 | $self->decoder->clean_bnodes; | |||||||||||||||||||||||||||
| 69 | 10 | $self->serializer->serialize_model_to_file( $self->fh, $self->model ); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 5 | 1; | |||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||