RPC/API/Command.pm

filter: Statementstmt 73.1% 30 / 41 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.6% 7 / 11 Podpod 0.0% 0 / 2 totaltotal 59.6% 37 / 62 CC 5 SCAR 15.3
CC
5
Cov
61%
args_to_struct
12.0
__ANON__
6.0
encode
6.0
CRAP 4.6
« RPC/API/AutoDiscover.pm ↑ Summary RPC/API.pm »
1 package Neovim::RPC::API::Command;
2 5 our $AUTHORITY = 'cpan:YANICK';
3 5 $Neovim::RPC::API::Command::VERSION = '0.2.0';
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use MsgPack::Encoder;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use MsgPack::Type::Ext;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶use List::Util qw/ pairmap /;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 ▶use experimental 'postderef';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 has api => (
16 is => 'ro',
17 );
18  
19 5 has deferred => (
20 is => 'ro',
21 default => 1,
22 );
23  
24 5 has name => (
25 is => 'ro',
26 required => 1,
27 );
28  
29 has parameters => (
30 traits => [ 'Array' ],
31 isa => 'ArrayRef',
32 is => 'ro',
33 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 5 handles => {
35 all_parameters => 'elements',
36 num_parameters => 'count',
37 },
38 );
39  
40 5 has receives_channel_id => (
41 is => 'ro',
42 );
43  
44 5 has return_type => (
45 is => 'ro',
46 );
47  
48 sub args_to_struct {
49 0 ▶ my( $self, @args ) = @_;
Subroutine args_to_struct: not called CC=3 SCAR=24.8
Pod undocumented
50  
51  
52 0 my $is_hash = @args == 2 * $self->num_parameters;
53 0 ▶ my %args = $is_hash ? @args : ();
Branch: 1 branch
BranchTrueFalseTotal
$is_hash ? : 0 0 0
54  
55 [
56 pairmap {
57 0 ▶ my $type = $self->api->types->{$a};
Subroutine __ANON__: not called CC=2 SCAR=17.9
58 0 ▶ defined $type
Branch: 1 branch
BranchTrueFalseTotal
defined $type ? : 0 0 0
59 ? MsgPack::Type::Ext->new( type => $type, data => $b )->data
60 : $b
61 }
62 0 ▶ map { $_->[0] => $is_hash ? $args{$_->[1]} : shift @args } $self->all_parameters ]
Branch: 1 branch
BranchTrueFalseTotal
$is_hash ? : 0 0 0
63 }
64  
65 sub encode {
66 0 ▶ my $self = shift;
Subroutine encode: not called CC=2 SCAR=17.9
Pod undocumented
67 0 ▶ my $struct = @_ == 1 ? shift : $self->to_struct(@_);
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 0 0
68  
69 0 return MsgPack::Encoder->new( struct => $struct );
70 }
71  
72 5 1;
73  
74 __END__
75  
76 =pod
77  
78 =encoding UTF-8
79  
80 =head1 NAME
81  
82 Neovim::RPC::API::Command
83  
84 =head1 VERSION
85  
86 version 0.2.0
87  
88 =head1 AUTHOR
89  
90 Yanick Champoux <yanick@cpan.org>
91  
92 =head1 COPYRIGHT AND LICENSE
93  
94 This software is copyright (c) 2015 by Yanick Champoux.
95  
96 This is free software; you can redistribute it and/or modify it under
97 the same terms as the Perl 5 programming language system itself.
98  
99 =cut
« RPC/API/AutoDiscover.pm ↑ Summary RPC/API.pm »