File Coverage

blib/lib/App/JESP/Colorizer.pm
Criterion Covered Total %
statement 10 10 100.0
branch 2 2 100.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 16 16 100.0


line stmt bran cond sub pod time code
1             package App::JESP::Colorizer;
2             $App::JESP::Colorizer::VERSION = '0.014';
3 8     8   46 use Moose;
  8         15  
  8         59  
4              
5             has 'jesp' => ( is => 'ro' , isa => 'App::JESP', required => 1);
6              
7 8     8   49663 use Term::ANSIColor qw//;
  8         50067  
  8         698  
8              
9             =head2 colored
10              
11             Returns a colored text only in an interactive environment.
12              
13             =cut
14              
15             sub colored{
16 14     14 1 26 my ($self, $text, $ansi_color_def) = @_;
17 14 100       283 if( $self->jesp->interactive() ){
18 1         3 return Term::ANSIColor::colored($text, $ansi_color_def);
19             }
20 13         44 return $text;
21             }
22              
23             __PACKAGE__->meta->make_immutable();