File Coverage

blib/lib/Games/Solitaire/Verify/State/LaxParser.pm
Criterion Covered Total %
statement 27 28 96.4
branch 7 8 87.5
condition n/a
subroutine 4 4 100.0
pod n/a
total 38 40 95.0


line stmt bran cond sub pod time code
1             package Games::Solitaire::Verify::State::LaxParser;
2             $Games::Solitaire::Verify::State::LaxParser::VERSION = '0.2403';
3 3     3   575 use warnings;
  3         8  
  3         128  
4 3     3   16 use strict;
  3         8  
  3         73  
5              
6              
7 3     3   15 use parent 'Games::Solitaire::Verify::State';
  3         6  
  3         20  
8              
9             sub _from_string
10             {
11 6     6   23 my ( $self, $str ) = @_;
12              
13 6         14 my $rank_re = '[0A1-9TJQK]';
14              
15 6         45 my $founds_s;
16 6 100       43 if ( $str =~ m{\A(Foundations:[^\n]*)\n}cgms )
17             {
18 3         12 $founds_s = $1;
19             }
20             else
21             {
22 3         11 $founds_s = "Foundations: H-0 C-0 D-0 S-0";
23             }
24              
25 6         53 $self->set_foundations(
26             Games::Solitaire::Verify::Foundations->new(
27             {
28             num_decks => $self->num_decks(),
29             string => $founds_s,
30             }
31             )
32             );
33              
34 6         18 my $fc = 'Freecells:';
35 6 100       30 if ( $str =~ m{\G(Freecells:[^\n]*)\n}cgms )
36             {
37 3         10 $fc = $1;
38             }
39 6         34 $self->_assign_freecells_from_string($fc);
40              
41 6         29 foreach my $col_idx ( 0 .. ( $self->num_columns() - 1 ) )
42             {
43 48 50       265 if ( $str !~ m{\G([^\n]*)\n}msg )
44             {
45 0         0 Games::Solitaire::Verify::Exception::Parse::State::Column->throw(
46             error => "Cannot parse column",
47             index => $col_idx,
48             );
49             }
50 48         140 my $column_str = $1;
51 48 100       128 if ( $column_str !~ /\A:/ )
52             {
53 24         84 $column_str =~ s/\A\s*/: /;
54             }
55              
56             $self->add_column(
57 48         201 Games::Solitaire::Verify::Column->new(
58             {
59             string => $column_str,
60             }
61             )
62             );
63             }
64              
65 6         24 return;
66             }
67              
68             1; # End of Games::Solitaire::Verify::State
69              
70             __END__