perlrdf/FileSpec/InputRDF.pm

filter: Statementstmt 93.5% 29 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 95.2% 40 / 42 CC 1 SCAR 0.3
CC
1
Cov
94%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« perlrdf/Command/MakeStore.pm ↑ Summary
1 package App::perlrdf::FileSpec::InputRDF;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 $App::perlrdf::FileSpec::InputRDF::AUTHORITY = 'cpan:TOBYINK';
11 1 $App::perlrdf::FileSpec::InputRDF::VERSION = '0.006';
12 }
13  
14 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use RDF::Trine;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use RDF::TriN3;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use RDF::TrineX::Parser::Pretdsl;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 0 ▶use RDF::TrineX::Parser::RDFa;
Subroutine BEGIN: called CC=1 SCAR=2.6
19 use RDF::TrineX::Functions -all => { -prefix => 'rdf_' };
20  
21 use namespace::clean;
22  
23 extends 'App::perlrdf::FileSpec::InputFile';
24  
25 has parser => (
26 is => 'ro',
27 isa => 'Object|Undef',
28 lazy_build => 1,
29 );
30  
31 sub _build_format
32 {
33 my $self = shift;
34
35 if (lc $self->uri->scheme eq 'file')
36 {
37 return 'RDF::TrineX::Parser::Pretdsl'
38 if $self->uri->file =~ /\.(pret|pretdsl)/i;
39
40 return RDF::Trine::Parser
41 -> guess_parser_by_filename($self->uri->file);
42 }
43
44 if ($self->can('response'))
45 {
46 return $self->response->content_type
47 if $self->response->content_type;
48
49 return 'RDF::TrineX::Parser::Pretdsl'
50 if (($self->response->base // $self->uri) =~ /\.(pret|pretdsl)/i);
51
52 return RDF::Trine::Parser->guess_parser_by_filename(
53 $self->response->base // $self->uri,
54 );
55 }
56  
57 return 'RDF::TrineX::Parser::Pretdsl'
58 if $self->uri =~ /\.(pret|pretdsl)/i;
59  
60 return RDF::Trine::Parser->guess_parser_by_filename($self->uri);
61 }
62  
63 sub _build_parser
64 {
65 my $self = shift;
66 my $P = 'RDF::Trine::Parser';
67
68 if (blessed $self->format and $self->format->isa($P))
69 {
70 return $self->format;
71 }
72
73 if ($self->format =~ m{/})
74 {
75 return $P->parser_by_media_type($self->format)->new;
76 }
77  
78 if ($self->format =~ m{::})
79 {
80 return $self->format->new;
81 }
82  
83 if ($self->format =~ m{(pret|pretdsl)}i)
84 {
85 return RDF::TrineX::Parser::Pretdsl->new;
86 }
87  
88 return $P->new($self->format);
89 }
90  
91 sub parse_into_model
92 {
93 my ($self, $model, %args) = @_;
94  
95 rdf_parse(
96 $self->handle,
97 base => $self->base,
98 using => $self->parser,
99 into => $model,
100 %args,
101 )
102 }
103  
104 1;
« perlrdf/Command/MakeStore.pm ↑ Summary