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

filter: Statementstmt 93.8% 46 / 49 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 90.1% 64 / 71 CC 8 SCAR 13.9
CC
8
Cov
89%
run
7.6
_argv
2.0
BEGIN
1.0
CRAP 4.0
« Build ↑ Summary blib/lib/Games/ABC_Path/Solver/Board.pm »
1 package Games::ABC_Path::Solver::App;
2 4 $Games::ABC_Path::Solver::App::VERSION = '0.6.2';
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 4 ▶use parent 'Games::ABC_Path::Solver::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Getopt::Long qw/ GetOptionsFromArray /;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Pod::Usage qw/ pod2usage /;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶use Games::ABC_Path::Solver::Board ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub _argv
15 {
16 8 ▶ my $self = shift;
Subroutine _argv: called CC=2 SCAR=6.9
17  
18 8 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 5 8
19 {
20 3 $self->{_argv} = shift;
21 }
22  
23 8 return $self->{_argv};
24 }
25  
26 sub _init
27 {
28 3 ▶ my ( $self, $args ) = @_;
Subroutine _init: called CC=1 SCAR=0.0
29  
30 3 $self->_argv( [ @{ $args->{argv} } ] );
31  
32 3 return;
33 }
34  
35 sub run
36 {
37 3 ▶ my $self = shift;
Subroutine run: called CC=7 SCAR=20.2
Pod documented
38  
39 3 my $man = 0;
40 3 my $help = 0;
41 3 my $gen_template = 0;
42 3 ▶ GetOptionsFromArray(
Branch: 1 branch
BranchTrueFalseTotal
&GetOptionsFromArray($self->_argv, "help|h", \$help, "man", \$man, "gen-v1-template", \$gen_template) or pod2usage(2) 0 3 3
43 $self->_argv,
44 'help|h' => \$help,
45 man => \$man,
46 'gen-v1-template' => \$gen_template,
47 ) or pod2usage(2);
48  
49 3 ▶ if ($help)
Branch: 3 branches
BranchTrueFalseTotal
if ($help) { } 0 3 3
elsif ($man) { } 0 3 3
elsif ($gen_template) { } 1 2 3
50 {
51 0 pod2usage(1);
52 }
53 elsif ($man)
54 {
55 0 pod2usage( -verbose => 2 );
56 }
57 elsif ($gen_template)
58 {
59 1 print <<'EOF';
60 ABC Path Solver Layout Version 1:
61 ???????
62 ? ?
63 ? ?
64 ? ?
65 ? A ?
66 ? ?
67 ???????
68 EOF
69 }
70 else
71 {
72 2 my $board_fn = shift( @{ $self->_argv } );
73  
74 2 ▶ if ( !defined($board_fn) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $board_fn) 0 2 2
75 {
76 0 die
77 "Filename not specified - usage: abc-path-solver.pl [filename]!";
78 }
79  
80 2 my $solver = Games::ABC_Path::Solver::Board->input_from_file($board_fn);
81  
82 # Now let's do a neighbourhood inferring of the board.
83  
84 2 $solver->solve;
85  
86 2 foreach my $move ( @{ $solver->get_moves } )
87 {
88 181 print +( ' => ' x $move->get_depth() ), $move->get_text(), "\n";
89 }
90  
91 2 print @{ $solver->get_successes_text_tables };
92 }
93  
94 3 exit(0);
95 }
96  
97  
98 4 1; # End of Games::ABC_Path::Solver::App
99  
100 __END__
« Build ↑ Summary blib/lib/Games/ABC_Path/Solver/Board.pm »