line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Message::BlockColor; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
991
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
24
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
71
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
extends qw(MooseX::App::Message::Block); |
11
|
1
|
|
|
1
|
|
7031
|
no if $] >= 5.018000, warnings => qw(experimental::smartmatch); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
62
|
use Term::ANSIColor qw(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
14
|
1
|
|
|
1
|
|
4
|
use IO::Interactive qw(is_interactive); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
BEGIN { |
17
|
1
|
50
|
|
1
|
|
432
|
if ($^O eq 'MSWin32') { |
18
|
0
|
|
|
|
|
|
Class::Load::try_load_class('Win32::Console::ANSI'); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub stringify { |
23
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $header_color; |
26
|
|
|
|
|
|
|
my $body_color; |
27
|
0
|
|
|
|
|
|
given ($self->type) { |
28
|
0
|
|
|
|
|
|
when('error') { |
29
|
0
|
|
|
|
|
|
$header_color = 'bright_red bold'; |
30
|
0
|
|
|
|
|
|
$body_color = 'bright_red'; |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
when('default') { |
33
|
0
|
|
|
|
|
|
$header_color = 'bold'; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
default { |
36
|
0
|
|
|
|
|
|
$header_color = $_; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $message = ''; |
41
|
0
|
0
|
|
|
|
|
if ($self->has_header) { |
42
|
0
|
|
|
|
|
|
$message .= $self->_wrap_color($header_color,$self->header)."\n"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if ($self->has_body) { |
46
|
0
|
|
|
|
|
|
$message .= $self->_wrap_color($body_color,$self->body)."\n\n"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $message; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _wrap_color { |
53
|
0
|
|
|
0
|
|
|
my ($self,$color,$string) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
0
|
|
|
|
return $string |
56
|
|
|
|
|
|
|
unless is_interactive() |
57
|
|
|
|
|
|
|
&& defined $color; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return Term::ANSIColor::color($color) |
60
|
|
|
|
|
|
|
.$string |
61
|
|
|
|
|
|
|
.Term::ANSIColor::color('reset'); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
65
|
|
|
|
|
|
|
1; |