| 1 | package Neovim::RPC; | ||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||
| 3 | # ABSTRACT: RPC client for Neovim | ||||||||||||||||||||
| 4 | 2 | $Neovim::RPC::VERSION = '0.0.1'; | |||||||||||||||||||
| 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 Future; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 2 | ▶ | use Class::Load qw/ load_class /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 2 | ▶ | use experimental 'signatures'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 2 | extends 'MsgPack::RPC'; | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 2 | has '+io' => ( | |||||||||||||||||||
| 21 | builder => '_build_io' | ||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | sub _build_io { | ||||||||||||||||||||
| 25 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_build_io: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | my $io =$ENV{NVIM_LISTEN_ADDRESS} || do { | ||||||||||||||||||
|
Condition0%0/3
$ENV{'NVIM_LISTEN_ADDRESS'} || do {
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]
}
| |||||||||||||||||||||
| 28 | 0 | open my $in, '<', '-'; | |||||||||||||||||||
| 29 | 0 | open my $out, '>', '-'; | |||||||||||||||||||
| 30 | 0 | [ $in, $out ]; | |||||||||||||||||||
| 31 | }; | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | $self->_set_io_accessors($io); | |||||||||||||||||||
| 34 | 0 | $io; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | has "api" => ( | ||||||||||||||||||||
| 38 | is => 'ro', | ||||||||||||||||||||
| 39 | lazy => 1, | ||||||||||||||||||||
| 40 | default => sub { | ||||||||||||||||||||
| 41 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 42 | 0 | Neovim::RPC::API::AutoDiscover->new( rpc => $self, logger => $self->logger ); | |||||||||||||||||||
| 43 | }, | ||||||||||||||||||||
| 44 | 2 | ); | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | ▶ | before subscribe => sub($self,$event,@){ | |||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 47 | 0 | $self->api->vim_subscribe( event => $event ); | |||||||||||||||||||
| 48 | 2 | }; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 and around emit_request => sub { | ||||||||||||||||||||
| 51 | 0 | ▶ | my( $orig, $self, @args ) = @_; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 52 | 0 | my $event = $orig->($self,@args); | |||||||||||||||||||
| 53 | 0 | ▶ | $event->response->fail("no subscriber") unless $event->response->is_ready; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 0 | $event; | |||||||||||||||||||
| 55 | 2 | }; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | has plugins => ( | ||||||||||||||||||||
| 58 | traits => [ 'Array' ], | ||||||||||||||||||||
| 59 | isa => 'ArrayRef', | ||||||||||||||||||||
| 60 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 61 | 2 | handles => { | |||||||||||||||||||
| 62 | _push_plugin => 'push', | ||||||||||||||||||||
| 63 | }, | ||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | # TODO make that a coerced type | ||||||||||||||||||||
| 67 | ▶ | sub load_plugin ( $self, $plugin ) { | |||||||||||||||||||
|
Subroutine
load_plugin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 68 | 0 | my $class = 'Neovim::RPC::Plugin::' . $plugin; | |||||||||||||||||||
| 69 | 0 | $self->_push_plugin( | |||||||||||||||||||
| 70 | load_class($class)->new( rpc => $self ) | ||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 2 | 1; | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | =pod | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =encoding UTF-8 | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head1 NAME | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | Neovim::RPC - RPC client for Neovim | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | =head1 VERSION | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | version 0.0.1 | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =head1 AUTHOR | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | Yanick Champoux <yanick@cpan.org> | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | This software is copyright (c) 2015 by Yanick Champoux. | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 99 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||