| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SweetPea::Cli::Flash; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
43
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
379
|
use SweetPea::Cli::Util; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
518
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# SweetPea::Cli::Flash - Flash handling for SweetPea-Cli. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
0
|
|
|
0
|
0
|
|
my ($class, $s) = @_; |
|
12
|
0
|
|
|
|
|
|
my $self = {}; |
|
13
|
0
|
|
|
|
|
|
bless $self, $class; |
|
14
|
0
|
|
|
|
|
|
$self->{base} = $s; |
|
15
|
0
|
|
|
|
|
|
$self->{flashes} = []; |
|
16
|
0
|
|
|
|
|
|
return $self; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# flash |
|
20
|
|
|
|
|
|
|
# The flash method is responsible for storing passed in error messages |
|
21
|
|
|
|
|
|
|
# for later retrieval and rendering. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub flash { |
|
24
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
25
|
0
|
|
|
|
|
|
foreach my $message (@_) { |
|
26
|
0
|
|
|
|
|
|
push @{$self->{flashes}}, $message; |
|
|
0
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
|
28
|
0
|
|
|
|
|
|
return $self; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# count |
|
32
|
|
|
|
|
|
|
# The count method returns the number of error messages currently |
|
33
|
|
|
|
|
|
|
# existing in the error messages container. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub count { |
|
36
|
0
|
|
|
0
|
0
|
|
return @{shift->{flashes}}; |
|
|
0
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# clear |
|
40
|
|
|
|
|
|
|
# The clear method resets the error message container. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub clear { |
|
43
|
0
|
|
|
0
|
0
|
|
shift->{flashes} = []; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# report |
|
47
|
|
|
|
|
|
|
# The report method is responsible for displaying all stored error |
|
48
|
|
|
|
|
|
|
# messages using the defined message delimiter. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub report { |
|
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
52
|
0
|
|
|
|
|
|
my $c = shift; |
|
53
|
0
|
|
|
|
|
|
my $u = SweetPea::Cli::Util->new; |
|
54
|
0
|
0
|
|
|
|
|
if ($c) { |
|
55
|
0
|
|
|
|
|
|
$c->stash->{flashes} = $self->{flashes}; |
|
56
|
0
|
|
|
|
|
|
$self->clear; |
|
57
|
0
|
|
|
|
|
|
return $u->template('misc/text_string.tt', $c); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; # End of SweetPea::Cli::Flash |