File Coverage

blib/lib/IPC/PubSub.pm
Criterion Covered Total %
statement 33 38 86.8
branch 4 6 66.6
condition 1 2 50.0
subroutine 11 16 68.7
pod 1 9 11.1
total 50 71 70.4


line stmt bran cond sub pod time code
1             package IPC::PubSub;
2             $IPC::PubSub::VERSION = '0.29';
3              
4 2     2   45848 use 5.006;
  2         8  
  2         70  
5 2     2   11 use strict;
  2         2  
  2         59  
6 2     2   8 use warnings;
  2         7  
  2         46  
7 2     2   1006 use IPC::PubSub::Cacheable;
  2         12  
  2         45  
8 2     2   981 use IPC::PubSub::Publisher;
  2         6  
  2         14  
9 2     2   1150 use IPC::PubSub::Subscriber;
  2         6  
  2         15  
10 2     2   64 use base qw/Class::Accessor::Fast/;
  2         3  
  2         870  
11              
12             __PACKAGE__->mk_accessors(qw/_cache/);
13              
14             sub new {
15 4     4 1 43336 my $self = bless {}, shift;
16              
17 4   50     23 my $backend = shift || 'PlainHash';
18              
19 4         8 local $@;
20 4 50       28 eval { require "IPC/PubSub/Cache/$backend.pm" }
  4         3495  
21             or die "Cannot load backend module: IPC::PubSub::Cache::$backend: $@";
22              
23 4         53 $self->_cache(IPC::PubSub::Cacheable->new($backend => \@_));
24 4         66 return $self;
25             }
26              
27             sub new_publisher {
28 6     6 0 7631 my $self = shift;
29 6 100       31 IPC::PubSub::Publisher->new($self->_cache, @_ ? @_ : '');
30             }
31              
32             sub new_subscriber {
33 4     4 0 26 my $self = shift;
34 4 50       12 IPC::PubSub::Subscriber->new($self->_cache, @_ ? @_ : '');
35             }
36              
37 0     0 0 0 sub fetch { ( +shift )->_cache->fetch(@_) }
38 0     0 0 0 sub store { ( +shift )->_cache->store(@_) }
39 0     0 0 0 sub lock { ( +shift )->_cache->lock(@_) }
40 0     0 0 0 sub unlock { ( +shift )->_cache->unlock(@_) }
41 12     12 0 45 sub modify { ( +shift )->_cache->modify(@_) }
42 0     0 0   sub disconnect { ( +shift )->_cache->disconnect }
43              
44             1;
45              
46             __END__