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.016';
3 8     8   56 use Moose;
  8         16  
  8         68  
4              
5             has 'jesp' => ( is => 'ro' , isa => 'App::JESP', required => 1);
6              
7 8     8   60188 use Term::ANSIColor qw//;
  8         64333  
  8         964  
8              
9             =head2 colored
10              
11             Returns a colored text only in an interactive environment.
12              
13             =cut
14              
15             sub colored{
16 26     26 1 61 my ($self, $text, $ansi_color_def) = @_;
17 26 100       658 if( $self->jesp->interactive() ){
18 1         6 return Term::ANSIColor::colored($text, $ansi_color_def);
19             }
20 25         383 return $text;
21             }
22              
23             __PACKAGE__->meta->make_immutable();