lib/Devel/Trepan/CmdProcessor/Msg.pm

filter: Statementstmt 41.3% 48 / 116 Branchbran 16.6% 9 / 54 Conditioncond 14.2% 5 / 35 MC/DCmcdc 0.0% 0 / 22 Subroutinesub 44.4% 12 / 27 Podpod 0.0% 0 / 20 totaltotal 27.0% 74 / 274 CC 39 SCAR 24.3
CC
39
Cov
30%
errmsg
24.9
errmsg
24.9
section
13.1
CRAP 11.3
« blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Return.pm ↑ Summary blib/lib/Devel/Trepan/Condition.pm »
1 # Copyright (C) 2011-2012, 2015 Rocky Bernstein <rocky@cpan.org>
2 # I/O related command processor methods
3  
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 12 ▶use rlib '../../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 require Devel::Trepan::Util;
12 12 require Devel::Trepan::CmdProcessor;
13 package Devel::Trepan::CmdProcessor;
14  
15 # # Because we use Exporter we want to silence:
16 # # Use of inherited AUTOLOAD for non-method ... is deprecated
17 # sub AUTOLOAD
18 # {
19 # my $name = our $AUTOLOAD;
20 # $name =~ s/.*:://; # lose package name
21 # my $target = "DynaLoader::$name";
22 # goto &$target;
23 # }
24  
25  
26 12 ▶use vars qw(@EXPORT @ISA $HAVE_TERM_ANSIColor);
Subroutine BEGIN: called CC=1 SCAR=0.0
27 12 @ISA = qw(Exporter);
28  
29 12 ▶$HAVE_TERM_ANSIColor = eval "use Term::ANSIColor; 1";
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 # attr_accessor :ruby_highlighter
32  
33 sub confirm($$$)
34 0 ▶{
Subroutine confirm: not called CC=3 SCAR=24.8
Pod undocumented
35 0 ▶ my ($self, $msg, $default) = @_;
Subroutine confirm: not called CC=3 SCAR=24.8
Pod undocumented
36 0 my $intf = $self->{interfaces}[-1];
37 my $confirmed = $self->{settings}{confirm} ?
38 0 ▶ $intf->confirm($msg, $default) : 1;
Branch: 2 branches
BranchTrueFalseTotal
$self->{'settings'}{'confirm'} ? : 0 0 0
$self->{'settings'}{'confirm'} ? : 0 0 0
39 0 ▶ $intf->remove_history unless $confirmed;
Branch: 2 branches
BranchTrueFalseTotal
unless $confirmed 0 0 0
unless $confirmed 0 0 0
40 0 $confirmed;
41 }
42  
43 2 ▶sub errmsg($$;$) {
Subroutine errmsg: called CC=7 SCAR=32.1
Pod undocumented
44 0 ▶ my($self, $message, $opts) = @_;
Subroutine errmsg: not called CC=7 SCAR=32.1
Pod undocumented
45 0 ▶ $opts ||={};
Condition25%1/4
$opts ||= {}
l!l
02
$opts ||= {}
l!l
00
MC/DC0%0/1
$opts ||= {}
$opts
MC/DC0%0/1
$opts ||= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
Truth table0%0/2
A
A= $opts
Aresult
11
00
46 0 ▶ if (ref($message) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $message eq 'ARRAY') { } 0 2 2
if (ref $message eq 'ARRAY') { } 0 0 0
47 0 foreach my $mess (@$message) {
48 0 $self->errmsg($mess, $opts)
49 }
50 0 return;
51 } else {
52 0 ▶ $message = $self->safe_rep($message) unless $self->{opts}{unlimited};
Branch: 2 branches
BranchTrueFalseTotal
unless $self->{"opts"}{"unlimited"} 2 0 2
unless $self->{"opts"}{"unlimited"} 0 0 0
53 }
54 0 ▶ if ($self->{settings}{highlight} && $HAVE_TERM_ANSIColor) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor) 2 0 2
if ($self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor) 0 0 0
Condition16%1/6
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
!ll&&!rl&&r
002
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
$self->{"settings"}{"highlight"} $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
MC/DC0%0/2
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
$self->{"settings"}{"highlight"} $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
Truth table33%1/3
A and B
A= $self->{"settings"}{"highlight"}B= $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $self->{"settings"}{"highlight"}B= $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
ABresult
0X0
100
111
55 0 $message = color('underscore') . $message . color('reset');
56 }
57 0 $self->{interfaces}[-1]->errmsg($message);
58 }
59  
60 3 ▶sub msg($$;$) {
Subroutine msg: called CC=3 SCAR=16.8
Pod undocumented
61 0 ▶ my($self, $message, $opts) = @_;
Subroutine msg: not called CC=3 SCAR=16.8
Pod undocumented
62 0 ▶ $message = $self->safe_rep($message) unless $opts->{unlimited};
Branch: 2 branches
BranchTrueFalseTotal
unless $opts->{"unlimited"} 3 0 3
unless $opts->{"unlimited"} 0 0 0
63 # $message = $self->perl_format($message) if $opts->{code};
64 $self->{interfaces}[-1]->msg($message) if
65 0 ▶ defined $self->{interfaces}[-1];
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->{"interfaces"}[-1] 3 0 3
if defined $self->{"interfaces"}[-1] 0 0 0
66  
67 }
68  
69 0 ▶sub msg_need_running($$;$) {
Subroutine msg_need_running: not called CC=1 SCAR=6.9
Pod undocumented
70 0 ▶ my($self, $prefix, $opts) = @_;
Subroutine msg_need_running: not called CC=1 SCAR=6.9
Pod undocumented
71 0 $self->errmsg("$prefix not available when terminated");
72 }
73  
74 0 ▶sub msg_nocr($$;$) {
Subroutine msg_nocr: not called CC=2 SCAR=17.9
Pod undocumented
75 0 ▶ my($self, $message, $opts) = @_;
Subroutine msg_nocr: not called CC=2 SCAR=17.9
Pod undocumented
76 0 ▶ $message = $self->safe_rep($message) unless $self->{opts}{unlimited};
Branch: 2 branches
BranchTrueFalseTotal
unless $self->{"opts"}{"unlimited"} 0 0 0
unless $self->{"opts"}{"unlimited"} 0 0 0
77 # $message = $self->perl_format($message) if $self->{opts}{code};
78 0 $self->{interfaces}[-1]->msg_nocr($message);
79  
80 }
81  
82 0 ▶sub read_command($) {
Subroutine read_command: not called CC=1 SCAR=6.9
Pod undocumented
83 0 ▶ my $self = shift;
Subroutine read_command: not called CC=1 SCAR=6.9
Pod undocumented
84 0 $self->{interfaces}[-1]->read_command($self->{prompt});
85 }
86  
87 # sub perl_format($$) {
88 # my($self, $text);
89 # return $text unless $self->settings{highlight};
90 # unless @ruby_highlighter
91 # begin
92 # require 'coderay'
93 # require 'term/ansicolor'
94 # @ruby_highlighter = CodeRay::Duo[:ruby, :term]
95 # rescue LoadError
96 # return text
97 # }
98 # }
99 # return @ruby_highlighter.encode(text)
100 # }
101  
102 7 ▶sub safe_rep($$) {
Subroutine safe_rep: called CC=1 SCAR=1.2
Pod undocumented
103 0 ▶ my($self, $str) = @_;
Subroutine safe_rep: not called CC=1 SCAR=1.2
Pod undocumented
104 0 Devel::Trepan::Util::safe_repr($str, $self->{settings}{maxstring});
105 }
106  
107 2 ▶sub bolden($$) {
Subroutine bolden: called CC=3 SCAR=18.5
Pod undocumented
108 0 ▶ my($self, $message) = @_;
Subroutine bolden: not called CC=3 SCAR=18.5
Pod undocumented
109 0 ▶ if ($self->{settings}{highlight} && $HAVE_TERM_ANSIColor) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'settings'}{'highlight'} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor) { } 2 0 2
if ($self->{'settings'}{'highlight'} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor) { } 0 0 0
Condition16%1/6
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
!ll&&!rl&&r
002
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
$self->{"settings"}{"highlight"} $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
MC/DC0%0/2
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
$self->{"settings"}{"highlight"} $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
Truth table33%1/3
A and B
A= $self->{"settings"}{"highlight"}B= $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $self->{"settings"}{"highlight"}B= $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
ABresult
0X0
100
111
110 0 return $message = color('bold') . $message . color('reset');
111 } else {
112 0 return $message
113 }
114 }
115  
116 0 ▶sub underline($$) {
Subroutine underline: not called CC=3 SCAR=24.8
Pod undocumented
117 0 ▶ my($self, $message) = @_;
Subroutine underline: not called CC=3 SCAR=24.8
Pod undocumented
118 0 ▶ if ($self->{settings}{highlight} && $HAVE_TERM_ANSIColor) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'settings'}{'highlight'} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor) { } 0 0 0
if ($self->{'settings'}{'highlight'} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor) { } 0 0 0
Condition0%0/6
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
!ll&&!rl&&r
000
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
$self->{"settings"}{"highlight"} $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
MC/DC0%0/2
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
$self->{"settings"}{"highlight"} $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
Truth table0%0/3
A and B
A= $self->{"settings"}{"highlight"}B= $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $self->{"settings"}{"highlight"}B= $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
ABresult
0X0
100
111
119 0 return $message = color('underscore') . $message . color('reset');
120 } else {
121 0 return $message
122 }
123 }
124  
125 2 ▶sub section($$;$) {
Subroutine section: called CC=5 SCAR=25.7
Pod undocumented
126 0 ▶ my($self, $message, $opts) = @_;
Subroutine section: not called CC=5 SCAR=25.7
Pod undocumented
127 0 ▶ $opts ||= {};
Condition25%1/4
$opts ||= {}
l!l
20
$opts ||= {}
l!l
00
MC/DC0%0/1
$opts ||= {}
$opts
MC/DC0%0/1
$opts ||= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
Truth table0%0/2
A
A= $opts
Aresult
11
00
128 0 ▶ $message = $self->safe_rep($message) unless $self->{opts}{unlimited};
Branch: 2 branches
BranchTrueFalseTotal
unless $self->{"opts"}{"unlimited"} 2 0 2
unless $self->{"opts"}{"unlimited"} 0 0 0
129 0 ▶ if ($self->{settings}{highlight} && $HAVE_TERM_ANSIColor) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'settings'}{'highlight'} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor) { } 2 0 2
if ($self->{'settings'}{'highlight'} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor) { } 0 0 0
Condition16%1/6
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
!ll&&!rl&&r
002
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
$self->{"settings"}{"highlight"} $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
MC/DC0%0/2
$self->{"settings"}{"highlight"} and $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
$self->{"settings"}{"highlight"} $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
Truth table33%1/3
A and B
A= $self->{"settings"}{"highlight"}B= $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $self->{"settings"}{"highlight"}B= $Devel::Trepan::CmdProcessor::HAVE_TERM_ANSIColor
ABresult
0X0
100
111
130 0 $message = $self->bolden($message);
131 } else {
132 0 $message .= "\n" . '-' x length($message);
133 }
134 0 $self->{interfaces}[-1]->msg($message);
135 }
136  
137 12 ▶if (__FILE__ eq $0) {
Branch: 1 branch
BranchTrueFalseTotal
if (__FILE__ eq $0) 0 12 12
138 0 require Devel::Trepan::CmdProcessor;
139 0 my $proc = Devel::Trepan::CmdProcessor->new;
140 0 ▶ if (scalar(@ARGV) > 0 && $proc->{interfaces}[-1]->is_interactive) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @ARGV > 0 and $proc->{"interfaces"}[-1]->is_interactive) 0 0 0
Condition0%0/3
scalar @ARGV > 0 and $proc->{"interfaces"}[-1]->is_interactive
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @ARGV > 0 and $proc->{"interfaces"}[-1]->is_interactive
scalar @ARGV > 0 $proc->{"interfaces"}[-1]->is_interactive
Truth table0%0/3
A and B
A= scalar @ARGV > 0B= $proc->{"interfaces"}[-1]->is_interactive
ABresult
0X0
100
111
141 0 my $response = $proc->confirm("Are you sure?", 1);
142 0 ▶ printf "You typed: %s\n", $response ? "Y" : "N";
Branch: 1 branch
BranchTrueFalseTotal
$response ? : 0 0 0
143 }
144 }
145  
146 12 1;
« blib/lib/Devel/Trepan/CmdProcessor/Command/Set_Subcmd/Return.pm ↑ Summary blib/lib/Devel/Trepan/Condition.pm »