blib/script/anvl

filter: Statementstmt 100% 45 / 45 Branchbran 70.0% 14 / 20 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 92.0% 69 / 75 CC 1 SCAR 0.0
CC
1
Cov
91%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/script/erc ↑ Summary
1 #!/usr/local/bin/perl
2  
3 53 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 53 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 53 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 53 my $VERSION = $File::ANVL::VERSION;
8  
9 53 ▶use File::ANVL;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 53 ▶use File::OM;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 53 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 # this :config allows -h24w80 for '‐h 24 ‐w 80', -vax for --vax or --Vax
14 53 ▶use Getopt::Long qw(:config bundling_override);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 53 my %opt = (
17 comments => 0,
18 find => 0,
19 format => 0,
20 help => 0,
21 invert => 0,
22 listformats => 0,
23 man => 0,
24 predns => 0,
25 show => 0,
26 subjelpat => 0,
27 version => 0,
28 verbose => 0,
29 );
30  
31 # main
32 {
33 53 ▶ GetOptions(\%opt,
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions(\%opt, "comments", "find=s", "format|m=s", "help|h|?", "invert", "listformats", "man", "predns=s", "show=s", "subjelpat=s", "version", "verbose|v") or pod2usage("-exitstatus", 2, "-verbose", 1) 53 0 53
34 'comments',
35 'find=s',
36 'format|m=s',
37 'help|h|?',
38 'invert',
39 'listformats',
40 'man',
41 'predns=s',
42 'show=s',
43 'subjelpat=s',
44 'version',
45 'verbose|v',
46 )
47 or pod2usage(-exitstatus => 2, -verbose => 1);
48  
49 53 ▶ $opt{help} and pod2usage(-exitstatus => 0, -verbose => 1);
Branch: 1 branch
BranchTrueFalseTotal
$opt{"help"} and pod2usage("-exitstatus", 0, "-verbose", 1) 0 53 53
50 53 ▶ $opt{man} and pod2usage(-exitstatus => 0, -verbose => 2);
Branch: 1 branch
BranchTrueFalseTotal
$opt{"man"} and pod2usage("-exitstatus", 0, "-verbose", 2) 0 53 53
51 53 ▶ $opt{version} and print("$VERSION\n"), exit 0;
Branch: 1 branch
BranchTrueFalseTotal
$opt{"version"} and print("$VERSION\n"), exit 0 0 53 53
52 $opt{listformats} and
53 53 ▶ print(join("\n", File::OM::listformats()), "\n"),
Branch: 1 branch
BranchTrueFalseTotal
$opt{"listformats"} and print(join("\n", File::OM::listformats()), "\n"), exit 0 1 52 53
54 exit 0;
55  
56 # Format may be a name, optionally followed by a colon and a
57 # list of element names to be output.
58 #
59 52 ▶ my $format = $opt{format} || 'anvl'; # given format name
Condition100%2/2
$opt{'format'} || 'anvl'
l!l
4111
MC/DC100%1/1
$opt{'format'} || 'anvl'
$opt{'format'}
Truth table100%2/2
A
A= $opt{'format'}
Aresult
11
00
60 52 my $r_elem_order;
61 52 ▶ $format =~ /^([^:]*):\s*(.*)\s*/ and
Branch: 1 branch
BranchTrueFalseTotal
$format =~ /^([^:]*):\s*(.*)\s*/ and ($format, @$r_elem_order) = (lc $1, split(/\s*\|\s*/, $2, 0)) 14 38 52
62 ($format, @$r_elem_order) = (lc($1), split(/\s*\|\s*/, $2));
63  
64 # # If an element ordering is defined, change any empty element
65 # # names to the element name ("_"), which grabs any unlabeled
66 # # value that might start the record.
67 # #
68 # $r_elem_order and
69 # @$r_elem_order = map($_ || '_', @$r_elem_order);
70  
71 # output formats to do: anvlr, granvl, yaml, short erc/anvl, csv
72 # XXX need a default command? anvl_summarize?
73  
74 52 my $anvl_opt = File::ANVL::anvl_opt_defaults(); # ref to hash
75 52 $$anvl_opt{comments} = $opt{comments}; # whether to keep comments
76 52 $$anvl_opt{elem_order} = $r_elem_order; # different element order
77 52 $$anvl_opt{find} = $opt{find}; # find records matching regex
78 52 $$anvl_opt{invert} = $opt{invert}; # comma-invert any values
79 52 $$anvl_opt{show} = $opt{show}; # show given elems in recs
80 52 $$anvl_opt{verbose} = $opt{verbose}; # more output
81  
82 # While anvl_opt and om_opt share some keys, they're used differently.
83  
84 my %om_opt = (
85 comments => $opt{comments},
86 outhandle => *STDOUT,
87 verbose => $opt{verbose},
88 52 );
89 $opt{predns} and # predicate namespace
90 52 ▶ $om_opt{turtle_predns} = $opt{predns};
Branch: 1 branch
BranchTrueFalseTotal
$opt{"predns"} and $om_opt{"turtle_predns"} = $opt{"predns"} 1 51 52
91 $opt{subjelpat} and # subject element name pattern
92 52 ▶ $om_opt{turtle_subjelpat} = $opt{subjelpat};
Branch: 1 branch
BranchTrueFalseTotal
$opt{"subjelpat"} and $om_opt{"turtle_subjelpat"} = $opt{"subjelpat"} 1 51 52
93  
94 52 ▶ my $om = File::OM->new($format, \%om_opt) or
Branch: 1 branch
BranchTrueFalseTotal
my $om = "File::OM"->new($format, \%om_opt) or pod2usage("$0: unknown format: $format") 52 0 52
95 pod2usage("$0: unknown format: $format");
96  
97 52 my $st = File::ANVL::anvl_om($om, $anvl_opt);
98 52 ▶ $st ne 1 and die "anvl: $st";
Branch: 1 branch
BranchTrueFalseTotal
$st ne 1 and die "anvl: $st" 0 52 52
99 #
100 # If 'outhandle' had been set to '', we would expect $st to contain
101 # the complete output string built up by anvl_om.
102  
103 52 exit 0;
104 }
105  
106 __END__
« blib/script/erc ↑ Summary