blib/lib/App/Asciio/Options.pm

filter: Statementstmt 32.5% 14 / 43 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 3 totaltotal 23.3% 18 / 77 CC 10 SCAR 29.2
CC
10
Cov
23%
ParseSwitches
42.0
Get_GetoptLong_Data
12.0
__ANON__
6.0
CRAP 18.6
« blib/lib/App/Asciio/Actions/Shapes.pm ↑ Summary blib/lib/App/Asciio/Stencil.pm »
1  
2 package App::Asciio ;
3  
4 4 $|++ ;
5  
6 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Data::TreeDumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Getopt::Long ;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #-----------------------------------------------------------------------------
13  
14 sub ParseSwitches
15 0 ▶{
Subroutine ParseSwitches: not called CC=6 SCAR=37.4
Pod undocumented
16 0 my ($self, $switches_to_parse, $ignore_error) = @_ ;
17  
18 0 my $asciio_config = {} ;
19  
20 0 Getopt::Long::Configure('no_auto_abbrev', 'no_ignore_case', 'require_order') ;
21  
22 0 my @flags = Get_GetoptLong_Data($asciio_config) ;
23  
24 0 @ARGV = @{$switches_to_parse} ;
25  
26 # tweek option parsing so we can mix switches with targets
27 0 my $contains_switch ;
28 my @targets ;
29  
30 do
31 0 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
$contains_switch and do { do { while (@ARGV and not $ARGV[0] =~ /^-/) { push @targets, shift @ARGV; } ; $contains_switch = @ARGV; local $SIG{"__WARN__"} = sub { print STDERR $_[0] unless $ignore_error; } ; unless (&GetOptions(@flags)) { return 0, "Try perl asciio -h.", $asciio_config, @ARGV unless $ignore_error; } } } 0 0 0
32 0 ▶ while(@ARGV && $ARGV[0] !~ /^-/)
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV and not $ARGV[0] =~ /^-/) 0 0 0
Condition0%0/3
@ARGV and not $ARGV[0] =~ /^-/
!ll&&!rl&&r
000
MC/DC0%0/2
@ARGV and not $ARGV[0] =~ /^-/
@ARGV not $ARGV[0] =~ /^-/
Truth table0%0/3
A and not(B)
A= @ARGVB= not $ARGV[0] =~ /^-/
ABresult
0X0
100
111
33 {
34 #~ print "target => $ARGV[0] \n" ;
35 0 push @targets, shift @ARGV ;
36 }
37
38 0 $contains_switch = @ARGV ;
39
40 0 ▶ local $SIG{__WARN__} = sub {print STDERR $_[0] unless $ignore_error ;} ;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
unless $ignore_error 0 0 0
41
42 0 ▶ unless(GetOptions(@flags))
Branch: 1 branch
BranchTrueFalseTotal
unless (&GetOptions(@flags)) 0 0 0
43 {
44 0 ▶ return(0, "Try perl asciio -h.", $asciio_config, @ARGV) unless $ignore_error;
Branch: 1 branch
BranchTrueFalseTotal
unless $ignore_error 0 0 0
45 }
46 }
47 while($contains_switch) ;
48  
49 0 $asciio_config->{TARGETS} = \@targets ;
50  
51 0 return(1, '', $asciio_config) ;
52 }
53  
54 #-------------------------------------------------------------------------------
55  
56 sub Get_GetoptLong_Data
57 0 ▶{
Subroutine Get_GetoptLong_Data: not called CC=3 SCAR=24.8
Pod undocumented
58 0 ▶my $asciio_config = shift || die 'Missing argument.' ;
Condition0%0/2
shift() || die('Missing argument.')
l!l
00
MC/DC0%0/1
shift() || die('Missing argument.')
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
59  
60 0 my @flags_and_help = GetSwitches($asciio_config) ;
61  
62 0 my $flag_element_counter = 0 ;
63 0 my @getoptlong_data ;
64  
65 0 ▶for (my $i = 0 ; $i < @flags_and_help; $i += 4)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @flags_and_help) 0 0 0
66 {
67 0 my ($flag, $variable) = ($flags_and_help[$i], $flags_and_help[$i + 1]) ;
68 0 push @getoptlong_data, ($flag, $variable) ;
69 }
70  
71 0 return(@getoptlong_data) ;
72 }
73  
74 #-------------------------------------------------------------------------------
75  
76 sub GetSwitches
77 0 ▶{
Subroutine GetSwitches: not called CC=2 SCAR=17.9
Pod undocumented
78 0 ▶my $asciio_config = shift || {} ;
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
79  
80 0 $asciio_config->{SETUP_PATHS} = [] ;
81  
82 my @flags_and_help =
83 (
84 'setup_path=s' => $asciio_config->{SETUP_PATHS},
85 'Sets the root of the setup directory.',
86 '',
87
88 's|script=s' => \$asciio_config->{SCRIPT},
89 'script to be run at AsciiO start.',
90 '',
91
92 'h|help' => \$asciio_config->{HELP},
93 0 'Displays some help.',
94 '',
95 ) ;
96
97 0 return(@flags_and_help) ;
98 }
99  
100 #-----------------------------------------------------------------------------
101  
102 4 1 ;
103  
« blib/lib/App/Asciio/Actions/Shapes.pm ↑ Summary blib/lib/App/Asciio/Stencil.pm »