Lim/Component/CLI.pm

filter: Statementstmt 34.6% 17 / 49 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 38.4% 5 / 13 Podpod 100% 7 / 7 totaltotal 31.5% 29 / 92 SCAR 41.5
CC
11
Cov
24%
new
42.0
Error
12.0
DESTROY
6.0
CRAP 63.5
« Lim/Component/Client.pm ↑ Summary Lim/RPC/Protocols.pm »
1 package Lim::Component::CLI;
2  
3 1 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Log::Log4perl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Lim ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =encoding utf8
12  
13 =head1 NAME
14  
15 ...
16  
17 =head1 VERSION
18  
19 See L<Lim> for version.
20  
21 =cut
22  
23 1 our $VERSION = $Lim::VERSION;
24  
25 =head1 SYNOPSIS
26  
27 ...
28  
29 =head1 SUBROUTINES/METHODS
30  
31 =head2 new
32  
33 =cut
34  
35 sub new {
36 0 ▶ my $this = shift;
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
37 0 ▶ my $class = ref($this) || $this;
Condition0%0/3
ref $this || $this
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table0%0/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
38 0 my %args = ( @_ );
39 0 my $self = {
40 logger => Log::Log4perl->get_logger
41 };
42 0 bless $self, $class;
43  
44 0 ▶ unless (defined $args{cli}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"cli"}) 0 0 0
45 0 confess __PACKAGE__, ': Missing cli';
46 }
47 0 $self->{cli} = delete $args{cli};
48 0 weaken($self->{cli});
49  
50 0 eval {
51 0 $self->Init(%args);
52 };
53 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
54 0 ▶ Lim::WARN and $self->{logger}->warn('Unable to initialize module '.$class.': '.$@);
Branch: 1 branch
BranchTrueFalseTotal
Lim::WARN() and $self->{"logger"}->warn('Unable to initialize module ' . $class . ': ' . $@) 0 0 0
55 0 return;
56 }
57
58 0 ▶ Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self);
Branch: 1 branch
BranchTrueFalseTotal
Lim::OBJ_DEBUG() and $self->{"logger"}->debug("new ", __PACKAGE__, " ", $self) 0 0 0
59 0 $self;
60 }
61  
62 sub DESTROY {
63 0 ▶ my ($self) = @_;
Subroutine DESTROY: not called CC=2 SCAR=17.9
64 0 ▶ Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self);
Branch: 1 branch
BranchTrueFalseTotal
Lim::OBJ_DEBUG() and $self->{"logger"}->debug("destroy ", __PACKAGE__, " ", $self) 0 0 0
65
66 0 $self->Destroy;
67 }
68  
69 =head2 Init
70  
71 =cut
72  
73 ▶sub Init {
Subroutine Init: not called CC=1 SCAR=0.0
Pod documented
74 }
75  
76 =head2 Destroy
77  
78 =cut
79  
80 ▶sub Destroy {
Subroutine Destroy: not called CC=1 SCAR=0.0
Pod documented
81 }
82  
83 =head2 cli
84  
85 =cut
86  
87 sub cli {
88 0 ▶ $_[0]->{cli};
Subroutine cli: not called CC=1 SCAR=6.9
Pod documented
89 }
90  
91 =head2 Prompt
92  
93 =cut
94  
95 sub Prompt {
96 0 ▶ my ($self) = @_;
Subroutine Prompt: not called CC=2 SCAR=17.9
Pod documented
97
98 0 ▶ if (ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) 0 0 0
99 0 $self = ref($self);
100 }
101 0 $self =~ s/::[^:]+$//o;
102
103 0 return '/'.lc($self->Name);
104 }
105  
106 =head2 Successful
107  
108 =cut
109  
110 sub Successful {
111 0 ▶ my ($self) = @_;
Subroutine Successful: not called CC=2 SCAR=17.9
Pod documented
112
113 0 ▶ if (defined $self->{cli}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"cli"}) 0 0 0
114 0 $self->{cli}->Successful;
115 }
116 }
117  
118 =head2 Error
119  
120 =cut
121  
122 sub Error {
123 0 ▶ my $self = shift;
Subroutine Error: not called CC=3 SCAR=24.8
Pod documented
124
125 0 ▶ if (defined $self->{cli}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'cli'}) { } 0 0 0
126 0 $self->{cli}->Error(@_);
127 }
128 else {
129 0 ▶ Lim::ERR and $self->{logger}->error('Command returned error but CLI is gone [', $self, ']');
Branch: 1 branch
BranchTrueFalseTotal
Lim::ERR() and $self->{"logger"}->error("Command returned error but CLI is gone [", $self, "]") 0 0 0
130 }
131 }
132  
133 =head1 AUTHOR
134  
135 Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >>
136  
137 =head1 BUGS
138  
139 Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>.
140  
141 =head1 SUPPORT
142  
143 You can find documentation for this module with the perldoc command.
144  
145 perldoc Lim
146  
147 You can also look for information at:
148  
149 =over 4
150  
151 =item * Lim issue tracker (report bugs here)
152  
153 L<https://github.com/jelu/lim/issues>
154  
155 =back
156  
157 =head1 ACKNOWLEDGEMENTS
158  
159 =head1 LICENSE AND COPYRIGHT
160  
161 Copyright 2012-2013 Jerry Lundström.
162  
163 This program is free software; you can redistribute it and/or modify it
164 under the terms of either: the GNU General Public License as published
165 by the Free Software Foundation; or the Artistic License.
166  
167 See http://dev.perl.org/licenses/ for more information.
168  
169  
170 =cut
171  
172 1 1; # End of Lim::Component::CLI
« Lim/Component/Client.pm ↑ Summary Lim/RPC/Protocols.pm »