| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | AtteanX::Serializer::NTuples - Shared functionality for N-Triples and N-Quads serializers | ||||||||||
| 4 | |||||||||||
| 5 | =head1 VERSION | ||||||||||
| 6 | |||||||||||
| 7 | This document describes AtteanX::Serializer::NTuples version 0.040 | ||||||||||
| 8 | |||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||
| 10 | |||||||||||
| 11 | use Attean; | ||||||||||
| 12 | my $serializer = Attean->get_serializer('NTriples')->new(); | ||||||||||
| 13 | $serializer->serialize_iter_to_io( $io, $fh ); | ||||||||||
| 14 | |||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||
| 16 | |||||||||||
| 17 | ... | ||||||||||
| 18 | |||||||||||
| 19 | =head1 METHODS | ||||||||||
| 20 | |||||||||||
| 21 | =over 4 | ||||||||||
| 22 | |||||||||||
| 23 | =cut | ||||||||||
| 24 | |||||||||||
| 25 | 7 | ▶ | use v5.14; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 7 | package AtteanX::Serializer::NTuples 0.040 { | |||||||||
| 29 | 7 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 7 | ▶ | use Encode qw(encode); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 7 | ▶ | use Attean::ListIterator; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 7 | ▶ | use List::Util qw(any); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | 7 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | |||||||||||
| 35 | =item C<< serialize_iter_to_io( $fh, $iterator ) >> | ||||||||||
| 36 | |||||||||||
| 37 | Serializes the L<Attean::API::Binding> objects from C<< $iterator >> to the | ||||||||||
| 38 | L<IO::Handle> object C<< $fh >>. | ||||||||||
| 39 | |||||||||||
| 40 | =cut | ||||||||||
| 41 | |||||||||||
| 42 | 4 | ▶ | sub serialize_iter_to_io { | ||||||||
|
Subroutine
serialize_iter_to_io: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 43 | 4 | my $self = shift; | |||||||||
| 44 | 4 | my $io = shift; | |||||||||
| 45 | 4 | my $iter = shift; | |||||||||
| 46 | 4 | ▶ | while (my $t = $iter->next()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 8 | my $str = $t->tuples_string . "\n"; | |||||||||
| 48 | 8 | $io->print($str); | |||||||||
| 49 | } | ||||||||||
| 50 | 4 | return; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | =item C<< serialize_iter_to_bytes( $iterator ) >> | ||||||||||
| 54 | |||||||||||
| 55 | Serializes the L<Attean::API::Binding> objects from C<< $iterator >> | ||||||||||
| 56 | and returns the serialization as a UTF-8 encoded byte string. | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||
| 59 | |||||||||||
| 60 | 4 | ▶ | sub serialize_iter_to_bytes { | ||||||||
|
Subroutine
serialize_iter_to_bytes: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | 4 | my $self = shift; | |||||||||
| 62 | 4 | my $iter = shift; | |||||||||
| 63 | 4 | my $data = ''; | |||||||||
| 64 | 4 | ▶ | while (my $t = $iter->next()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 8 | my $str = $t->tuples_string; | |||||||||
| 66 | 8 | $data .= $str . "\n"; | |||||||||
| 67 | } | ||||||||||
| 68 | 4 | return encode('UTF-8', $data); | |||||||||
| 69 | } | ||||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 7 | 1; | |||||||||
| 73 | |||||||||||
| 74 | __END__ | ||||||||||