| line | stmt | bran | cond | sub | pod | time | code | 
| 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.033 | 
| 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 |  |  | 7 |  | 3989 | use v5.14; | 
|  | 7 |  |  |  |  | 26 |  | 
| 26 | 7 |  |  | 7 |  | 47 | use warnings; | 
|  | 7 |  |  |  |  | 16 |  | 
|  | 7 |  |  |  |  | 287 |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | use Moo; | 
| 29 | 7 |  |  | 7 |  | 38 | use Encode qw(encode); | 
|  | 7 |  |  |  |  | 14 |  | 
|  | 7 |  |  |  |  | 43 |  | 
| 30 | 7 |  |  | 7 |  | 2391 | use Attean::ListIterator; | 
|  | 7 |  |  |  |  | 16 |  | 
|  | 7 |  |  |  |  | 347 |  | 
| 31 | 7 |  |  | 7 |  | 45 | use List::MoreUtils qw(any); | 
|  | 7 |  |  |  |  | 16 |  | 
|  | 7 |  |  |  |  | 191 |  | 
| 32 | 7 |  |  | 7 |  | 37 | use namespace::clean; | 
|  | 7 |  |  |  |  | 16 |  | 
|  | 7 |  |  |  |  | 69 |  | 
| 33 | 7 |  |  | 7 |  | 4155 |  | 
|  | 7 |  |  |  |  | 15 |  | 
|  | 7 |  |  |  |  | 56 |  | 
| 34 |  |  |  |  |  |  | =item C<< serialize_iter_to_io( $fh, $iterator ) >> | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | Serializes the L<Attean::API::Binding> objects from C<< $iterator >> to the | 
| 37 |  |  |  |  |  |  | L<IO::Handle> object C<< $fh >>. | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =cut | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | my $self	= shift; | 
| 42 |  |  |  |  |  |  | my $io		= shift; | 
| 43 | 4 |  |  | 4 | 1 | 21 | my $iter	= shift; | 
| 44 | 4 |  |  |  |  | 6 | while (my $t = $iter->next()) { | 
| 45 | 4 |  |  |  |  | 6 | my $str = $t->tuples_string . "\n"; | 
| 46 | 4 |  |  |  |  | 12 | $io->print($str); | 
| 47 | 8 |  |  |  |  | 21 | } | 
| 48 | 8 |  |  |  |  | 34 | return; | 
| 49 |  |  |  |  |  |  | } | 
| 50 | 4 |  |  |  |  | 14 |  | 
| 51 |  |  |  |  |  |  | =item C<< serialize_iter_to_bytes( $iterator ) >> | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | Serializes the L<Attean::API::Binding> objects from C<< $iterator >> | 
| 54 |  |  |  |  |  |  | and returns the serialization as a UTF-8 encoded byte string. | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | =cut | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | my $self	= shift; | 
| 59 |  |  |  |  |  |  | my $iter	= shift; | 
| 60 |  |  |  |  |  |  | my $data	= ''; | 
| 61 | 4 |  |  | 4 | 1 | 21 | while (my $t = $iter->next()) { | 
| 62 | 4 |  |  |  |  | 5 | my $str = $t->tuples_string; | 
| 63 | 4 |  |  |  |  | 8 | $data	.= $str . "\n"; | 
| 64 | 4 |  |  |  |  | 16 | } | 
| 65 | 8 |  |  |  |  | 34 | return encode('UTF-8', $data); | 
| 66 | 8 |  |  |  |  | 32 | } | 
| 67 |  |  |  |  |  |  | } | 
| 68 | 4 |  |  |  |  | 27 |  | 
| 69 |  |  |  |  |  |  | 1; | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =back | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =head1 BUGS | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | Please report any bugs or feature requests to through the GitHub web interface | 
| 77 |  |  |  |  |  |  | at L<https://github.com/kasei/perlrdf/issues>. | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head1 AUTHOR | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | Gregory Todd Williams  C<< <gwilliams@cpan.org> >> | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | Copyright (c) 2014--2022 Gregory Todd Williams. This | 
| 86 |  |  |  |  |  |  | program is free software; you can redistribute it and/or modify it under | 
| 87 |  |  |  |  |  |  | the same terms as Perl itself. | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =cut |