File Coverage

lib/App/colourhexdump/DefaultColourProfile.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1 1     1   720 use 5.006;
  1         3  
  1         33  
2 1     1   4 use strict;
  1         1  
  1         30  
3 1     1   3 use warnings;
  1         1  
  1         65  
4              
5             package App::colourhexdump::DefaultColourProfile;
6              
7             our $VERSION = '1.000001';
8              
9             # ABSTRACT: The default colour profile
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 1     1   176 use Moose qw( has with );
  0            
  0            
14             use namespace::autoclean;
15              
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35              
36              
37              
38             with 'App::colourhexdump::ColourProfile';
39              
40             use Term::ANSIColor 3.00 qw( BLACK ON_RED BOLD BRIGHT_BLUE BRIGHT_YELLOW ON_YELLOW RED BLUE YELLOW );
41              
42              
43              
44              
45              
46              
47              
48             ## no critic ( Subroutines::RequireArgUnpacking )
49             sub get_colour_for {
50             return BLACK . ON_RED if $_[1] =~ /\r/;
51             return BOLD . BRIGHT_BLUE if $_[1] =~ /\n/;
52             return BLUE if $_[1] =~ / /;
53             return BOLD . BRIGHT_BLUE . ON_YELLOW if $_[1] =~ /\t/;
54             return RED if $_[1] =~ qr{[^[:print:]]};
55             return if $_[1] =~ qr{[[:alpha:]\d]};
56             return YELLOW;
57             }
58              
59              
60              
61              
62              
63              
64              
65             ## no critic ( Subroutines::RequireArgUnpacking )
66              
67             sub get_display_symbol_for {
68             return q{_} if $_[1] =~ qr{\s};
69             return q{.} if $_[1] =~ qr{[^[:print:]]};
70             return $_[1];
71             }
72              
73             __PACKAGE__->meta->make_immutable;
74             no Moose;
75             1;
76              
77             __END__
78              
79             =pod
80              
81             =encoding UTF-8
82              
83             =head1 NAME
84              
85             App::colourhexdump::DefaultColourProfile - The default colour profile
86              
87             =head1 VERSION
88              
89             version 1.000001
90              
91             =head1 SYNOPSIS
92              
93             This is the default colour profile.
94              
95             \r => black on red '_'
96             \n => bold bright blue '_'
97             " " => blue '_'
98             \t => bold bright blue on yellow '_'
99             alphanumeric => white $char
100             nonprintable => red '.'
101             everything else => yellow $char
102              
103             Invocation:
104              
105             my $cp = App::colourhexdump::DefaultColourProfile->new();
106             my $colouredChar =
107             $cp->get_string_pre( $char ) .
108             $cp->get_dispaly_symbol_for( $char ) .
109             $cp->get_string_post( $char );
110              
111             =head1 METHODS
112              
113             =head2 get_colour_for
114              
115             See L<App::colourhexdump::ColourProfile/get_colour_for>
116              
117             =head2 get_display_symbol_for
118              
119             See L<App::colourhexdump::ColourProfile/get_display_symbol_for>
120              
121             =head1 AUTHOR
122              
123             Kent Fredric <kentnl@cpan.org>
124              
125             =head1 COPYRIGHT AND LICENSE
126              
127             This software is copyright (c) 2014 by Kent Fredric <kentnl@cpan.org>.
128              
129             This is free software; you can redistribute it and/or modify it under
130             the same terms as the Perl 5 programming language system itself.
131              
132             =cut