blib/lib/Circle.pm

filter: Statementstmt 76.6% 46 / 60 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 25.0% 1 / 4 totaltotal 74.3% 61 / 82 SCAR 14.5
CC
4
Cov
74%
new
3.0
make_local_client
2.7
warn
2.0
CRAP 4.3
« blib/lib/Circle/Widget/Box.pm ↑ Summary blib/lib/Circle/Widget.pm »
1 # You may distribute under the terms of the GNU General Public License
2 #
3 # (C) Paul Evans, 2008-2014 -- leonerd@leonerd.org.uk
4  
5 package Circle;
6  
7 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use base qw( Net::Async::Tangence::Server );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 IO::Async::Notifier->VERSION( '0.43' ); # ->loop
11 4 Net::Async::Tangence::Server->VERSION( '0.12' ); # subclass of IaListener
12  
13 4 our $VERSION = '0.142470';
14  
15 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 ▶use Tangence::Registry 0.20; # Support for late-loading classes
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use Circle::RootObj;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 4 ▶use File::ShareDir qw( module_file );
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 4 ▶use IO::Async::OS;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =head1 NAME
25  
26 C<Circle> - server backend for the C<Circle> application host
27  
28 =cut
29  
30 sub new
31 {
32 3 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=11.1
Pod documented
33 3 my %args = @_;
34  
35 3 ▶ my $loop = $args{loop} or croak "Need a loop";
Branch: 1 branch
BranchTrueFalseTotal
my $loop = $args{"loop"} or croak("Need a loop") 0 3 3
36  
37 3 my $registry = Tangence::Registry->new(
38 tanfile => module_file( __PACKAGE__, "circle.tan" ),
39 );
40  
41 3 my $rootobj = $registry->construct(
42 "Circle::RootObj",
43 loop => $loop
44 );
45 3 ▶ $rootobj->id == 1 or die "Assert failed: root object does not have ID 1";
Branch: 1 branch
BranchTrueFalseTotal
$rootobj->id == 1 or die "Assert failed: root object does not have ID 1" 0 3 3
46  
47 3 my $self = $class->SUPER::new(
48 registry => $registry,
49 );
50  
51 3 $loop->add( $self );
52  
53 3 $self->{rootobj} = $rootobj;
54  
55 3 return $self;
56 }
57  
58 sub make_local_client
59 {
60 3 ▶ my $self = shift;
Subroutine make_local_client: called CC=2 SCAR=10.1
Pod undocumented
61  
62 3 my $loop = $self->loop;
63  
64 3 ▶ my ( $S1, $S2 ) = IO::Async::OS->socketpair or die "Cannot socketpair - $!";
Branch: 1 branch
BranchTrueFalseTotal
() = "IO::Async::OS"->socketpair or die "Cannot socketpair - $!" 0 3 3
65  
66 # Internal hackery; stolen from IaListener
67 3 my $acceptor = $self->acceptor;
68 3 my $handle = $self->{new_handle}->( $self );
69 0 $S1->blocking( 0 );
70 0 $handle->set_handle( $S1 );
71 0 $self->on_accept( $handle );
72  
73 0 require Net::Async::Tangence::Client;
74 0 my $client = Net::Async::Tangence::Client->new(
75 handle => $S2,
76 identity => "test_client",
77 );
78  
79 0 $loop->add( $client );
80  
81 0 return $client;
82 }
83  
84 sub new_with_client
85 {
86 3 ▶ my $class = shift;
Subroutine new_with_client: called CC=1 SCAR=0.2
Pod undocumented
87  
88 3 my $self = $class->new( @_ );
89  
90 3 my $client = $self->make_local_client;
91  
92 0 return ( $self, $client );
93 }
94  
95 sub warn
96 {
97 0 ▶ my $self = shift;
Subroutine warn: not called CC=1 SCAR=6.9
Pod undocumented
98 0 my $text = join " ", @_;
99 0 chomp $text;
100  
101 0 my $rootobj = $self->{rootobj};
102 0 $rootobj->push_displayevent( warning => { text => $text } );
103 0 $rootobj->bump_level( 2 );
104 }
105  
106 =head1 AUTHOR
107  
108 Paul Evans <leonerd@leonerd.org.uk>
109  
110 =cut
111  
112 4 0x55AA;
« blib/lib/Circle/Widget/Box.pm ↑ Summary blib/lib/Circle/Widget.pm »