lib/Getopt/LL/Short.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 2 / 2 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 49 / 49 CC 4 SCAR 5.5
CC
4
Cov
100%
getoptions
3.0
parse_short_rule
2.0
BEGIN
1.0
CRAP 1.7
« blib/lib/Getopt/LL/DLList.pm ↑ Summary lib/Getopt/LL/Simple.pm »
1 # $Id: Short.pm,v 1.6 2007/07/13 00:00:14 ask Exp $
2 # $Source: /opt/CVS/Getopt-LL/lib/Getopt/LL/Short.pm,v $
3 # $Author: ask $
4 # $HeadURL$
5 # $Revision: 1.6 $
6 # $Date: 2007/07/13 00:00:14 $
7 package Getopt::LL::Short;
8 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use base 'Getopt::LL';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use version; our $VERSION = qv('1.0.0');
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use 5.006_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 {
14  
15 4 ▶ use Getopt::LL::SimpleExporter qw(getoptions);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 my %RULE_ABBREVATION = (
18 's' => 'string',
19 'd' => 'digit',
20 'f' => 'flag',
21 );
22  
23 16 ▶ sub parse_short_rule {
Subroutine parse_short_rule: called CC=2 SCAR=6.9
Pod documented
24 16 my ($rule) = @_;
25  
26 16 ▶ if (index ($rule, q{=}) != -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($rule, "=") != -1) 9 7 16
27 9 my ($arg_name, $rule_type) = split m/=/xms, $rule, 2;
28 9 return ($arg_name, $RULE_ABBREVATION{$rule_type});
29 }
30  
31 # Default rule is flag.
32 7 return ($rule, 'flag');
33 }
34  
35 5 ▶ sub getoptions {
Subroutine getoptions: called CC=3 SCAR=11.0
Pod documented
36 5 my ($rules_ref, $options_ref, $argv_ref) = @_;
37 5 ▶ $rules_ref ||= [ ];
Condition100%2/2
$rules_ref ||= []
l!l
41
MC/DC100%1/1
$rules_ref ||= []
$rules_ref
Truth table100%2/2
A
A= $rules_ref
Aresult
11
00
38  
39 5 my %converted_rules;
40 5 for my $rule (@{$rules_ref}) {
41 16 my ($arg_name, $rule_ref) = parse_short_rule($rule);
42 16 $converted_rules{$arg_name} = $rule_ref;
43 }
44  
45 5 return Getopt::LL::getoptions(
46 \%converted_rules, $options_ref, $argv_ref
47 );
48  
49 }
50  
51 }
52 4 1;
53  
54 __END__
« blib/lib/Getopt/LL/DLList.pm ↑ Summary lib/Getopt/LL/Simple.pm »