File Coverage

blib/lib/App/CSE/Colorizer.pm
Criterion Covered Total %
statement 9 10 90.0
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 14 16 87.5


line stmt bran cond sub pod time code
1             package App::CSE::Colorizer;
2             $App::CSE::Colorizer::VERSION = '0.015';
3 11     11   73 use Moose;
  11         21  
  11         60  
4              
5             has 'cse' => ( is => 'ro' , isa => 'App::CSE', required => 1);
6              
7 11     11   70543 use Term::ANSIColor qw//;
  11         83914  
  11         1083  
8              
9             =head2 colored
10              
11             Returns a colored text only in an interactive environment.
12              
13             =cut
14              
15             sub colored{
16 1     1 1 23 my ($self, $text, $ansi_color_def) = @_;
17 1 50       24 if( $self->cse->interactive() ){
18 0         0 return Term::ANSIColor::colored($text, $ansi_color_def);
19             }
20 1         8 return $text;
21             }
22              
23             __PACKAGE__->meta->make_immutable();