Lim/RPC/TLS.pm

filter: Statementstmt 55.5% 25 / 45 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 66.6% 8 / 12 Podpod 100% 3 / 3 totaltotal 43.9% 36 / 82 CC 9 SCAR 30.6
CC
9
Cov
40%
new
56.0
DESTROY
6.0
instance
6.0
CRAP 21.3
« Lim/RPC/Protocol/SOAP.pm ↑ Summary Lim/RPC/Transports.pm »
1 package Lim::RPC::TLS;
2  
3 6 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶use Log::Log4perl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶use AnyEvent::TLS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Net::SSLeay ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 ▶use Lim ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 =encoding utf8
15  
16 =head1 NAME
17  
18 ...
19  
20 =head1 VERSION
21  
22 See L<Lim> for version.
23  
24 =cut
25  
26 6 our $VERSION = $Lim::VERSION;
27 6 our $INSTANCE;
28  
29 =head1 SYNOPSIS
30  
31 ...
32  
33 =head1 SUBROUTINES/METHODS
34  
35 =head2 new
36  
37 =cut
38  
39 0 ▶sub new {
Subroutine new: not called CC=7 SCAR=40.3
Pod documented
40 0 my $this = shift;
41 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
42 0 my $self = {
43 logger => Log::Log4perl->get_logger($class),
44 };
45 0 bless $self, $class;
46 0 weaken($self->{logger});
47  
48 0 eval {
49 0 ▶ if (!defined Lim::Config->{rpc}->{tls}->{key_file}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined &Lim::Config()->{'rpc'}{'tls'}{'key_file'}) { } 0 0 0
elsif (not defined &Lim::Config()->{'rpc'}{'tls'}{'cert_file'}) { } 0 0 0
50 0 $@ = 'No key_file set';
51 }
52 elsif (!defined Lim::Config->{rpc}->{tls}->{cert_file}) {
53 0 $@ = 'No cert_file set';
54 }
55 else {
56 0 $self->{tls_ctx} = AnyEvent::TLS->new(%{Lim::Config->{rpc}->{tls}});
57 }
58 };
59 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
60 0 ▶ Lim::OBJ_DEBUG and $self->{logger}->debug('Unable to initialize TLS context, will not use TLS/SSL: ', $@);
Branch: 1 branch
BranchTrueFalseTotal
Lim::OBJ_DEBUG() and $self->{"logger"}->debug("Unable to initialize TLS context, will not use TLS/SSL: ", $@) 0 0 0
61 0 $self->{tls_ctx} = undef;
62 }
63  
64 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
65 0 $self;
66 }
67  
68 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=2 SCAR=17.9
69 0 my ($self) = @_;
70 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
71 }
72  
73 6 ▶END {
Subroutine END: called CC=1 SCAR=0.0
74 6 undef($INSTANCE);
75 }
76  
77 =head2 instance
78  
79 =cut
80  
81 0 ▶sub instance {
Subroutine instance: not called CC=2 SCAR=17.9
Pod documented
82 0 ▶ $INSTANCE ||= Lim::RPC::TLS->new;
Condition0%0/3
$Lim::RPC::TLS::INSTANCE ||= "Lim::RPC::TLS"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$Lim::RPC::TLS::INSTANCE ||= "Lim::RPC::TLS"->new
$Lim::RPC::TLS::INSTANCE "Lim::RPC::TLS"->new
Truth table0%0/3
A ||= B
A= $Lim::RPC::TLS::INSTANCEB= "Lim::RPC::TLS"->new
ABresult
1X1
011
000
83 }
84  
85 =head2 tls_ctx
86  
87 =cut
88  
89 0 ▶sub tls_ctx {
Subroutine tls_ctx: not called CC=1 SCAR=6.9
Pod documented
90 0 $_[0]->{tls_ctx};
91 }
92  
93 =head1 AUTHOR
94  
95 Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >>
96  
97 =head1 BUGS
98  
99 Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>.
100  
101 =head1 SUPPORT
102  
103 You can find documentation for this module with the perldoc command.
104  
105 perldoc Lim
106  
107 You can also look for information at:
108  
109 =over 4
110  
111 =item * Lim issue tracker (report bugs here)
112  
113 L<https://github.com/jelu/lim/issues>
114  
115 =back
116  
117 =head1 ACKNOWLEDGEMENTS
118  
119 =head1 LICENSE AND COPYRIGHT
120  
121 Copyright 2012-2013 Jerry Lundström.
122  
123 This program is free software; you can redistribute it and/or modify it
124 under the terms of either: the GNU General Public License as published
125 by the Free Software Foundation; or the Artistic License.
126  
127 See http://dev.perl.org/licenses/ for more information.
128  
129  
130 =cut
131  
132 6 1; # End of Lim::RPC::TLS
« Lim/RPC/Protocol/SOAP.pm ↑ Summary Lim/RPC/Transports.pm »