perlrdf/Command/StoreDescribe.pm

filter: Statementstmt 66.0% 35 / 53 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 92.3% 12 / 13 Podpod 100% 1 / 1 totaltotal 63.1% 48 / 76 CC 6 SCAR 26.9
CC
6
Cov
57%
execute
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 14.7
« perlrdf/Command/StoreLoad.pm ↑ Summary perlrdf/FileSpec/OutputFile.pm »
1 package App::perlrdf::Command::StoreDescribe;
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::StoreDescribe::AUTHORITY = 'cpan:TOBYINK';
10 1 $App::perlrdf::Command::StoreDescribe::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 (Describe RDF resource using an RDF::Trine::Store.);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use constant command_names => qw( store_describe desc );
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 Retrieve a bounded description from an RDF::Trine::Store.
20 INTRO
21  
22 Output files are specified the same way as for the 'translate' command. See
23 'filespec' for more details.
24 DESCRIPTION
25  
26 1 ▶use constant opt_spec => (
Subroutine BEGIN: called CC=1 SCAR=0.0
27 __PACKAGE__->store_opt_spec,
28 []=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>,
29 [ 'output|o=s@', 'Output filename or URL' ],
30 [ 'output-spec|O=s@', 'Output file specification' ],
31 [ 'output-format|s=s', 'Output format (mnemonic: serialise)' ],
32 1 );
33 1 ▶use constant usage_desc => '%c store_describe %o RESOURCE';
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 sub execute
36 0 ▶{
Subroutine execute: not called CC=6 SCAR=37.4
Pod documented
37 0 require RDF::Trine;
38 0 require App::perlrdf::FileSpec::OutputRDF;
39
40 0 my ($self, $opt, $arg) = @_;
41  
42 0 my $store = $self->get_store($opt);
43 0 my $model = RDF::Trine::Model->new($store);
44  
45 0 ▶ my $resource = @$arg
Branch: 1 branch
BranchTrueFalseTotal
@$arg ? : 0 0 0
46 ? RDF::Trine::iri(shift @$arg)
47 : $self->usage_error("No resource to describe");
48  
49 0 my @outputs = $self->get_filespecs(
50 'App::perlrdf::FileSpec::OutputRDF',
51 output => $opt,
52 );
53
54 push @outputs, map {
55 0 App::perlrdf::FileSpec::OutputRDF->new_from_filespec(
56 $_,
57 $opt->{output_format},
58 $opt->{output_base},
59 )
60 0 } @$arg;
61
62 push @outputs,
63 App::perlrdf::FileSpec::OutputRDF->new_from_filespec(
64 '-',
65 ($opt->{output_format} // 'NQuads'),
66 $opt->{output_base},
67 )
68 0 ▶ unless @outputs;
Branch: 1 branch
BranchTrueFalseTotal
unless @outputs 0 0 0
Condition0%0/2
$opt->{"output_format"} // "NQuads"
l!l
00
MC/DC0%0/1
$opt->{"output_format"} // "NQuads"
$opt->{"output_format"}
Truth table0%0/2
A
A= $opt->{"output_format"}
Aresult
11
00
69  
70 0 my $description = RDF::Trine::Model->new;
71 0 $description->add_iterator( $model->bounded_description($resource) );
72  
73 0 for (@outputs)
74 {
75 0 printf STDERR "Writing %s\n", $_->uri;
76
77 0 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { local $@ = undef; $_->serialize_model($description); 1 } } or warn "$@\n" 0 0 0
78 0 local $@ = undef;
79 0 $_->serialize_model($description);
80 0 1;
81 } or warn "$@\n";
82 }
83 }
84  
85 1 1;
« perlrdf/Command/StoreLoad.pm ↑ Summary perlrdf/FileSpec/OutputFile.pm »