| 1 | package Devel::REPL::Client::AnyEvent; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Devel::REPL::Client::AnyEvent::Connection; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use AnyEvent::Socket; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Term::ReadKey; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use constant { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | EOT => "\x04", | |||||||||||||||||||||||||||
| 14 | 1 | }; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | my $RESTORE_READMODE; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | END { | ||||||||||||||||||||||||||||
| 19 | ReadMode 0, \*STDIN if $RESTORE_READMODE; | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 0 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 24 | my $self = bless { | ||||||||||||||||||||||||||||
| 25 | port => $args{port}, | ||||||||||||||||||||||||||||
| 26 | path => $args{path}, | ||||||||||||||||||||||||||||
| 27 | mode => $args{mode}, | ||||||||||||||||||||||||||||
| 28 | on_connection => $args{on_connection}, | ||||||||||||||||||||||||||||
| 29 | 0 | tcp_guard => undef, | |||||||||||||||||||||||||||
| 30 | }, $class; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | return $self; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub listen { | ||||||||||||||||||||||||||
|
Subroutine
listen: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my $weak_self = $self; | |||||||||||||||||||||||||||
| 39 | 0 | weaken($weak_self); | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | my $cb = sub { $weak_self->_new_connection($_[0]) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $prepare = ($self->{path} && defined $self->{mode}) ? sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 42 | chmod $weak_self->{mode}, $weak_self->{path} | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | or die "Unable to change file mode for socket: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | } : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"path"} and defined $self->{"mode"}
MC/DC0%0/2
$self->{"path"} and defined $self->{"mode"}
$self->{"path"}
defined $self->{"mode"}
Truth table0%0/3
A and B
A= $self->{"path"}B= defined $self->{"mode"}
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ($self->{port}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 46 | 0 | $self->{tcp_guard} = tcp_server('127.0.0.1', $self->{port}, $cb); | |||||||||||||||||||||||||||
| 47 | } elsif ($self->{path}) { | ||||||||||||||||||||||||||||
| 48 | 0 | $self->{tcp_guard} = tcp_server('unix/', $self->{path}, $cb, $prepare); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub _new_connection { | ||||||||||||||||||||||||||
|
Subroutine
_new_connection: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 53 | 0 | my ($self, $fh) = @_; | |||||||||||||||||||||||||||
| 54 | 0 | my $connection = Devel::REPL::Client::AnyEvent::Connection->new(socket => $fh); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | $RESTORE_READMODE = 1; | |||||||||||||||||||||||||||
| 57 | 0 | ReadMode 3, \*STDIN; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | $self->{on_connection}->($connection); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1 | 1; | |||||||||||||||||||||||||||