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.2601';
3 7     7   462487 use warnings;
  7         21  
  7         455  
4 7     7   157 use strict;
  7         16  
  7         188  
5              
6              
7 7     7   35 use parent 'Games::Solitaire::Verify::State';
  7         11  
  7         47  
8              
9             sub _from_string
10             {
11 6     6   28 my ( $self, $str ) = @_;
12              
13 6         13 my $rank_re = '[0A1-9TJQK]';
14              
15 6         9 my $founds_s;
16 6 100       35 if ( $str =~ m{\A(Foundations:[^\n]*)\n}cgms )
17             {
18 3         10 $founds_s = $1;
19             }
20             else
21             {
22 3         7 $founds_s = "Foundations: H-0 C-0 D-0 S-0";
23             }
24              
25 6         30 $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       28 if ( $str =~ m{\G(Freecells:[^\n]*)\n}cgms )
36             {
37 3         9 $fc = $1;
38             }
39 6         29 $self->_assign_freecells_from_string($fc);
40              
41 6         25 foreach my $col_idx ( 0 .. ( $self->num_columns() - 1 ) )
42             {
43 48 50       251 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         118 my $column_str = $1;
51 48 100       120 if ( $column_str !~ /\A:/ )
52             {
53 24         77 $column_str =~ s/\A\s*/: /;
54             }
55              
56             $self->add_column(
57 48         175 Games::Solitaire::Verify::Column->new(
58             {
59             string => $column_str,
60             }
61             )
62             );
63             }
64              
65 6         22 return;
66             }
67              
68             1; # End of Games::Solitaire::Verify::State
69              
70             __END__