File Coverage

blib/lib/App/GitGot/Outputter.pm
Criterion Covered Total %
statement 25 27 92.5
branch 1 2 50.0
condition 1 3 33.3
subroutine 10 11 90.9
pod 4 4 100.0
total 41 47 87.2


line stmt bran cond sub pod time code
1             package App::GitGot::Outputter;
2             our $AUTHORITY = 'cpan:GENEHACK';
3             $App::GitGot::Outputter::VERSION = '1.336';
4             # ABSTRACT: Generic base class for outputting formatted messages.
5 5     5   1909 use 5.014;
  5         14  
6              
7 5     5   2454 use Term::ANSIColor qw/ colored /;
  5         56218  
  5         2775  
8 5     5   35 use Types::Standard -types;
  5         9  
  5         29  
9              
10 5     5   18688 use App::GitGot::Types;
  5         9  
  5         40  
11              
12 5     5   754 use Moo;
  5         9  
  5         27  
13 5     5   1611 use namespace::autoclean;
  5         8  
  5         47  
14              
15              
16             has no_color => (
17             is => 'ro' ,
18             isa => Bool ,
19             default => 0 ,
20             documentation => 'boolean indicating whether color messages should be output at all' ,
21             );
22              
23              
24             sub error {
25 3     3 1 76 my( $self , $message ) = @_;
26 3         10 return $self->_colored( $message , $self->color_error );
27             }
28              
29              
30             sub major_change {
31 8     8 1 6285 my( $self , $message ) = @_;
32 8         27 return $self->_colored( $message , $self->color_major_change );
33             }
34              
35              
36             sub minor_change {
37 9     9 1 9067 my( $self , $message ) = @_;
38 9         31 return $self->_colored( $message , $self->color_minor_change );
39             }
40              
41              
42             sub warning {
43 0     0 1 0 my( $self , $message ) = @_;
44 0         0 return $self->_colored( $message , $self->color_warning );
45             }
46              
47             sub _colored {
48 20     20   38 my( $self , $message , $color_string ) = @_;
49              
50 20 50 33     108 return ( $self->no_color || $color_string eq 'uncolored' ) ? $message
51             : colored( $message , $color_string );
52             }
53              
54             1;
55              
56             __END__