Console/Output.pm

filter: Statementstmt 28.5% 8 / 28 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 22.2% 2 / 9 Podpod 100% 7 / 7 totaltotal 28.8% 17 / 59 CC 8 SCAR 36.1
CC
8
Cov
19%
wrap
72.0
error
2.0
info
2.0
CRAP 36.9
↑ Summary Console.pm »
1 package Mojo::Console::Output;
2 2 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 has 'sameline' => 1;
7  
8 0 ▶sub error {
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
9 0 shift->wrap(@_, 'bright_red', 1);
10 }
11  
12 0 ▶sub info {
Subroutine info: not called CC=1 SCAR=6.9
Pod documented
13 0 shift->wrap(@_, 'bright_cyan');
14 }
15  
16 0 ▶sub line {
Subroutine line: not called CC=1 SCAR=6.9
Pod documented
17 0 shift->wrap(@_);
18 }
19  
20 0 ▶sub newline {
Subroutine newline: not called CC=1 SCAR=6.9
Pod documented
21 0 my $self = shift;
22  
23 0 my $sameline = $self->sameline;
24 0 $self->sameline(0);
25  
26 0 $self->wrap(@_);
27  
28 0 $self->sameline($sameline);
29 }
30  
31 0 ▶sub success {
Subroutine success: not called CC=1 SCAR=6.9
Pod documented
32 0 shift->wrap(@_, 'bright_green');
33 }
34  
35 0 ▶sub warn {
Subroutine warn: not called CC=1 SCAR=6.9
Pod documented
36 0 shift->wrap(@_, 'bright_yellow');
37 }
38  
39 0 ▶sub wrap {
Subroutine wrap: not called CC=8 SCAR=42.8
Pod documented
40 0 my ($self, $message, $color, $error) = @_;
41  
42 0 ▶ $error ||= 0;
Condition0%0/2
$error ||= 0
l!l
00
MC/DC0%0/1
$error ||= 0
$error
Truth table0%0/2
A
A= $error
Aresult
11
00
43  
44 0 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) { } 0 0 0
45 0 ▶ print STDERR color($color) if ($color);
Branch: 1 branch
BranchTrueFalseTotal
if $color 0 0 0
46 0 print STDERR $message;
47 0 ▶ print STDERR color('reset') if ($color);
Branch: 1 branch
BranchTrueFalseTotal
if $color 0 0 0
48  
49 0 exit;
50 } else {
51 0 ▶ print STDOUT color($color) if ($color);
Branch: 1 branch
BranchTrueFalseTotal
if $color 0 0 0
52 0 ▶ print STDOUT sprintf("%s%s", $message, ($self->sameline ? '' : "\n"));
Branch: 1 branch
BranchTrueFalseTotal
$self->sameline ? : 0 0 0
53 0 ▶ print STDOUT color('reset') if ($color);
Branch: 1 branch
BranchTrueFalseTotal
if $color 0 0 0
54 }
55 }
56  
57 2 1;
58  
59 =encoding utf8
60  
61 =head1 NAME
62  
63 Mojo::Console::Output - write things to STDOUT / STDERR
64  
65 =head1 METHODS
66  
67 L<Mojo::Console::Output> inherits all methods from L<Mojo::Base> and implements
68 the following new ones.
69  
70 =head2 error
71  
72 $self->error("The program will stop here");
73  
74 =head2 info
75  
76 $self->info("This is just an info message");
77  
78 =head2 line
79  
80 $self->line("This message will not have a new line at the end");
81  
82 =head2 newline
83  
84 $self->line("This message will have a new line at the end");
85  
86 =head2 success
87  
88 $self->success("This is just a success message");
89  
90 =head2 warn
91  
92 $self->success("This is just a warning message");
93  
94 =head2 wrap
95  
96 $self->wrap("Message", "color", 1/0);
97  
98 =cut
↑ Summary Console.pm »