blib/lib/Net/RCON/Minecraft/Response.pm

filter: Statementstmt 100% 37 / 37 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 100% 49 / 49 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Net/RCON/Minecraft.pm ↑ Summary
1 package Net::RCON::Minecraft::Response;
2  
3 # Minecraft command response
4  
5 11 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Mouse::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 11 our $VERSION = '0.05';
13  
14 65 ▶use overload q("") => sub { shift->plain },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
15 1 ▶ '++' => sub { $_[0] = $_[0]->plain + 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 1 ▶ '--' => sub { $_[0] = $_[0]->plain - 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
17 11 fallback => 1;
18  
19 # Minecraft -> ANSI color map
20 11 my %COLOR = map { $_->[1] => color($_->[0]) } (
21 [black => '0'], [blue => '1'], [green => '2'],
22 [cyan => '3'], [red => '4'], [magenta => '5'],
23 [yellow => '6'], [white => '7'], [bright_black => '8'],
24 [bright_blue => '9'], [bright_green => 'a'], [bright_cyan => 'b'],
25 [bright_red => 'c'], [bright_magenta => 'd'], [yellow => 'e'],
26 [bright_white => 'f'],
27 [bold => 'l'], [concealed => 'm'], [underline => 'n'],
28 [reverse => 'o'], [reset => 'r'],
29 );
30  
31 11 has id => ( is => 'ro', isa => 'Int' );
32  
33 11 has raw => ( is => 'ro', isa => 'Str' );
34  
35 40 ▶has plain => ( is => 'ro', isa => 'Str', lazy => 1, default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
36 40 my $raw = $_[0]->raw;
37 40 $raw =~ s/\x{00A7}.//g;
38 40 $raw;
39 11 });
40  
41 8 ▶has ansi => ( is => 'ro', isa => 'Str', lazy => 1, default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
42 8 local $_ = $_[0]->raw;
43 8 s/\x{00A7}(.)/$COLOR{$1}/g;
44 8 $_ . $COLOR{r};
45 11 });
46  
47 11 __PACKAGE__->meta->make_immutable();
« blib/lib/Net/RCON/Minecraft.pm ↑ Summary