RPC.pm

filter: Statementstmt 67.9% 36 / 53 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 9 / 15 Podpod 0.0% 0 / 1 totaltotal 59.2% 45 / 76 CC 3 SCAR 8.8
CC
3
Cov
62%
_build_io
6.0
__ANON__
6.0
__ANON__
2.0
CRAP 2.4
« RPC/API.pm ↑ Summary RPC/Plugin/FileToPackageName.pm »
1 package Neovim::RPC;
2 2 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: RPC client for Neovim
4 2 $Neovim::RPC::VERSION = '0.2.0';
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use MsgPack::RPC;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Neovim::RPC::API::AutoDiscover;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use MsgPack::Decoder;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Class::Load qw/ load_class /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 extends 'MsgPack::RPC';
18  
19 2 has '+io' => (
20 builder => '_build_io'
21 );
22  
23 sub _build_io {
24 0 ▶ my $self = shift;
Subroutine _build_io: not called CC=2 SCAR=17.9
25  
26 0 ▶ my $io =$ENV{NVIM_LISTEN_ADDRESS} || do {
Condition0%0/3
$ENV{'NVIM_LISTEN_ADDRESS'} || do {
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'NVIM_LISTEN_ADDRESS'} || do { open my $in, '<', '-'; open my $out, '>', '-'; [$in, $out] }
$ENV{'NVIM_LISTEN_ADDRESS'} do { open my $in, '<', '-'; open my $out, '>', '-'; [$in, $out] }
Truth table0%0/3
A || B
A= $ENV{'NVIM_LISTEN_ADDRESS'}B= do { open my $in, '<', '-'; open my $out, '>', '-'; [$in, $out] }
ABresult
1X1
011
000
27 0 open my $in, '<', '-';
28 0 open my $out, '>', '-';
29 0 [ $in, $out ];
30 };
31 0 $self->_set_io_accessors($io);
32 0 $io;
33 }
34  
35 has "api" => (
36 is => 'ro',
37 lazy => 1,
38 default => sub {
39 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 Neovim::RPC::API::AutoDiscover->new( rpc => $self, logger => $self->logger );
41 },
42 2 );
43  
44 ▶before subscribe => sub($self,$event,@){
Subroutine __ANON__: not called CC=1 SCAR=6.9
45 0 $self->api->vim_subscribe( event => $event );
46 2 };
47  
48 0 and around emit_request => sub {
49 0 ▶ my( $orig, $self, @args ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
50 0 my $event = $orig->($self,@args);
51 0 ▶ $event->response->fail("no subscriber") unless $event->response->is_ready;
Branch: 1 branch
BranchTrueFalseTotal
unless $event->response->is_ready 0 0 0
52 0 $event;
53 2 };
54  
55 has plugins => (
56 traits => [ 'Array' ],
57 isa => 'ArrayRef',
58 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 2 handles => {
60 _push_plugin => 'push',
61 },
62 );
63  
64 # TODO make that a coerced type
65 ▶sub load_plugin ( $self, $plugin ) {
Subroutine load_plugin: not called CC=1 SCAR=6.9
Pod undocumented
66 0 my $class = 'Neovim::RPC::Plugin::' . $plugin;
67 0 $self->_push_plugin(
68 load_class($class)->new( rpc => $self )
69 );
70 }
71  
72 2 1;
73  
74 __END__
75  
76 =pod
77  
78 =encoding UTF-8
79  
80 =head1 NAME
81  
82 Neovim::RPC - RPC client for Neovim
83  
84 =head1 VERSION
85  
86 version 0.2.0
87  
88 =head1 SEE ALSO
89  
90 =over
91  
92 =item L<http://neovim.io> - Neovim site
93  
94 =item L<http://techblog.babyl.ca/entry/neovim-way-to-go> - blog entry introducing Neovim-RPC to the world.
95  
96 =back
97  
98 =head1 AUTHOR
99  
100 Yanick Champoux <yanick@cpan.org>
101  
102 =head1 COPYRIGHT AND LICENSE
103  
104 This software is copyright (c) 2015 by Yanick Champoux.
105  
106 This is free software; you can redistribute it and/or modify it under
107 the same terms as the Perl 5 programming language system itself.
108  
109 =cut
« RPC/API.pm ↑ Summary RPC/Plugin/FileToPackageName.pm »