| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | =head1 NAME | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | AtteanX::Serializer::SPARQLTSV - SPARQL Results TSV Serializer | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =head1 VERSION | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | This document describes AtteanX::Serializer::SPARQLTSV version 0.033 | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | use Attean; | 
| 12 |  |  |  |  |  |  | my $s = Attean->get_serializer('SPARQLTSV')->new(); | 
| 13 |  |  |  |  |  |  | $s->serialize_iter_to_io( $fh, $iter ); | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | ... | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | =over 4 | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =item C<< canonical_media_type >> | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =item C<< file_extensions >> | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =back | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =head1 METHODS | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =over 4 | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =cut | 
| 34 |  |  |  |  |  |  |  | 
| 35 | 3 |  |  | 3 |  | 8136 | use v5.14; | 
|  | 3 |  |  |  |  | 15 |  | 
| 36 | 3 |  |  | 3 |  | 18 | use warnings; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 135 |  | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | use Moo; | 
| 39 | 3 |  |  | 3 |  | 16 | use Types::Standard qw(Str ArrayRef); | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 20 |  | 
| 40 | 3 |  |  | 3 |  | 1038 | use Encode qw(encode); | 
|  | 3 |  |  |  |  | 10 |  | 
|  | 3 |  |  |  |  | 41 |  | 
| 41 | 3 |  |  | 3 |  | 2003 | use Scalar::Util qw(blessed); | 
|  | 3 |  |  |  |  | 16 |  | 
|  | 3 |  |  |  |  | 143 |  | 
| 42 | 3 |  |  | 3 |  | 22 | use Attean::ListIterator; | 
|  | 3 |  |  |  |  | 14 |  | 
|  | 3 |  |  |  |  | 128 |  | 
| 43 | 3 |  |  | 3 |  | 23 | use List::MoreUtils qw(any); | 
|  | 3 |  |  |  |  | 9 |  | 
|  | 3 |  |  |  |  | 90 |  | 
| 44 | 3 |  |  | 3 |  | 21 | use namespace::clean; | 
|  | 3 |  |  |  |  | 36 |  | 
|  | 3 |  |  |  |  | 27 |  | 
| 45 | 3 |  |  | 3 |  | 2860 |  | 
|  | 3 |  |  |  |  | 10 |  | 
|  | 3 |  |  |  |  | 26 |  | 
| 46 |  |  |  |  |  |  | has 'canonical_media_type' => (is => 'ro', isa => Str, init_arg => undef, default => 'text/tab-separated-values'); | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | =item C<< media_types >> | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | Returns a list of media types that identify the format produced by this serializer. | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | =cut | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | return [qw(text/tab-separated-values)]; | 
| 55 |  |  |  |  |  |  | } | 
| 56 | 9 |  |  | 9 | 1 | 30 |  | 
| 57 |  |  |  |  |  |  | =item C<< file_extensions >> | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | Returns a list of file extensions associated with the serialized format. | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =cut | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =item C<< serialize_iter_to_io( $fh, $iterator ) >> | 
| 65 | 6 |  |  | 6 | 1 | 21 |  | 
| 66 |  |  |  |  |  |  | Serializes the L<Attean::API::Binding> objects from C<< $iterator >> to the | 
| 67 |  |  |  |  |  |  | L<IO::Handle> object C<< $fh >>. | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =cut | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | my $self	= shift; | 
| 72 |  |  |  |  |  |  | my $io		= shift; | 
| 73 |  |  |  |  |  |  | my $iter	= shift; | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | my @vars	= @{ $iter->variables }; | 
| 76 |  |  |  |  |  |  | $io->print(join("\t", map { "?$_" } @vars) . "\n"); | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | while (my $t = $iter->next()) { | 
| 79 |  |  |  |  |  |  | my @strings	= map { blessed($_) ? $_->ntriples_string : '' } map { $t->value($_) } @vars; | 
| 80 |  |  |  |  |  |  | $io->print(join("\t", @strings) . "\n"); | 
| 81 |  |  |  |  |  |  | } | 
| 82 |  |  |  |  |  |  | return; | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =item C<< serialize_iter_to_bytes( $iterator ) >> | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | Serializes the L<Attean::API::Binding> objects from C<< $iterator >> | 
| 88 |  |  |  |  |  |  | and returns the serialization as a UTF-8 encoded byte string. | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =cut | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | my $self	= shift; | 
| 93 |  |  |  |  |  |  | my $iter	= shift; | 
| 94 |  |  |  |  |  |  | my $data	= ''; | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | my @vars	= @{ $iter->variables }; | 
| 97 |  |  |  |  |  |  | $data		.= join("\t", map { "?$_" } @vars) . "\n"; | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | while (my $t = $iter->next()) { | 
| 100 |  |  |  |  |  |  | my @strings	= map { blessed($_) ? $_->ntriples_string : '' } map { $t->value($_) } @vars; | 
| 101 |  |  |  |  |  |  | my $str		= join("\t", @strings); | 
| 102 |  |  |  |  |  |  | $data		.= $str . "\n"; | 
| 103 |  |  |  |  |  |  | } | 
| 104 |  |  |  |  |  |  | return encode('UTF-8', $data); | 
| 105 |  |  |  |  |  |  | } | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | with 'Attean::API::ResultSerializer', 'Attean::API::AppendableSerializer'; | 
| 108 |  |  |  |  |  |  | } | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | 1; | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =back | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | =head1 BUGS | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | Please report any bugs or feature requests to through the GitHub web interface | 
| 118 |  |  |  |  |  |  | at L<https://github.com/kasei/perlrdf/issues>. | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =head1 AUTHOR | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | Gregory Todd Williams  C<< <gwilliams@cpan.org> >> | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | Copyright (c) 2014--2022 Gregory Todd Williams. This | 
| 127 |  |  |  |  |  |  | program is free software; you can redistribute it and/or modify it under | 
| 128 |  |  |  |  |  |  | the same terms as Perl itself. | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | =cut |