| 1 | package App::JESP::Colorizer; | ||||||||||
| 2 | 8 | $App::JESP::Colorizer::VERSION = '0.016'; | |||||||||
| 3 | 8 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 8 | has 'jesp' => ( is => 'ro' , isa => 'App::JESP', required => 1); | |||||||||
| 6 | |||||||||||
| 7 | 8 | ▶ | use Term::ANSIColor qw//; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | =head2 colored | ||||||||||
| 10 | |||||||||||
| 11 | Returns a colored text only in an interactive environment. | ||||||||||
| 12 | |||||||||||
| 13 | =cut | ||||||||||
| 14 | |||||||||||
| 15 | 26 | ▶ | sub colored{ | ||||||||
|
Subroutine
colored: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 16 | 26 | my ($self, $text, $ansi_color_def) = @_; | |||||||||
| 17 | 26 | ▶ | if( $self->jesp->interactive() ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 1 | return Term::ANSIColor::colored($text, $ansi_color_def); | |||||||||
| 19 | } | ||||||||||
| 20 | 25 | return $text; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 8 | __PACKAGE__->meta->make_immutable(); | |||||||||