perlrdf/Command/StoreLoad.pm

filter: Statementstmt 62.7% 32 / 51 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 100% 1 / 1 totaltotal 61.1% 44 / 72 CC 6 SCAR 27.4
CC
6
Cov
54%
execute
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 15.5
« perlrdf/Command/Prefix.pm ↑ Summary perlrdf/Command/StoreDescribe.pm »
1 package App::perlrdf::Command::StoreLoad;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 $App::perlrdf::Command::StoreLoad::AUTHORITY = 'cpan:TOBYINK';
10 1 $App::perlrdf::Command::StoreLoad::VERSION = '0.006';
11 }
12  
13 1 ▶use App::perlrdf -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use constant abstract => q (Load RDF data into an RDF::Trine::Store.);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use constant command_names => qw( store_load load );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant description => <<'INTRO' . __PACKAGE__->store_help . <<'DESCRIPTION';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 Load data into an RDF::Trine::Store. The store should have been previously
20 initialized (e.g. using the make_store command).
21 INTRO
22  
23 Input files are specified the same way as for the 'translate' command. See
24 'filespec' for more details. If a parsing error occurs in an input,
25 subsequent inputs will still be processed. It may be a good idea to check
26 the input files first using 'validate'.
27 DESCRIPTION
28  
29 1 ▶use constant opt_spec => (
Subroutine BEGIN: called CC=1 SCAR=0.0
30 __PACKAGE__->store_opt_spec,
31 []=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>,
32 [ 'input|i=s@', 'Input filename or URL' ],
33 [ 'input-spec|I=s@', 'Input file specification' ],
34 [ 'input-format|p=s', 'Input format (mnemonic: parse)' ],
35 [ 'input-base|b=s', 'Input base URI' ],
36 []=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>,
37 [ 'graph|g=s', 'Graph URI for input' ],
38 [ 'autograph|G', 'Generate graph URI based on input URI' ],
39 1 );
40  
41 sub execute
42 0 ▶{
Subroutine execute: not called CC=6 SCAR=37.4
Pod documented
43 0 require RDF::Trine;
44 0 require App::perlrdf::FileSpec::InputRDF;
45
46 0 my ($self, $opt, $arg) = @_;
47  
48 0 my $store = $self->get_store($opt);
49 0 my $model = RDF::Trine::Model->new($store);
50  
51 0 my @inputs = $self->get_filespecs(
52 'App::perlrdf::FileSpec::InputRDF',
53 input => $opt,
54 );
55
56 push @inputs, map {
57 0 App::perlrdf::FileSpec::InputRDF->new_from_filespec(
58 $_,
59 $opt->{input_format},
60 $opt->{input_base},
61 )
62 0 } @$arg;
63  
64 push @inputs,
65 App::perlrdf::FileSpec::InputRDF->new_from_filespec(
66 '-',
67 $opt->{input_format},
68 $opt->{input_base},
69 )
70 0 ▶ unless @inputs;
Branch: 1 branch
BranchTrueFalseTotal
unless @inputs 0 0 0
71  
72 0 for (@inputs)
73 {
74 0 printf STDERR "Loading %s\n", $_->uri;
75
76 0 my %params = ();
77 0 ▶ if ($opt->{autograph})
Branch: 2 branches
BranchTrueFalseTotal
if ($opt->{'autograph'}) { } 0 0 0
elsif ($opt->{'graph'}) { } 0 0 0
78 0 { $params{graph} = $_->uri }
79 elsif ($opt->{graph})
80 0 { $params{graph} = $opt->{graph} }
81
82 0 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { local $@ = undef; $_->parse_into_model($model, %params); 1 } } or warn "$@\n" 0 0 0
83 0 local $@ = undef;
84 0 $_->parse_into_model($model, %params);
85 0 1;
86 } or warn "$@\n";
87 }
88 }
89  
90 1 1;
91  
« perlrdf/Command/Prefix.pm ↑ Summary perlrdf/Command/StoreDescribe.pm »