blib/lib/Horris.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 59 CC 4 SCAR 21.5
CC
4
Cov
0%
_build_connections
20.0
_build_condvar
2.0
run
2.0
CRAP 8.5
1 package Horris;
2 # ABSTRACT: An IRC Bot Based On Moose/AnyEvent - forked L<Morris>
3  
4  
5 use Moose;
6 use AnyEvent;
7 use Const::Fast;
8 use Horris::Connection;
9 use namespace::clean -except => qw/meta/;
10  
11 const our $DEBUG => $ENV{PERL_HORRIS_DEBUG};
12  
13 has condvar => (
14 is => 'ro',
15 lazy_build => 1,
16 );
17  
18 has connections => (
19 traits => ['Array'],
20 is => 'ro',
21 isa => 'ArrayRef[Horris::Connection]',
22 lazy_build => 1,
23 handles => {
24 all_connections => 'elements',
25 push_connection => 'push',
26 },
27 );
28  
29 has config => (
30 is => 'ro',
31 isa => 'HashRef',
32 required => 1,
33 );
34  
35 sub _build_condvar { AnyEvent->condvar }
36 sub _build_connections {
37 my ($self) = @_;
38 my @connections;
39 while (my ($name, $conn) = each %{$self->{config}{connection}}) {
40 confess "No network specified for connection '$name'" unless $conn->{network};
41 print "Connection Name: $name\n" if $Horris::DEBUG;
42  
43 my $network = $self->{config}{network}->{ $conn->{network} };
44 my $connection = Horris::Connection->new({
45 %$network,
46 %$conn,
47 plugins => $conn->{loadmodule} ? $conn->{loadmodule} : [],
48 });
49 push @connections, $connection;
50 }
51  
52 return \@connections;
53 }
54  
55 sub run {
56 my $self = shift;
57 my $cv = $self->condvar;
58 $cv->begin;
59 foreach my $conn ($self->all_connections) {
60 $conn->run;
61 }
62  
63 $cv->recv;
64 }
65  
66 __PACKAGE__->meta->make_immutable;
67  
68 1;
69  
70 __END__