AtteanX/Serializer/CanonicalNTriples.pm

filter: Statementstmt 100% 33 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 100% 42 / 42 CC 2 SCAR 2.2
CC
2
Cov
100%
serialize_iter_to_io
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« AtteanX/Parser/Turtle/Constants.pm ↑ Summary AtteanX/Parser/NTriples.pm »
1 =head1 NAME
2  
3 AtteanX::Serializer::CanonicalNTriples - Canonical N-Triples Serializer
4  
5 =head1 VERSION
6  
7 This document describes AtteanX::Serializer::CanonicalNTriples 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, $iter );
14  
15 =head1 DESCRIPTION
16  
17 ...
18  
19 =head1 METHODS
20  
21 =over 4
22  
23 =cut
24  
25 5 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 5 package AtteanX::Serializer::CanonicalNTriples 0.040 {
29 5 ▶ use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 5 ▶ use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 5 extends 'AtteanX::Serializer::NTriples';
32 5 ▶ use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
33
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 2 ▶ sub serialize_iter_to_io {
Subroutine serialize_iter_to_io: called CC=2 SCAR=6.9
Pod documented
42 2 my $self = shift;
43 2 my $io = shift;
44 2 my $iter = shift;
45 2 $iter = $iter->materialize;
46 2 my $triples = $iter->canonical_set();
47
48 2 foreach my $t (@$triples) {
49 6 my $str = $t->tuples_string;
50 6 $io->print($str . "\n");
51 }
52 2 return;
53 }
54
55 =item C<< serialize_iter_to_bytes( $iterator ) >>
56  
57 Serializes the L<Attean::API::Binding> objects from C<< $iterator >>
58 and returns the serialization as a UTF-8 encoded byte string.
59  
60 =cut
61  
62 2 ▶ sub serialize_iter_to_bytes {
Subroutine serialize_iter_to_bytes: called CC=1 SCAR=0.0
Pod documented
63 2 my $self = shift;
64 2 my $iter = shift;
65 2 my $data = encode('UTF-8', '');
66 2 open(my $fh, '>', \$data);
67 2 $self->serialize_iter_to_io($fh, $iter);
68 2 close($fh);
69 2 return $data;
70 }
71 }
72  
73 5 1;
74  
75 __END__
« AtteanX/Parser/Turtle/Constants.pm ↑ Summary AtteanX/Parser/NTriples.pm »