| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 4 |  |  | 4 |  | 9810 | use v5.14; | 
|  | 4 |  |  |  |  | 14 |  | 
| 2 | 4 |  |  | 4 |  | 22 | use warnings; | 
|  | 4 |  |  |  |  | 9 |  | 
|  | 4 |  |  |  |  | 212 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | =head1 NAME | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | AtteanX::Parser::NQuads - N-Quads Parser | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 VERSION | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | This document describes AtteanX::Parser::NQuads version 0.032 | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | use Attean; | 
| 15 |  |  |  |  |  |  | my $parser = Attean->get_parser('NQuads')->new(); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | # Parse data from a file-handle and handle quads in the 'handler' callback | 
| 18 |  |  |  |  |  |  | $parser->parse_cb_from_io( $fh ); | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | # Parse the given byte-string, and return an iterator of quads | 
| 21 |  |  |  |  |  |  | my $iter = $parser->parse_iter_from_bytes('<http://example.org/subject> <tag:example.org:predicate> "object" <http://example.org/graph> .'); | 
| 22 |  |  |  |  |  |  | while (my $quad = $iter->next) { | 
| 23 |  |  |  |  |  |  | print $quad->as_string; | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | This module implements a parser for the N-Quads format. | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | =head1 ROLES | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | This class consumes L<Attean::API::Parser>, L<Attean::API::PullParser> | 
| 33 |  |  |  |  |  |  | and <Attean::API::MixedStatementParser>. | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =head1 METHODS | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =over 4 | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =cut | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | use utf8; | 
| 42 | 4 |  |  | 4 |  | 26 |  | 
|  | 4 |  |  |  |  | 9 |  | 
|  | 4 |  |  |  |  | 29 |  | 
| 43 |  |  |  |  |  |  | use Attean; | 
| 44 | 4 |  |  | 4 |  | 89 | use Moo; | 
|  | 4 |  |  |  |  | 9 |  | 
|  | 4 |  |  |  |  | 30 |  | 
| 45 | 4 |  |  | 4 |  | 16 | extends 'AtteanX::Parser::NTuples'; | 
|  | 4 |  |  |  |  | 10 |  | 
|  | 4 |  |  |  |  | 30 |  | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =item C<< canonical_media_type >> | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | Returns the canonical media type for N-Quads: application/n-quads. | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =cut | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 1 |  |  | 1 | 1 | 564 | =item C<< media_types >> | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | Returns a list of media types that may be parsed with the N-Triples parser: | 
| 57 |  |  |  |  |  |  | application/n-quads. | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =cut | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | return [qw(application/n-quads)]; | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 | 5 |  |  | 5 | 1 | 19 | =item C<< file_extensions >> | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | Returns a list of file extensions that may be parsed with the parser. | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =cut | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | with 'Attean::API::MixedStatementParser'; | 
| 72 |  |  |  |  |  |  | with 'Attean::API::PullParser'; | 
| 73 | 13 |  |  | 13 | 1 | 55 |  | 
| 74 |  |  |  |  |  |  | my $self	= shift; | 
| 75 |  |  |  |  |  |  | my $nodes	= shift; | 
| 76 |  |  |  |  |  |  | my $lineno	= shift; | 
| 77 |  |  |  |  |  |  | if (scalar(@$nodes) == 3) { | 
| 78 |  |  |  |  |  |  | return Attean::Triple->new(@$nodes); | 
| 79 | 17 |  |  | 17 |  | 25 | } elsif (scalar(@$nodes) == 4) { | 
| 80 | 17 |  |  |  |  | 20 | return Attean::Quad->new(@$nodes); | 
| 81 | 17 |  |  |  |  | 31 | } else { | 
| 82 | 17 | 100 |  |  |  | 41 | die qq[Not valid N-Quads data at line $lineno]; | 
|  |  | 50 |  |  |  |  |  | 
| 83 | 3 |  |  |  |  | 42 | } | 
| 84 |  |  |  |  |  |  | } | 
| 85 | 14 |  |  |  |  | 265 | } | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 0 |  |  |  |  |  | 1; | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =back | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =head1 BUGS | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | Please report any bugs or feature requests to through the GitHub web interface | 
| 95 |  |  |  |  |  |  | at L<https://github.com/kasei/perlrdf/issues>. | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =head1 AUTHOR | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | Gregory Todd Williams  C<< <gwilliams@cpan.org> >> | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | Copyright (c) 2014--2022 Gregory Todd Williams. This | 
| 104 |  |  |  |  |  |  | program is free software; you can redistribute it and/or modify it under | 
| 105 |  |  |  |  |  |  | the same terms as Perl itself. | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =cut |