perlrdf/Command/FileSpec.pm

filter: Statementstmt 87.5% 35 / 40 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 1 / 1 totaltotal 85.7% 48 / 56 CC 3 SCAR 11.6
CC
3
Cov
83%
execute
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« perlrdf/FileSpec.pm ↑ Summary perlrdf/DummyModel.pm »
1 package App::perlrdf::Command::FileSpec;
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::FileSpec::AUTHORITY = 'cpan:TOBYINK';
10 1 $App::perlrdf::Command::FileSpec::VERSION = '0.006';
11 }
12  
13 1 ▶use App::perlrdf -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use constant abstract => q (Shows help on how to use "file specifications");
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant command_names => qw( filespec );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use constant description => <<'DESCRIPTION';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 FileSpecs are an App::perlbrew microsyntax for specifying input and output
21 data streams. Various commands expect to be given filespecs so that they know
22 what files, URLs or streams to operate on.
23  
24 FileSpecs have a two part syntax. They start with an optional JSON-like
25 options specification, and are followed by a (non-optional) file name, URL or
26 dash. Some examples:
27  
28 {format:RDFXML}C:\Data\Countries.rdfx
29 http://www.example.com/data.rdf
30 {format:"Turtle",base:"http://www.example.net/"}-
31  
32 The optional JSON-like part is a list of key-value pairs, where pairs are
33 separated with commas, and keys are seperated from values with colons. Keys
34 and values must be quoted with single or double quotes if they contain
35 "non-word" characters (i.e. /\W/). No escaping is available. There are no
36 nested data structures.
37  
38 The following keys are currently defined:
39  
40 format - file format (media type, format name or parser class)
41 base - base URI
42  
43 Additional keys are currently ignored, available for future use.
44  
45 The second part may be a relative or absolute filename which will be
46 converted into a URI; or may be an absolute URI in any supported URI scheme;
47 or may be a dash, which is treated as STDIN or STDOUT depending on context.
48  
49 Supported URI schemes include any URI scheme which can be used for GET
50 requests by LWP::UserAgent, including http, https, data, file, ftp, gopher
51 and nntp; and pseudo-schemes cpan, loopback and nogo. App::perlrdf also
52 supports pseudo-schemes stdin, stdout and stderr.
53  
54 So for example, to write Turtle to STDERR:
55  
56 perlrdf translate -i mydata.rdf -o "{format:Turtle}stderr:"
57  
58 The 'translate' command allows you to specify input our output as either a
59 filename or a file spec, using different parameters for each:
60  
61 perlrdf translate --input=FILE --output-spec=SPEC
62 perlrdf translate --input-spec=SPEC --output=FILE
63 perlrdf translate -I SPEC -O SPEC
64 perlrdf translate -i FILE -o FILE -O SPEC
65  
66 If you want to test FileSpecs, you can run:
67  
68 perlrdf filespec SPEC1 SPEC2 ...
69 DESCRIPTION
70 1 ▶use constant opt_spec => qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
71 1 ▶use constant usage_desc => '%c filespec';
Subroutine BEGIN: called CC=1 SCAR=0.0
72  
73 sub execute
74 0 ▶{
Subroutine execute: not called CC=3 SCAR=24.8
Pod documented
75 0 my ($class, $opt, $args) = @_;
76
77 0 ▶ if (@$args)
Branch: 1 branch
BranchTrueFalseTotal
if (@$args) { } 0 0 0
78 {
79 0 require App::perlrdf::FileSpec;
80 say
81 App::perlrdf::FileSpec->new_from_filespec($_)->TO_JSON(1),
82 0 for @$args;
83 }
84 else
85 {
86 0 say $class->description;
87 }
88 }
89  
90 1 1;
91  
« perlrdf/FileSpec.pm ↑ Summary perlrdf/DummyModel.pm »