blib/lib/App/karr/Role/Color.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 60 CC 8 SCAR 30.6
CC
8
Cov
0%
_effective_color
30.0
_want_color
20.0
BEGIN
2.0
CRAP 21.3
1 # ABSTRACT: Shared colour decision for the renderers that colour their output
2  
3 package App::karr::Role::Color;
4 our $VERSION = '0.602';
5 use Moo::Role;
6 use MooX::Options;
7  
8  
9 option color => (
10 is => 'ro',
11 negatable => 1,
12 doc => 'Colour output; --no-color disables it for this invocation',
13 );
14  
15 sub _effective_color {
16 my ($self) = @_;
17 return 0 if defined $self->color && !$self->color;
18 if ( $self->can('command_chain') && ( my $chain = $self->command_chain ) ) {
19 for my $cmd (@$chain) {
20 next if $cmd == $self;
21 return 0 if $cmd->can('color') && defined $cmd->color && !$cmd->color;
22 }
23 }
24 return 1;
25 }
26  
27 sub _want_color {
28 my ($self) = @_;
29 return 0 unless $self->_effective_color;
30 return 0 if $ENV{NO_COLOR};
31 return -t STDOUT ? 1 : 0;
32 }
33  
34 1;
35  
36 __END__