AtteanX/Serializer/NTuples.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 51 / 51 CC 3 SCAR 3.1
CC
3
Cov
100%
serialize_iter_to_io
2.0
serialize_iter_to_bytes
2.0
BEGIN
1.0
CRAP 1.4
« AtteanX/SPARQL/Constants.pm ↑ Summary Attean/Triple.pm »
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
BranchTrueFalseTotal
if (my $t = $iter->next) 8 4 12
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
BranchTrueFalseTotal
if (my $t = $iter->next) 8 4 12
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__
« AtteanX/SPARQL/Constants.pm ↑ Summary Attean/Triple.pm »