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.339';
4             # ABSTRACT: Generic base class for outputting formatted messages.
5 5     5   2550 use 5.014;
  5         20  
6              
7 5     5   3233 use Term::ANSIColor qw/ colored /;
  5         77082  
  5         3892  
8 5     5   55 use Types::Standard -types;
  5         10  
  5         76  
9              
10 5     5   24373 use App::GitGot::Types;
  5         10  
  5         40  
11              
12 5     5   1068 use Moo;
  5         12  
  5         61  
13 5     5   2388 use namespace::autoclean;
  5         13  
  5         53  
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 96 my( $self , $message ) = @_;
26 3         12 return $self->_colored( $message , $self->color_error );
27             }
28              
29              
30             sub major_change {
31 8     8 1 8074 my( $self , $message ) = @_;
32 8         42 return $self->_colored( $message , $self->color_major_change );
33             }
34              
35              
36             sub minor_change {
37 9     9 1 12633 my( $self , $message ) = @_;
38 9         65 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   48 my( $self , $message , $color_string ) = @_;
49              
50 20 50 33     148 return ( $self->no_color || $color_string eq 'uncolored' ) ? $message
51             : colored( $message , $color_string );
52             }
53              
54             1;
55              
56             __END__