Lim/Component/Server.pm

filter: Statementstmt 75.4% 43 / 57 Branchbran 20.0% 4 / 20 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 92.8% 13 / 14 Podpod 100% 5 / 5 totaltotal 62.2% 66 / 106 CC 13 SCAR 21.5
CC
13
Cov
58%
Error
30.0
Successful
6.7
new
6.4
CRAP 8.6
« Lim/Agent/CLI.pm ↑ Summary Lim/RPC/Callback.pm »
1 package Lim::Component::Server;
2  
3 5 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Log::Log4perl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Scalar::Util qw(blessed weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use Lim ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Lim::RPC ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Lim::Error ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =encoding utf8
14  
15 =head1 NAME
16  
17 ...
18  
19 =head1 VERSION
20  
21 See L<Lim> for version.
22  
23 =cut
24  
25 5 our $VERSION = $Lim::VERSION;
26  
27 =head1 SYNOPSIS
28  
29 ...
30  
31 =head1 SUBROUTINES/METHODS
32  
33 =head2 new
34  
35 =cut
36  
37 4 ▶sub new {
Subroutine new: called CC=5 SCAR=18.5
Pod documented
38 4 my $this = shift;
39 4 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
040
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
40 4 my $self = {
41 logger => Log::Log4perl->get_logger($class),
42 };
43 4 bless $self, $class;
44 4 weaken($self->{logger});
45  
46 4 eval {
47 4 $self->Init(@_);
48 };
49 4 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
50 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
51 0 return;
52 }
53  
54 4 ▶ Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self);
Branch: 1 branch
BranchTrueFalseTotal
Lim::OBJ_DEBUG() and $self->{"logger"}->debug("new ", __PACKAGE__, " ", $self) 4 0 4
55 4 $self;
56 }
57  
58 4 ▶sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=7.1
59 4 my ($self) = @_;
60 4 ▶ Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self);
Branch: 1 branch
BranchTrueFalseTotal
Lim::OBJ_DEBUG() and $self->{"logger"}->debug("destroy ", __PACKAGE__, " ", $self) 4 0 4
61  
62 4 $self->Destroy;
63 }
64  
65 =head2 Init
66  
67 =cut
68  
69 4 ▶sub Init {
Subroutine Init: called CC=1 SCAR=0.0
Pod documented
70 }
71  
72 =head2 Destroy
73  
74 =cut
75  
76 4 ▶sub Destroy {
Subroutine Destroy: called CC=1 SCAR=0.0
Pod documented
77 }
78  
79 =head2 Successful
80  
81 =cut
82  
83 4 ▶sub Successful {
Subroutine Successful: called CC=4 SCAR=19.1
Pod documented
84 4 my ($self, $cb, $data) = @_;
85  
86 4 eval {
87 4 Lim::RPC::R($cb, $data);
88 };
89 4 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
90 0 ▶ Lim::WARN and $self->{logger}->warn('data validation failed: ', $@);
Branch: 1 branch
BranchTrueFalseTotal
Lim::WARN() and $self->{"logger"}->warn("data validation failed: ", $@) 0 0 0
91 0 ▶ Lim::DEBUG and eval {
Branch: 1 branch
BranchTrueFalseTotal
Lim::DEBUG() and eval { do { $self->{"logger"}->debug(Dumper($data)); $self->{"logger"}->debug(Dumper($cb->call_def->{"out"})) } } 0 0 0
92 5 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
93 0 $self->{logger}->debug(Dumper($data));
94 0 $self->{logger}->debug(Dumper($cb->call_def->{out}));
95 };
96 0 Lim::RPC::R($cb, Lim::Error->new());
97 }
98 }
99  
100 =head2 Error
101  
102 =cut
103  
104 0 ▶sub Error {
Subroutine Error: not called CC=5 SCAR=34.0
Pod documented
105 0 my ($self, $cb, $error, @rest) = @_;
106  
107 0 ▶ if (blessed($error) and $error->isa('Lim::Error')) {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($error) and $error->isa('Lim::Error')) { } 0 0 0
elsif (defined $error) { } 0 0 0
Condition0%0/3
builtin::blessed($error) and $error->isa("Lim::Error")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($error) and $error->isa("Lim::Error")
builtin::blessed($error) $error->isa("Lim::Error")
Truth table0%0/3
A and B
A= builtin::blessed($error)B= $error->isa("Lim::Error")
ABresult
0X0
100
111
108 0 Lim::RPC::R($cb, $error);
109 }
110 elsif (defined $error) {
111 0 ▶ if (scalar @rest) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @rest) 0 0 0
112 0 $error .= join('', @rest);
113 }
114 0 Lim::RPC::R($cb, Lim::Error->new(module => $self, message => $error));
115 }
116 else {
117 0 Lim::RPC::R($cb, Lim::Error->new(module => $self));
118 }
119 }
120  
121 =head1 AUTHOR
122  
123 Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >>
124  
125 =head1 BUGS
126  
127 Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>.
128  
129 =head1 SUPPORT
130  
131 You can find documentation for this module with the perldoc command.
132  
133 perldoc Lim
134  
135 You can also look for information at:
136  
137 =over 4
138  
139 =item * Lim issue tracker (report bugs here)
140  
141 L<https://github.com/jelu/lim/issues>
142  
143 =back
144  
145 =head1 ACKNOWLEDGEMENTS
146  
147 =head1 LICENSE AND COPYRIGHT
148  
149 Copyright 2012-2013 Jerry Lundström.
150  
151 This program is free software; you can redistribute it and/or modify it
152 under the terms of either: the GNU General Public License as published
153 by the Free Software Foundation; or the Artistic License.
154  
155 See http://dev.perl.org/licenses/ for more information.
156  
157  
158 =cut
159  
160 5 1; # End of Lim::RPC::Base
« Lim/Agent/CLI.pm ↑ Summary Lim/RPC/Callback.pm »