blib/lib/Games/ABC_Path/Generator/App.pm

filter: Statementstmt 93.6% 44 / 47 Branchbran 71.4% 10 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 90.2% 65 / 72 CC 8 SCAR 13.5
CC
8
Cov
89%
run
7.6
_argv
2.0
BEGIN
1.0
CRAP 3.8
« Build ↑ Summary blib/lib/Games/ABC_Path/Generator/RiddleObj.pm »
1 package Games::ABC_Path::Generator::App;
2 6 $Games::ABC_Path::Generator::App::VERSION = '0.6.0';
3 6 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use Pod::Usage qw(pod2usage);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶use parent 'Games::ABC_Path::Generator::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 ▶use Getopt::Long qw(GetOptionsFromArray);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 6 ▶use Games::ABC_Path::Generator;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 sub _argv
17 {
18 8 ▶ my $self = shift;
Subroutine _argv: called CC=2 SCAR=6.9
19  
20 8 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4 4 8
21 {
22 4 $self->{_argv} = shift;
23 }
24  
25 8 return $self->{_argv};
26 }
27  
28 sub _init
29 {
30 4 ▶ my ( $self, $args ) = @_;
Subroutine _init: called CC=1 SCAR=0.0
31  
32 4 $self->_argv( $args->{argv} );
33  
34 4 return;
35 }
36  
37  
38 sub run
39 {
40 4 ▶ my ($self) = @_;
Subroutine run: called CC=7 SCAR=20.3
Pod documented
41  
42 4 my $seed;
43 4 my $mode = 'riddle';
44 4 my $man = 0;
45 4 my $help = 0;
46 4 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless (&GetOptionsFromArray($self->_argv, "seed=i", \$seed, "mode=s", \$mode, "help|h", \$help, "man", \$man)) 0 4 4
47 !GetOptionsFromArray(
48 $self->_argv(),
49 'seed=i' => \$seed,
50 'mode=s' => \$mode,
51 'help|h' => \$help,
52 man => \$man,
53 )
54 )
55 {
56 0 pod2usage(2);
57 }
58  
59 4 ▶ if ($help)
Branch: 3 branches
BranchTrueFalseTotal
if ($help) { } 1 3 4
elsif ($man) { } 0 3 3
elsif (not defined $seed) { } 0 3 3
60 {
61 1 pod2usage(1);
62 }
63 elsif ($man)
64 {
65 0 pod2usage( -verbose => 2 );
66 }
67 elsif ( !defined($seed) )
68 {
69 0 die "Seed not specified! See --help.";
70 }
71 else
72 {
73 3 my $gen = Games::ABC_Path::Generator->new( { seed => $seed, } );
74  
75 3 ▶ if ( $mode eq 'final' )
Branch: 2 branches
BranchTrueFalseTotal
if ($mode eq 'final') { } 1 2 3
elsif ($mode eq 'riddle') { } 2 0 2
76 {
77 1 print $gen->calc_final_layout()->as_string( {} );
78 }
79 elsif ( $mode eq 'riddle' )
80 {
81 2 my $riddle = $gen->calc_riddle();
82 2 my $riddle_string = $riddle->get_riddle_v1_string;
83  
84 2 print sprintf( "ABC Path Solver Layout Version 1:\n%s",
85 $riddle_string, );
86 }
87  
88 }
89 3 return;
90 }
91  
92  
93 6 1; # End of Games::ABC_Path::Generator::App
94  
95 __END__
« Build ↑ Summary blib/lib/Games/ABC_Path/Generator/RiddleObj.pm »