blib/lib/Thrift/UnixSocket.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 55 CC 2 SCAR 10.0
CC
2
Cov
0%
__open
6.0
new
2.0
BEGIN
2.0
CRAP 2.7
1 #
2 # Licensed to the Apache Software Foundation (ASF) under one
3 # or more contributor license agreements. See the NOTICE file
4 # distributed with this work for additional information
5 # regarding copyright ownership. The ASF licenses this file
6 # to you under the Apache License, Version 2.0 (the
7 # "License"); you may not use this file except in compliance
8 # with the License. You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing,
13 # software distributed under the License is distributed on an
14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 # KIND, either express or implied. See the License for the
16 # specific language governing permissions and limitations
17 # under the License.
18 #
19  
20 use 5.10.0;
21 use strict;
22 use warnings;
23  
24 use Thrift;
25 use Thrift::Socket;
26  
27 use IO::Socket::UNIX;
28  
29 package Thrift::UnixSocket;
30 use base qw( Thrift::Socket );
31 use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
32  
33 #
34 # Constructor.
35 # Takes a unix domain socket filename.
36 # See Thrift::Socket for base class parameters.
37 # @param[in] path path to unix socket file
38 # @example my $sock = Thrift::UnixSocket->new($path);
39 #
40 sub new
41 {
42 my $classname = shift;
43 my $self = $classname->SUPER::new();
44 $self->{path} = shift;
45 return bless($self, $classname);
46 }
47  
48 sub __open
49 {
50 my $self = shift;
51  
52 my $sock = IO::Socket::UNIX->new(
53 Type => IO::Socket::SOCK_STREAM,
54 Peer => $self->{path})
55 || do {
56 my $error = 'UnixSocket: Could not connect to ' .
57 $self->{path} . ' (' . $! . ')';
58 if ($self->{debug}) {
59 $self->{debugHandler}->($error);
60 }
61 die Thrift::TTransportException->new($error, Thrift::TTransportException::NOT_OPEN);
62 };
63  
64 return $sock;
65 }
66  
67 1;